- 10, Apr 2020
- #1
NReco PdfGenerator (C# WkHtmlToPdf wrapper)
more info https://www.nrecosite.com/pdf_generator_net.aspx
HTML-to-PDF Generator for .NET C# WkHtmlToPdf wrapper
Features on Convert HTML to PDF in C#:
FAQ:
1. Can I use PdfGenerator in commercial project for FREE?
2. How to include images or reference css/javascript files?
3. Technical limitations, PdfGenerator usage with .NET Core or Mono
4. Custom page header/footer with page numbering
5. Repeat table headers on each page
6. How to handle "Exit with code 1 due to network error: ..." errors
7. Convert Word file (docx) to PDF
8. How to convert ASPX to PDF
9. How to use @media print CSS?
10. Workaround for wkhtmltopdf letter spacing issue (bad kerning).
HTML-to-PDF Generator for .NET C# WkHtmlToPdf wrapper
- NReco PdfGenerator is the name of the software application for format conversion. With this software you will be able to convert HTML and Web pages into a PDF file.
- The feature and feature feature of this software is the ability to turn perfect and perfect web pages.
- This software is able to read CSS languages, images, various web fonts and javascript code.
- For this reason, you can safely convert various HTML pages to PDF.
- More than 99% of the conversions that are made with this software are successful and the converted version has the same quality as the web page version.
- Converting pages to PDF documents in this software is very simple.
- You can convert your desired format to just a few simple and trivial clicks. Also, the NReco PdfGenerator software also has many features that, if you intend to make changes, can help you make these changes as easy as the tools in this software.
Features on Convert HTML to PDF in C#:
- Create PDF from HTML page with one line of C# code.
- Full support of complex layout, CSS, images/svg, custom fonts, javascript code.
- Full support of complex layout, CSS, images/svg, custom fonts, javascript code.
- Precise rendering: in 99% cases PDF result is identical to the web browser view:
- based on WkHtmlToPdf
tool that uses WebKit browser engine.
- based on WkHtmlToPdf
- Simplest way to generate PDF from .NET applications (ASP.NET, ASP.NET MVC, WebForms, .NET Core, VB.NET):
- create PDF from HTML string, file or URL
- convert ASPX to PDF, MVC view to PDF
- merge several HTML pages (files, URLs) into one resulting PDF
- create PDF from HTML string, file or URL
- PDF options:
- page orientation, custom page size, page margins
- HTML template for page header/footer, page numbering, cover page
- automatic table of contents generation by headings (H1/H2/H3)
- page orientation, custom page size, page margins
- Stable and time-proven solution for C# HTML to PDF conversion: all you need is one .NET assembly (wkhtmltopdf binaries are embedded into DLL).
- Has .NET Core compatible version: NReco.PdfGenerator.LT
.
- PdfGenerator C# examples package:
- DataSetReport: generates PDF with data table from DataSet using XSLT
- DemoMvc: generate PDF from ASP.NET MVC views. Illustrates: page breaks, multi-page tables, cover page and table-of-contents, custom header/footer with page numbering
- DemoWebForms: generate PDF from textarea (online demo)
- EncryptPdf: how to generate secured (password protected) PDF
- MergePdf: produce several PDFs and merge whem into one file with iTextSharp
- PdfFromFiles: generate one PDF from several HTML documents (files, URLs)
- WatermarkPdf: how to generate PDF and watermark it with background image or text (watermarked PDF example
)
- BatchMode: optimized generation of several PDF documents in the batch mode
- DataSetReport: generates PDF with data table from DataSet using XSLT
- PdfGenerator converts HTML page (with full CSS / images / js support) to PDF file with one line of C# code.
- Don't spend your time and money on WkHtmlToPDF integration into your .NET application: it's already done!
- Download free package and add reference to the NReco.PdfGenerator.dll assembly OR install NReco.PdfGenerator nuget package
- Convert HTML to PDF with C# code:
-
var htmlContent = String.Format("<body>Hello world: {0}</body>", DateTime.Now); var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
- Create PDF from HTML file or URL (WebForms, MVC page):
-
htmlToPdf.GeneratePdfFromFile("http://www.nrecosite.com/", null, "export.pdf");
- That's all! See also online PdfGenerator API documentation
.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style>table { border:1px solid silver; border-collapse:collapse;} table td { border-bottom:1px solid silver; }</style>
</head>
<body>
<h1 style="text-align:center;">Order #17</h1>
<div style="float:left;">
Donald<br />
XXXXXX Park Avenue<br />
Big City<br /><br />
Date: 8/25/2018
</div>
<div style="float:right;">
<div style="border:1px solid gray;padding:10px;">
A company<br />
321 City Street<br />
Industry Park<br />
Another Country
</div>
</div>
<div style="clear:both;"></div>
<br /><br />
Ordered items list:
<table width="100%" style="margin-bottom:20px;">
<tr>
<td>T-shirt</td>
<td>4</td>
<td>$44</td>
</tr>
<tr>
<td>Coffee cup</td>
<td>5</td>
<td>$25</td>
</tr>
<tr>
<td colspan="2" align="right">Total:</td>
<td>$69</td>
</tr>
</table>
<div style="float:right;">
Signed: Saturday, August 25, 2018 4:11 PM<br />
From IP: XXX.XXX.XXX.XXX
Signature:<br />
<img src="https://www.nrecosite.com/img/pdfgenerator/donald_sign.jpg"/>
</div>
<div style="float:left;">Sincerely,<br />Donald</div>
<div style="clear:both;"></div>
</body>
</html>
FAQ:
1. Can I use PdfGenerator in commercial project for FREE?
2. How to include images or reference css/javascript files?
3. Technical limitations, PdfGenerator usage with .NET Core or Mono
4. Custom page header/footer with page numbering
5. Repeat table headers on each page
6. How to handle "Exit with code 1 due to network error: ..." errors
7. Convert Word file (docx) to PDF
8. How to convert ASPX to PDF
9. How to use @media print CSS?
10. Workaround for wkhtmltopdf letter spacing issue (bad kerning).