skillfed

pdfkit

Wkhtmltopdf python wrapper to convert html to pdf using the webkit rendering engine and qt

pdfkit v1.0.0 7.8M downloads/30d#1,696 on PyPI2,044
Permissive license MIT DORMANT released

What it is and what it does

pdfkit is a thin Python wrapper around the wkhtmltopdf command-line tool, which uses the Webkit rendering engine to convert HTML into PDF files. It lets you generate PDFs from live URLs, local HTML files, or HTML strings passed directly to the API, with support for options like page size, margins, headers, footers, and table of contents. The package handles the subprocess plumbing and argument construction so you don't have to shell out to wkhtmltopdf manually.

The wrapper requires wkhtmltopdf to be installed as a separate system binary; pdfkit itself has no Python runtime dependencies. It supports both Python 2 and 3 (though Python 2 is long obsolete) and offers a simple three-function API: from_url(), from_file(), and from_string(). You can also retrieve the PDF as a byte string instead of writing to disk, and pass detailed configuration options via dictionaries.

Use it for:

  • Generate PDF reports from HTML templates in a web application without relying on a headless browser service.
  • Batch-convert multiple HTML files or URLs to PDF for archival or distribution.
  • Create invoices or receipts by rendering HTML with CSS styling directly to PDF.
  • Embed PDF generation in a Python script that needs to produce documents from web content.
  • Add table of contents, headers, and footers to HTML-based documents during PDF export.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Python wrapper for wkhtmltopdf that converts HTML to PDF using the Webkit rendering engine, supporting URLs, files, and HTML strings as input.

Yes, if you need simple HTML-to-PDF conversion and are willing to manage the wkhtmltopdf system dependency. The package is stable and widely used, but dormant—no active maintenance since late 2023. Check the two known vulnerabilities before use in security-sensitive contexts. For new projects, consider whether a maintained alternative or headless-browser service better fits your risk tolerance.

Install

pdfkit on PyPI

pip

pip install pdfkit

uv

uv add pdfkit

poetry

poetry add pdfkit

Installing pdfkit

Before you install

Low install friction with no runtime dependencies. However, the package is dormant—last release was 2021-11-14 and last commit 2023-10-26—so expect no active maintenance or updates for emerging issues.

License in practice

MIT license is permissive, allowing commercial and private use with minimal restrictions.

Quickstart

pip install pdfkit

import pdfkit

pdfkit.from_url('http://google.com', 'out.pdf')
pdfkit.from_file('test.html', 'out.pdf')
pdfkit.from_string('Hello!', 'out.pdf')

wkhtmltopdf binary must be installed separately on your system (via apt-get, brew, or direct download); pdfkit is only a Python wrapper and will not function without it.

Verify before relying

  • Current compatibility with modern Python versions beyond 3.9 (classifiers list 3.9 as latest)
  • Status of the two known vulnerabilities (GHSA-9g3x-6x24-vf9f, PYSEC-2026-2860) and whether they affect typical use
  • Whether Debian/Ubuntu wkhtmltopdf packages still have reduced functionality as documented

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,734 days since the last release
Last repo commit
First released
Downloads 7,782,391/month — #1,696 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities 2 — GHSA-9g3x-6x24-vf9f, PYSEC-2026-2860

Evidence: pdfkit-1.0.0-py2-none-any.whl; pdfkit-1.0.0-py3-none-any.whl

Programming Language :: PythonProgramming Language :: Python :: 2.7Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Text ProcessingTopic :: Text Processing :: GeneralTopic :: Text Processing :: MarkupTopic :: Text Processing :: Markup :: HTMLTopic :: Text Processing :: Markup :: XMLTopic :: Utilities

Tags

html to pdf conversionwkhtmltopdf python wrapperwebkit pdf generationconvert html string to pdfbatch html to pdfpdf from url pythonhtml file to pdf converter
pdf-generationhtml-conversionwebkit-rendering

More Utilities packages