HTML Files to PDF

C# + VB.Net: HTML Files to PDF HTML Files to PDF
using IronPdf;

// Create a PDF from an existing HTML using C#
 var Renderer = new IronPdf.HtmlToPdf();
 var PDF = Renderer.RenderHTMLFileAsPdf("Assets/TestInvoice1.html");
 var OutputPath = "Invoice.pdf";
 PDF.SaveAs(OutputPath);
Imports IronPdf

' Create a PDF from an existing HTML using C#


 Dim Renderer = New IronPdf.HtmlToPdf()
 Dim PDF = Renderer.RenderHTMLFileAsPdf("Assets/TestInvoice1.html")
 Dim OutputPath = "Invoice.pdf"
 PDF.SaveAs(OutputPath)

We can also render any HTML file on our hard disk.

All relative assets such as CSS, images and js will be rendered as if the file had been opened using the file:// protocol.

This method has the advantage of allowing the developer the opportunity to test the HTML content in a browser during development. We recommend Chrome as being the web browser on which IronPDF's rendering engine is based.