You also can use pdfkit:

Usage

import pdfkit
pdfkit.from_url('http://google.com', 'out.pdf')

Install

MacOS: brew install Caskroom/cask/wkhtmltopdf

Debian/Ubuntu: apt-get install wkhtmltopdf

Windows: choco install wkhtmltopdf

See official documentation for MacOS/Ubuntu/other OS: https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf

Answer from NorthCat on Stack Overflow
🌐
APITemplate.io
apitemplate.io › home › convert html to pdf in python with 5 popular libraries in 2026
Convert HTML to PDF in Python with 5 Popular Libraries in 2026 - APITemplate.io
1 day ago - If you need a quick recommendation, Playwright is usually a strong choice for modern web pages, WeasyPrint works especially well for invoices and reports, and xhtml2pdf is a practical option for simpler HTML-to-PDF tasks. Pyppeteer and python-pdfkit can still be useful, especially if you already have an existing workflow built around them.
Discussions

HTML to PDF using Python and Headless Chrome
I just use weasyprint to transform HTML+CSS into PDF. Running headless Chrome seems slightly overkill for most applications, but it would make sense for dynamically rendered content I suppose. More on reddit.com
🌐 r/django
11
5
February 7, 2024
looking for an "low dependency" or pythonesque way to generate PDF's
Honestly all the good options I've found have required licenses, or are extremely low level, and a pain to use Eventually I always end up just outgrowing them and using a html -> pdf converter https://gotenberg.dev - this is what I use now, you can host your own and have all your clients use it via API calls (just post an html + CSS file and it returns a PDF) Alternatively just pop open a page in their default browser and have them print it to PDF More on reddit.com
🌐 r/Python
58
191
October 10, 2022
HTML to PDF
Look at dompdf-python-tools More on reddit.com
🌐 r/PythonLearning
9
1
September 26, 2024
HTML to PDF with performances
We moved away from HTML generated PDFs to use a layout engine on top of a 2D graphics API. Reason for us was that we needed to handle PDF documents of 6000-10000 pages. HTML generation was very demanding on memory and also slow. A document of 7000 pages takes us about 45 seconds to generate, including data fetching. The html one took several minutes and potentially ran into memory issues. We run all PDF generation outside the app in a docker container which is triggered by a message queue. It automatically scales out depending how many messages that is in queue. For this we use an Azure Container App. More on reddit.com
🌐 r/webdev
43
25
January 6, 2024
🌐
PyPI
pypi.org › project › pyhtml2pdf
pyhtml2pdf · PyPI
Simple python wrapper to convert HTML to PDF with headless Chrome via selenium.
      » pip install pyhtml2pdf
    
Published   Dec 20, 2025
Version   0.1.0
🌐
GitHub
github.com › mikahama › pdfy
GitHub - mikahama/pdfy: A Python library for converting HTML files into PDF with Chrome's engine. · GitHub
options = {"paperWidth": 8.3, "paperHeight":11.7} p.html_to_pdf("html_file.htm", pdf_path="pdf_file.pdf" options=options)
Starred by 21 users
Forked by 7 users
Languages   Python
🌐
Nutrient
nutrient.io › blog › sdk › how to generate pdf reports from html in python
Python PDF generator: Convert HTML to PDF with WeasyPrint and Nutrient API
July 29, 2025 - Multi-platform — Available on multiple operating systems, including Linux, Windows, and macOS. Python integration — WeasyPrint is a Python-based tool, easily integrating with Python projects.
🌐
PDFCrowd
pdfcrowd.com › api › html-to-pdf-python
HTML to PDF / Python Documentation
This page serves as a guide for using the PDFCrowd API to convert web pages and HTML content to PDF in Python applications.
🌐
Reddit
reddit.com › r/django › html to pdf using python and headless chrome
r/django on Reddit: HTML to PDF using Python and Headless Chrome
February 7, 2024 -

I often see questions pop up here and on Discord for how to convert an HTML page to PDF.

There are many ways of course, but I thought I'd share how I do it!

In this post I show how I use a simple Python utility function to start Chrome and output a PDF. For bonus points, I also cover some CSS tricks to control how content splits across pages, and how to prepare a Docker image that contains Chrome.

HTML to PDF Using Python and Headless Chrome

Anyone have a better/simpler way of handling it?

