Rendering PDF Pages
Rendering a PDF to an image is made simple with the PSPDFKit .NET Library. We leverage native .NET standard features in order to maintain compatibility and stay efficient.
Render a Page
Once you have a document instance, it’s very simple to render a page. The following will open a document and render page 0 with the dimensions of the page:
1 2 3
var document = new Document(new FileDataProvider("Assets/default.pdf")); var page = document.GetPage(0); var bitmap = page.RenderPage();
It’s also possible to pass custom dimensions to scale the image:
var bitmap = page.RenderPage(50, 50);
Save to File
The PSPDFKit .NET Library uses the Microsoft
System.Drawing.Common package to handle drawing and bitmaps. This package may also require a library installation on your target system.
sudo apt install libgdiplus
brew install mono-libgdiplus
RenderPage returns a native .NET
Bitmap object. Saving it out as a PNG image, for example, would then look like this: