html2PDF is an iText Core add-on available for Java and C# (.NET) that allows you to easily convert HTML and CSS into standards compliant PDFs that are accessible, searchable and usable for indexing.
- Converting XML/HTML & CSS to PDF or PDF/A
- Convert XML/HTML & CSS to iText objects
- Good default support for HTML5 and CSS3
- Easily configurable and extensible when needed
- Not based on any browser engine implementation
For the full list of supported\unsupported features please refer to Supported\Unsupported featues
Want to discover what's possible? Head over to our Demo Lab! It contains a collection of demo applications ready to use online!
The easiest way to get started is to use NuGet, just execute the following install command in the folder of your project:
dotnet add package itext.pdfhtml --version <REPLACE_WITH_DESIRED_ITEXT_VERSION>For more advanced use cases, please refer to the Installation guidelines. You can also build iText Community from source.
The following code snippet shows how to convert HTML to PDF using the HtmlConverter class:
The following example shows how easy it is to create a simple PDF document:
using iText.Html2pdf.ConverterProperties;
using iText.Html2pdf.HtmlConverter;
namespace HelloPdf {
class Program {
static void Main(string[] args) {
// Base URI is required to resolve the path to source files
ConverterProperties converterProperties = new ConverterProperties().SetBaseUri(resourceLoc);
HtmlConverter.ConvertToPdf(
new FileStream(htmlSource, FileMode.Open, FileAccess.Read, FileShare.Read),
new FileStream(pdfDest, FileMode.Create, FileAccess.Write),
converterProperties);
}
}
}For more advanced examples, refer to our Knowledge Base or the main Examples repo. You can find C# equivalents to the Java Signing examples here, though the Java code is very similar since they have the same API.
Some of the output PDF files will be incorrectly displayed by the GitHub previewer, so be sure to download them to see the correct results.
| Description | Link |
|---|---|
| Convert HTML to PDF/A-3B compliant document | C#, PDF |
| Convert HTML with custom QR code tags to PDF | C#, PDF |
| Create accessible tagged PDF from HTML content | C#, PDF |
| Convert HTML to PDF simulating color blindness vision | C#, PDF |
| Register custom fonts for HTML to PDF | C# |
| Convert HTML forms to tagged PDF with custom roles | C#, PDF |
| Convert HTML file with assets | C#, PDF |
| Enable formfield interactivity | C#, PDF |
| Convert HTML containing arabic and hebrew | C#, PDF |
Check out the iText Knowledge Base for tutorials, FAQs and more. Many common questions have already been answered on Stack Overflow, so make sure to also check there.
Many people have contributed to iText Community over the years. If you've found a bug, a mistake in documentation, or have a hot new feature you want to implement, we welcome your contributions.
Small changes or fixes can be submitted as a Pull Request, while for major changes we request you contact us at community@apryse.com so we can better coordinate our efforts and prevent duplication of work.
Please read our Contribution Guidelines for details on code submissions, coding rules, and more.
html2Pdf is dual licensed as AGPL/Commercial software.
AGPL is a free/open-source software license, however, this doesn't mean the software is gratis!
The AGPL is a copyleft license, which means that any derivative work must also be licensed under the same terms. If you’re using iText in software or a service which cannot comply with the AGPL terms, we have a commercial license available that exempts you from such obligations.
Contact Sales for more info.