Find elsewhere
🌐
Templated
templated.io › blog › how-to-convert-html-to-pdf-with-python
Convert HTML to PDF in Python with 5 Popular Libraries
February 21, 2024 - Hi, I’m Pedro, the founder of Templated, an API that automates images, PDFs, and videos. In this guide, I’m going to share five popular Python libraries for converting HTML to PDF.
🌐
The Python Code
thepythoncode.com › article › convert-html-to-pdf-in-python
How to Convert HTML to PDF in Python - The Python Code
Learn how you can convert HTML pages to PDF files from an HTML file, URL or even HTML content string using wkhtmltopdf tool and its pdfkit wrapper in Python.
🌐
DocRaptor
docraptor.com › python-html-to-pdf
Compare Top Python HTML to PDF Libraries - Open-Source and Commercial
Our partnership with the Prince commercial PDF library means we have the best support for PDF-specific functionality, such as advanced headers and footers, footnotes, fine-tuned page-break controls, forms, accessible PDFs, printer’s marks, varying page sizes, and much more. DocRaptor also has better CSS and JavaScript support than any non-Chromium-based open-source HTML-to-PDF library. Python-based WeasyPrint has more PDF-specific features than any other open-source library, regardless of language.
🌐
DocRaptor
docraptor.com › documentation › python
How to convert HTML-to-PDF with Python Documentation - DocRaptor HTML to PDF Converter
As the only API that uses the Prince PDF engine, DocRaptor uniquely supports advanced PDF generation features such as mixed layouts and header placements, accessible PDF tagging, crop marks, and more. We've been maintaining the DocRaptor Python package since 2016. Our library only supports Python 3 (we're proud members of the movement to drop Python 2 support). We've done our best to make the DocRaptor package the easiest way to convert HTML to PDF with Python.
🌐
Nutrient
nutrient.io › blog › sdk › how to convert html to pdf using wkhtmltopdf and python
Python HTML to PDF: Convert HTML to PDF using wkhtmltopdf
August 13, 2024 - Install wkhtmltopdf on your system, and then use pdfkit to generate PDFs from URLs, HTML strings, or files with from_url(), from_string(), or from_file(). Customize output with options for page size, orientation, and margins.
🌐
IronPDF
ironpdf.com › tutorials › html to pdf
Convert HTML to PDF in Python & .NET 10 Formatting Maintenance
Learn how to convert HTML to PDF using IronPDF in Python. Follow this comprehensive tutorial to transform your HTML content into professional PDFs.
Published   January 11, 2026
🌐
GitHub
github.com › xhtml2pdf › xhtml2pdf
GitHub - xhtml2pdf/xhtml2pdf: A library for converting HTML into PDFs using ReportLab · GitHub
xhtml2pdf is a HTML to PDF converter using Python, the ReportLab Toolkit, html5lib and pypdf. It supports HTML5 and CSS 2.1 (and some of CSS 3).
Starred by 2.4K users
Forked by 655 users
Languages   Python 52.5% | HTML 45.2% | CSS 2.1%
🌐
Apryse
docs.apryse.com › core › guides › features › conversion › convert-html › python
HTML to PDF Conversion Library in Python | Apryse documentation
The HTML2PDF converter supports HTML conversion from a string or URL and offers many options to control page size and formatting. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB.
🌐
Apache PDFBox
products.documentprocessing.com › conversion › python › xhtml2pdf
xhtml2pdf | Convert HTML to PDF in Python | Open Source
June 25, 2025 - python -m venv env .\env\Scripts\activate pip install xhtml2pdf · We can convert an HTML string to a PDF document using the xhtml2pdf library. We store the complete HTML content in a variable and then pass that variable to the function ...
🌐
Pdfendpoint
pdfendpoint.com › python-html-to-pdf
Python Libraries for HTML to PDF Conversion
Free, Fast and Easy to setup HTML to PDF API for converting URL and HTML to pixel perfect PDFs. Sample implementations in Node.js, Python, C#, Java, etc.
🌐
Medium
medium.com › @pymupdf › how-to-convert-html-tables-to-pdf-5aead22683c8
How to Convert HTML Tables to PDF Using Python | Medium
May 10, 2024 - Use Python to Convert HTML tables to PDF. PyMuPDF now supports a large portion of HTML syntax that is used to define tables.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-html-pdf
Python Convert Html to PDF - GeeksforGeeks
December 30, 2017 - ... sudo apt-get install wkhtmltopdf For Windows: (a)Download link: WKHTMLTOPDF (b)Set: PATH variable set binary folder in Environment variables. Step3: Code in Python to Download: (i) Already Saved HTML page
🌐
Aspose
docs.aspose.com › pdf › python-net › convert-html-to-pdf
Convert HTML to PDF in Python|Aspose.PDF for Python via .NET
September 27, 2025 - Aspose.PDF for Python is a PDF manipulation API that lets you convert any existing HTML documents to PDF seamlessly.