Rendering PDF Pages in .NET
Rendering a PDF to an image is made simple with the PSPDFKit .NET Library. We leverage native .NET standard features to maintain compatibility and stay efficient.
Once you have a document instance, it’s easy to render a page. The following will open a document and render page 0 with the dimensions of the page:
var document = new Document(new FileDataProvider("document.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);
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 look like this: