Some test text!

menu
Web/HTML to PDFkeyboard_arrow_down

Convert HTML to PDF in Python

To convert an HTML file to a PDF document without any external third party dependencies.

Requires the HTML2PDF module add-on. This is already included in the download package from the PDFTron website but may need to be manually added to your project if installing from a package manager.
# Start with a PDFDoc (the conversion destination)
doc = PDFDoc()
converter = HTML2PDF()

# add from HTML String data
converter.InsertFromHtmlString(htmlString)

# add from a web page location
converter.InsertFromURL(webPageLocation)

# apply conversion
converter.Convert(doc)

Convert HTML to PDF
Full sample code for directly converting HTML pages to PDF by using 'pdftron.PDF.HTML2PDF'. The HTML2PDF converter supports HTML conversion from a string or URL and offers many options to control page size and formatting.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.