Create PDF from Html, converting any web (Html and Css) to PDF document.

.NET Html to PDF converter offers a powerful html to pdf function to convert any web page or raw html string to pdf. The converter has full support for HTML tags, CSS (Extensive HTML 4.01 and CSS level 2 specifications), hyperlinks, form elements. It's useful to the users who are familiar to html, so converting html with specified style to PDF document becomes easily.

The online guide shows how to change Html string to PDF document using C# language.

// Html source code, or you can load from local .html file
string html = "<html><body><h1>This is H1</h1><div>Normal text</div>"
    + "<div style=\"color:red;\">Red text</div></body></html>";

HtmlPdfConverter converter = new HtmlPdfConverter();

// Customize the generated pdf page layout
converter.PageSize = PageSize.A4;
// You can set the specified page size excluded the standard layout
//converter.ManualPageSize = new XSize(700, 1200);

// Generate pdf from html content           
PdfDocument document = converter.CreatePdf(html);

// Save and show the document 
document.Save("Html2Pdf.pdf");
Process.Start("Html2Pdf.pdf");

Html to PDF converter provides PageOrientation property, developers can generate PDF in Landscape and Portrait style. Besides, page margins are also supported.

More PDF tutorial