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# 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.