PDF-to-Image Renderer for .NET C# wrapper for poppler tools
features
- C# component for rendering PDF pages to high-resolution images (jpg, png, tiff): can be used for generating PDF thumbnails, PDF viewer in ASP.NET apps.
- PdfRenderer is a .NET wrapper for open-source poppler tools pdftoppm, pdftotext, pdfimages, pdfinfo: XPDF successor, works WITHOUT Ghostscript or Adobe Reader. Both Windows and Linux deployments are supported.
- get info about PDF file: number of pages, page size.
- extract PDF images or get a list of images with metadata.
- scale to fit specified image size.
- render pages range (or all pages) in one pass.
- extract PDF text content (possibly with layout metadata).
- No external dependencies: all you need is one assembly. Poppler binaries (windows build) are included in nuget and extracted automatically on first use. For non-windows environments poppler utilities should be installed separately.
-
Usage examples (C# / NET6):
- 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)
- PdfImages: how to get list of images in PDF and extract them as image files
- PdfToText: how to extract text with metadata from PDF
download and pricing
NReco PdfRenderer Examples pack
Includes PDF Renderer trial for evaluation and testing purposes |
Download |
NReco PdfRenderer binary license pack
Includes: perpetual commercial license for redistribution and SaaS usage, license key, 1 year of email support and free component upgrades |
$199 - Order Now |
NReco PdfRenderer source code license pack
Includes: all binary license options + component source code |
Request Pricing |
quick purchase process
- 1 Choose a package
- 2 Pay online
- 3 Download the package
Need to render PDF to images (jpeg, png, tiff) or extract PDF text in C# code?
NReco.PdfRenderer is a right choice!
NReco.PdfRenderer is a right choice!
how to use
- Install NReco.PdfRenderer nuget package.
- Convert PDF to JPG in one line of C# code:
var pdfFile = "Sample1.pdf"; var pdfToImg = new NReco.PdfRenderer.PdfToImageConverter(); pdfToImg.ScaleTo = 600; // fit 600x600 box for preview pdfToImg.GenerateImage( pdfFile, 1, ImageFormat.Jpeg, "Sample1.jpg" );
- That's all! See API Reference for more details.
convert PDF to image online
Get PDF page thumbnail
Note: thumbnail is scaled to 800px (you can get better resolution).
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.
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.
NReco.PdfRenderer provides
PdfToTextConverter (API for 'pdftotext') that can be used for this purpose:
var pdfToText = new PdfToTextConverter(); pdfToText.CustomArgs = " -bbox-layout -eol dos "; var textWithLayoutMetadata = pdfToText.GenerateText("test.pdf");
NReco.PdfRenderer nuget package includes
For Linux deployments it is recommended to use nuget NReco.PdfRenderer.LT:
netstandard20
build which is fully compatible with
all .NET versions: .NET Framework, .NET Core 3.1, NET6+, NET8.
This nuget package includes poppler binaries for Windows and has dependency on System.Drawing.Common;
if your .NET apps is deployed on Linux (where poppler tools are installed separately) these things might be undesired + System.Drawing.Common is not supported on Linux starting from NET7.
For Linux deployments it is recommended to use nuget NReco.PdfRenderer.LT:
- LT-version nuget doesn't include poppler binaries for Windows (DLL size is only ~64kb).
- A license key is required by LT-version (no trial mode).
- When a .NET app is deployed on Linux, the wrapper tries to locate poppler tools in
/usr/local/bin
or/usr/bin
. If poppler executables (pdftoppm, pdfinfo etc) use another location you need to set "ToolPath" property explicitly. On Windows, there is no standard location for poppler tools so "ToolPath" needs to be initialized if NReco.PdfRenderer.LT is used on Windows.
- Ubuntu/Debian:
sudo apt-get install -y poppler-utils
- Other OS: use latest poppler tools release
Starting from PdfRenderer version 1.2.0 you can use
GenerateImage
and GenerateImages
overloads that accept Stream
as input to render PDF content without using temporary local file (C#):
void ProcessFileFromUrl(string url, Action<Stream> handler) { using (var httpClient = new System.Net.Http.HttpClient()) { using (var responseStream = httpClient.GetStreamAsync(url).GetAwaiter().GetResult()) { handler(responseStream); } } }
var pdfToImage = new PdfToImageConverter(); var pdfUrl = "https://www.adobe.com/support/products/enterprise/knowledgecenter/media/c4611_sample_explain.pdf"; ProcessFileFromUrl(pdfUrl, (pdfInputStream) => { pdfToImage.GenerateImage(pdfInputStream, 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.
If PDF text is not rendered most likely you need to use poppler encoding data
(it is not included into distribution by default). You can verify that by handling "LogReceived" event;
typical errors are smth like Missing language pack for 'Adobe-Korea1' mapping
,
Missing language pack for 'Adobe-Japan1' mapping
, Missing language pack for 'Adobe-CNS1' mapping
.
In case of .NET Core on Linux it is enough to install "poppler-data" package. For Windows environment:
- download an archive with "poppler-data": https://poppler.freedesktop.org/poppler-data-0.4.12.tar.gz and extract
poppler-data-0.4.12
folder (it should contain folders "cidToUnicode", "cMap", "nameToUnicode", "unicodeMap") - prepare special folder for poppler binaries and poppler-data files. Let's assume this is
<your_asp_net_app_folder>\App_Data\PdfRenderer
- copy everything from
poppler-data-0.4.12
folder to<your_asp_net_app_folder>\App_Data\PdfRenderer\share\poppler
-
in C# code, change default path for poppler binaries to use your special folder:
var pdfToImage = new PdfToImageConverter(); pdfToImage.ToolPath = "<your_asp_net_app_folder>\App_Data\PdfRenderer\poppler\bin";
- now PdfRenderer should render PDFs with non-Unicode characters correctly
It is possible to use NReco.PdfRenderer in Azure Function under the following conditions:
- because of Azure Functions hosting environment System.Drawing API is not supported.
This means that you should avoid usage of API methods that return
System.Drawing.Image
object or use NReco.PdfRenderer.LT nuget. - in trial mode component applies a watermark and this causes an exception for the same reason (System.Drawing API cannot be used). You can request a demo key for testing purposes if you want to ensure that everything works fine.
- by default wrapper extracts poppler tools binaries into the folder with .NET Core app.
It is read-only in case of Azure Functions, so you need to specify another location:
var pdfToImg = new NReco.PdfRenderer.PdfToImageConverter(); pdfToImg.ToolPath = Path.Combine(Path.GetTempPath(), "NRecoPdfRenderer");
what's new
2024 Oct 08 |
v.1.6.0 changes:
|
2024 Jul 23 |
v.1.5.4 changes:
|
2023 Nov 20 |
v.1.5.3 changes:
|
2023 Oct 16 |
v.1.5.2 changes:
|
2022 Sep 21 |
v.1.5.1 changes:
|
2022 Jul 16 |
v.1.5.0 changes:
|
2021 Oct 13 |
v.1.4.1 changes:
|
2021 Jul 25 |
v.1.4.0 changes:
|
2020 Aug 24 |
v.1.3.1 changes:
|
2020 May 22 |
v.1.3.0 changes:
|
2018 Aug 25 |
v.1.2.2 changes:
|
2018 Aug 25 |
v.1.2.2 changes:
|
2018 Aug 23 |
v.1.2.1 changes:
|
2018 Aug 16 |
v.1.2.0 changes:
|
2018 Apr 11 |
v.1.1.2 changes:
|
2017 Nov 28 |
v.1.1.1 changes:
|
2017 Nov 11 |
v.1.1.0 changes:
|
2017 Jun 18 |
v.1.0.2 changes:
|
2017 Jan 06 |
v.1.0.1 changes:
|
2016 Nov 22 |
v.1.0.0 features:
|
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.