PDF-to-Image Renderer for .NET C# wrapper for poppler tool (XPDF)


features

  • C# component for rendering PDF pages to high-quality images (jpg, png, tiff): can be used for PDF thumbnails, PDF viewer in both ASP.NET and desktop apps.
  • .NET wrapper for FREE poppler tools: XPDF successor, works WITHOUT Ghostscript or Adobe Reader.
  • can scale to fit specified image size.
  • can extract info about PDF file: number of pages, page size.
  • can render pages range (or all pages) in one pass.
  • No external dependencies: all you need is one assembly. Poppler binaries are embedded as archive and extracted automatically on first use (windows platform only).
  • Usage examples (C#):
    • CreatePdfThumbnails: generates PDF thumbnails by PDF 1-st page, illustrates how to resize/scale rendering result to fit image size constraints (2 ways)
    • PdfViewerMvc: ASP.NET PDF viewer - renders each page to image on the server side (user has no access to original PDF file)
Need to render PDF to images from C# code?
NReco.PdfRenderer is a right choice!

download and pricing

quick purchase process

  • 1 Choose a package
  • 2 Pay online 2Checkout.com is a worldwide leader in online payment services
  • 3 Download the package

how to use

  1. Install latest version of NReco.PdfRenderer nuget package. Also you can download nupkg file from nuget.org, extract the DLL and reference it directly if you like.
  2. Convert PDF to JPG with one line of C# code:
    var pdfFile = "Sample1.pdf";
    var pdfToImg = new NReco.PdfRenderer.PdfToImageConverter();
    pdfToImg.ScaleTo = 200; // fit 200x200 box
    pdfToImg.GenerateImage( pdfFile, 1, 
      ImageFormat.Jpeg, "Sample1.jpg" );
  3. That's all! See API Reference for more details.
Feel free to contact us in case of any questions.

convert PDF to image online


Get PDF page thumbnail

frequently asked questions

PdfRenderer is licensed per-company (or individual) and can be used in company's products without any limitations (unlimited number of developers/deployments). Trial version can be used only for evaluation/testing purposes.

Internally PdfRenderer executes poppler tools as a separate programs (with System.Diagnostics.Process); poppler is licensed under GPL and it may be used/redistributed for free. According to GPL conditions, "aggregate" (usage and distribution of GPL-program when it is executed from another non-GPL program) is allowed. Note that if you're redistribute PdfRenderer as part of your product, you need to declare that it depends on poppler tools as separate program and include all notices required by GPL redistribution terms.
The following features may be implemented in the future releases:
  • render PDF to text for indexing purposes (for keyword-based search across PDF files)
  • render PDF to HTML for web publishing
If you are interested in one of these features please let us know.
Starting from version 1.0.2 PdfRenderer nuget package includes netstandard1.5 build that can be used from .NET Core apps. Note that only win32 binaries of poppler tool are shipped with NReco.PdfRenderer assembly; on non-Windows platforms poppler utilities (pdftoppm, pdfinfo) should be installed separately:
Currently poppler (pdftoppm) can use only local PDF file as input. You can save PDF from URL to temporary file, render page(s), and remove temp file in the following way (C#):
void ProcessFileFromUrl(string url, Action<string> handler) {
  var tmpFileName = Path.GetTempFileName() + ".pdf";
  try {
    using (var webClient = new System.Net.WebClient()) {
      webClient.DownloadFile(url, tmpFileName);
      handler(tmpFileName);
    }
  } finally {
    if (File.Exists(tmpFileName))
      File.Delete(tmpFileName);
  }
}
var pdfToImage = new PdfToImageConverter();

var pdfUrl = "https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf";
ProcessFileFromUrl(pdfUrl, (pdfFileName) => {
  pdfToImage.GenerateImage(pdfFileName, 1, ImageFormat.Jpeg, "c:\\temp\\test.jpg");
});
Starting from v.1.1.0 it is possible to use PdfInfo class for this purpose (C#):
var pdfInfo = new PdfInfo();
var testPdfInfo = pdfInfo.GetPdfInfo(@"test.pdf");
Console.WriteLine($"Pages: {testPdfInfo.Pages}");
Console.WriteLine($"Page size: {testPdfInfo.PageSize.PageFormat}");
This is possible with GenerateImages method (available in v.1.1.0 or newer):
var fileNames = pdfToImage.GenerateImages(@"test.pdf", 
	3, 7,  // render from pages 3-7
	ImageFormat.Png, "outputFolder");
As result 4 images are produced and saved into specified folder.

what's new

2018 Apr 11 v.1.1.2 changes:
  • use System.Drawing.Common instead of CoreCompat.System.Drawing.v2 in netstandard2.0 build
2017 Nov 28 v.1.1.1 changes:
  • added netstandard20 build to nuget package (solves System.Drawing.Color compile-time conflict in .NET Core 2 apps)
2017 Nov 11 v.1.1.0 changes:
  • added PdfInfo class (wrapper for pdfinfo.exe) that allows to get some information about PDF file (like number of pages).
  • added PdfToImageConverter.GenerateImages method that renders specified page range (or all pages) in one pass.
2017 Jun 18 v.1.0.2 changes:
  • poppler win32 binaries updated to v.0.51
  • added netstandard1.5 build (can be used from .NET Core apps). Only win32 binaries of poppler tool are shipped with PdfRenderer and for non-Windows platforms it should be installed separately.
2017 Jan 06 v.1.0.1 changes:
  • poppler binaries updated to v.0.50 (released on December 15, 2016)
2016 Nov 22 v.1.0.0 features:
  • render PDF pages to png, jpg, tiff formats
  • scale image to fit specified box (N*N) automatically
  • change rendering resolution (DPI=150 by default)

more components

  • HTML-to-PDF Generator

    .NET wrapper for WkHtmlToPdf utility that generates PDF reports by HTML template.

  • Image Generator

    .NET wrapper WkHtmlToImage utility that generate pretty-looking images by HTML layout.