HTML Files to PDF

C# + VB.Net: HTML Files to PDF HTML Files to PDF
 // Install IronPdf with Nuget:  PM> Install-Package IronPdf
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);
' Install IronPdf with Nuget:  PM> Install-Package IronPdf
Imports IronPdf

' Create a PDF from an existing HTML using C#
 Private Renderer = New IronPdf.HtmlToPdf()
 Private PDF = Renderer.RenderHTMLFileAsPdf("Assets/TestInvoice1.html")
 Private 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.