You may often bookmark interesting HTML pages in web browser for later reviewing. Or you may need to view and read important web page whenever the internet is connected or not. As we all know, PDF is might be the most convenient way to print, view, navigate, and forward to someone else. So, to make things easier, it is a wise choice to save HTML to PDF document.

XsHtml .NET HTML to PDF SDK is one of the best C# HTML to PDF converter libraries for various .NET applications, like ASP.NET, MVC web sites, WinForms and WPF applications. This C# html to pdf converter library compiles mature html to pdf apis into an independent .NET library dll.

PDF documents created and saved from Html web page and Html string are all compatible with PDF standards, like full PDF, PDF/A, and PDF/UA. This C# html to pdf converter library for .NET supports HTML5 and CSS3 that helps to fully layout and style your PDF document.

How to Save HTML to PDF with C# API and Code

XsHtml .NET HTML to PDF SDK is easy to save and convert HTML to PDF with a few lines of C# code. Various html to pdf APIs are provided for your customization. Please see a simple html to pdf conversion example as below.

string html = @"sample.html";
string savePath = "sample.pdf";

// Create a Html converter instance 
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// Set output PDF size
converter.PageSize = PageSize.A4;
// Convert html to PDF
converter.ConvertFromFile(html, savePath);

Notice - If you use the free trial version of .NET HTML to PDF SDK, there is a statement in PDF page footer, "This is an XsPDF trial version"