HTML Files to PDF
IronPDF can transform HTML files located on a computer or a network file path. To accomplish this, call the
PdfDocument.renderHtmlFileAsPdf method, as the example above shows.
PdfDocument.renderHtmlFileAsPdf will return a new
PdfDocument object containing the content of the HTML file found at the provided location. This method will also render all relatively referenced assets within the HTML file (such as paths to stylesheets, scripts, and images) faithfully within their proper context in the HTML file.
In short, the HTML file will appear as a PDF the same way that it appears in a browser—with all images and CSS intact!
PdfDocument.renderHtmlFileAsPdf will throw an
IOException if it is unable to locate the HTML file or open it for reading.
Refer to the API Documentation page for the
ChromePdfRenderOptions class for more information on how to use the class to customize the appearance of PDF documents created from the