PdfGenerator produces PDF by HTML in .NET projects
PdfGenerator is a .NET wrapper for WkHtmlToPdf tool that generates high-quality PDF documents from HTML pages. WkHtmlToPdf is based on WebKit engine and resulting PDF in most cases is identical to HTML web browser view.
- supports custom page size, orientation, margins, cover page and autogenerated table-of-contents.
- header/footer also defined with HTML. It is possible to use special tokens for page numbers / total number of pages / section title.
- friendly deployment: all in one DLL (no external dependencies, wkhtmltopdf is embedded as assembly resource and automatically extracted on first use)
- can be used from ASP.NET server code, Azure WebRole / WorkerRole
- Azure Apps (WebSites) / WebJobs are not supported at this moment (because of GDI usage limitations)
- one PDF can be generated from several HTML pages
- can be used for generating watermarked and secured (password protected) PDFs
- PdfGenerator LT build can be used in .NET Core projects
Convert HTML to PDF with one line of C# code
- install NReco.PdfGenerator nuget package
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
var pdfBytes1 = htmlToPdf.GeneratePdf(htmlContent);
var pdfBytes2 = htmlToPdf.GeneratePdfFromFile("https://google.com");