This sample uses EO.Pdf for .NET to convert any HTML markup to PDF.
Use it in your Application
Sample code to convert HTML markup to PDF (many advanced features not shown here):
//Code to convert HTML to PDF. The following code writes output to a file.
//You can also write output to a Stream, a PdfPage, or a PdfDocument object
HtmlToPdf.ConvertHtml(htmlCode, outputFileName);
'Code to convert HTML to PDF. The following code writes output to a file.
'You can also write output to a Stream, a PdfPage, or a PdfDocument object
HtmlToPdf.ConvertHtml(htmlCode, outputFileName)
Detailed documentation and sample code about this feature can be found in the
download package.
Try it Online
More samples and demos with source code can be found in the download package.
Core Features
- Convert any valid HTML to PDF. Rendering any HTML the same as your browser
does, but output as PDF;
- Zero External Dependency. Does not depend on any Web browser on your system.
Will always work regardless you install, uninstall or update your browsers;
- Built-in CSS1, CSS2 and CSS3 support. All CSS standards are supported. Feel
free to use any CSS in your HTML code;
- Built-in Javascript Engine. All Javascript code runs exactly the same way
as they would in a browser. You can also turn Javascript off;
- Automatic and Manual Paging. The converter can automatically page the contents
into multiple pages completely based on page contents or "hard page break" styles
such as "page-break-before" and "page-break-after" in your HTML code;
- Scale to Fit. Automatically scaling the HTML page to fit in PDF paper size,
or use a fixed scaling factor (or not scaling at all);
- Selectable Text and clickable Links. The generated PDF file is not a "screenshot"
image. All texts in your HTML file are rendered as selectable text in PDF. All links
in your HTML file are preserved;
- Multiple output options. Output to a file? Output to a stream? Output to
Web client? Output as a download file? Choose one that fits your need.
- And much more.
Try it out for free to see it in action!