IRONSOFTWAREHOME
HTML Files to PDF
from ironpdf import *

# Instantiate Renderer
renderer = ChromePdfRenderer()

# Create a PDF from an existing HTML file using Python
pdf = renderer.RenderHtmlFileAsPdf("example.html")

# Export to a file or Stream
pdf.SaveAs("output.pdf")
pip install ironpdf
HTML Files to PDF

HTML Files to PDF

Convert an entire HTML file into a pixel-perfect PDF with IronPDF for Python's RenderHtmlFileAsPdf method.

Getting Started

To convert an HTML file to PDF, you can use the RenderHtmlFileAsPdf method. This method requires only the path to the local HTML file and returns a PdfDocument object. This object contains the content from the HTML file, rendered as if viewed in a web browser. Ensure your HTML contains valid markup to avoid rendering issues.

Here's a simple example of how to use the method:

Understanding the Code

  • ChromePdfRenderer: This object serves as the point of interaction with the rendering process. It allows adjustments to the PDF output by setting properties like headers, footers, and more.
  • ChromePdfRenderer: This method takes a path to an HTML file and converts it into a PdfDocument. The generated PDF will closely match the HTML file as it appears in a web browser.
  • save_as: This method saves the newly created PDF document to the specified path on your file system.

Customizing the PDF Output

ChromePdfRenderer comes with various options for customization, including setting headers, footers, margins, backgrounds, page numbers, etc. For more advanced features and customization, see this code example and learn how to customize PDF output.

Learn to Convert HTML to PDF with This Tutorial!
View on GitHub

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999