Convert HTML to PDF in C# using Spire.PDF


As far as I know, this is the simplest solution with high quality to convert any HTML file to PDF using C# and finally I chose this one. It supports to convert the complex HTML page with rich elements, such as HTTPS, CSS3, HTML5, JavaScript. But it is not free. You can have 1 month free trial on it. If you want to use it in commercial application, you need to purchase the license at the acceptable price.

https://pdfapi.codeplex.com/


Code Snippet
  1. //Create a pdf document
  2. PdfDocument doc = new PdfDocument();
  3. String url = "Http://apple.com/"
  4. doc.LoadFromHTML(url, false, true, true);
  5. //Save pdf file
  6. doc.SaveToFile("webpageaspdf.pdf");
  7. doc.Close();
  8. System.Diagnostics.Process.Start("webpageaspdf.pdf");

Post a Comment