Prince: convert HTML with CSS to PDF. Bundles the Prince engine - no separate install required.
Project description
prince-pdf
Python packaging of Prince, the HTML-with-CSS to PDF engine. The wheel bundles the Prince engine for the current platform — no separate installation, no network access at install or run time.
pip install prince-pdf
import prince_pdf
prince_pdf.convert("document.html", "document.pdf")
pdf_bytes = prince_pdf.html_to_pdf("<h1>Hello</h1>") # in-memory
pdf_bytes = prince_pdf.markdown_to_pdf("# Hello") # Prince 17+
The package also puts prince on PATH, so the full
command-line interface works as
documented:
prince document.html -o document.pdf
python -m prince_pdf also works anywhere the package is importable, even
when the script directory is not on PATH.
Prince is free for non-commercial use (output carries a watermark on the
first page until a license is installed). Commercial use requires a
license from YesLogic. Point the
engine at your license file with the PRINCE_LICENSE_FILE environment
variable (preferred — it survives reinstalls), or install it at the path
returned by prince_pdf.license().
Supported platforms: Linux x86-64 and ARM64 (glibc), musl/Alpine ARM64,
macOS 10.13+ (universal), Windows x64 and ARM64. On Linux x86-64 the engine
additionally needs the system fontconfig library — in minimal containers,
apt-get install libfontconfig1 (it usually arrives with fonts anyway).
Names
One package, three names: install it as prince-pdf, import it as
prince_pdf, run it as prince. Note that pip install prince
installs an unrelated statistics library, not this package.
Python API
prince_pdf.convert(inputs, output=None, args=())— convert one or more files (HTML, XML, SVG; Markdown with Prince 17+; a list is merged into one PDF), with the format detected from each file. Extra command-line options go inargs, e.g.args=("--javascript",). Returns the output path, or the PDF asbyteswhenoutputis None.prince_pdf.html_to_pdf(html, output=None, args=()),prince_pdf.markdown_to_pdf(markdown, ...),prince_pdf.xml_to_pdf(xml, ...)— convert a document given as a string or bytes, without temporary files. Combine withoutput=Nonefor fully in-memory conversion. Markdown input requires a bundled Prince 17 or later (pip install --pre prince-pdfwhile 17 is in pre-release); on older enginesmarkdown_to_pdfraises an error saying exactly that.- Failures raise
PrinceErrorcarrying.returncode, raw.stderr, and.messages— the engine's diagnostics parsed intoMessage(severity, location, text)tuples. Engine warnings during successful conversions are emitted on the"prince_pdf"logger. prince_pdf.run(*args, **kwargs)— invoke the engine with raw command-line arguments;kwargspass through tosubprocess.run().prince_pdf.command(*args)— the argv list that would be run, for use with external process tooling.prince_pdf.executable()— path of the bundled engine binary.prince_pdf.version()— the engine's version string.prince_pdf.license()— the default license-file location inside the bundle (preferPRINCE_LICENSE_FILE, which survives reinstalls).
Troubleshooting
- Missing or wrong fonts in minimal containers: the wheel bundles the
engine but uses the system's fonts. Install some, e.g.
apt-get install fonts-dejavu fontconfig(Debian/Ubuntu) orapk add fontconfig ttf-dejavu(Alpine). libfontconfig.so.1: cannot open shared object file(Linux x86-64): install the system fontconfig library, e.g.apt-get install libfontconfig1— installing fonts as above also provides it.- Watermark on the first page: expected without a license — the engine
is fully functional for evaluation and non-commercial use. A purchased
license (via
PRINCE_LICENSE_FILE) removes it. - Documents referencing remote resources: fetching
http(s)images or stylesheets requires network access at conversion time; self-contained local files need none. - Diagnosing failures:
PrinceError.stderrcarries the engine's warnings and errors; add--verbose(or-oplus--log=FILE) for more detail.
How this repository works
This repo contains no Prince binaries and no engine source — only packaging.
versions.json— the release manifest: for each wheel platform tag, the princexml.com artifact URL and its SHA-256. Wheels are built only from artifacts that verify against this manifest, so a commit of this repo fully determines the bytes that reach PyPI.src/prince_pdf/— the wrapper module andprinceconsole script. At build time the engine's installation prefix is bundled asprince_pdf/_bundle/, and the wrapper invokes_bundle/bin/prince --prefix=<bundle>(the same thing the shipped launcher script does).build_hook.py— hatchling hook that sets the wheel's platform tag and pulls in the staged engine tree.scripts/build_wheels.py— download → verify → stage → build, for one or all platforms.scripts/update_versions.py <version>— regenerate the manifest for a new Prince release: downloads the artifacts, computes checksums, and scans the Linux binaries'GLIBC_*symbols so the manylinux tags stay honest..github/workflows/wheels.yml— builds all wheels on one Linux runner (repackaging only, no compilation), smoke-tests each wheel on its real platform (including installing and running with networking disabled), and publishes to PyPI via trusted publishing when av*tag is pushed.
Building locally
pip install build hatchling
python scripts/build_wheels.py --platform macosx_10_13_universal2
pip install dist/prince_pdf-*.whl
python tests/smoke.py
Releasing a new Prince version
python scripts/update_versions.py 17- Review the diff, commit, and push a tag matching the new package version
(
v17.0.0). - CI builds, tests, and publishes to PyPI. Packaging-only fixes between
engine releases use PEP 440 post-releases:
17.0.0.post1.
Pre-release builds map to PEP 440 versions that pip hides from ordinary
users (installed only with --pre or an exact version pin):
- Betas:
python scripts/update_versions.py 17b1→ package17.0.0b1. - Dated builds:
python scripts/update_versions.py 20260630 --dev-of 17→ package17.0.0.dev20260630. The--dev-ofmapping is required — a raw date used as a version would sort above every real release forever..devversions sort before the release they lead to (17.0.0.dev20260630 < 17.0.0b1 < 17.0.0), so once 17.0.0 ships, dated builds must target the next release:--dev-of 17.1. - The pre-release channel may build for a different Alpine range than the
stable channel; pass
--alpine-oldest 3.21accordingly.
Publish selected milestones, not nightlies: each release uploads ~200 MB of
wheels against PyPI's default 10 GB per-project quota. Old .dev releases
can be deleted from PyPI to reclaim space, and quota increases can be
requested if needed.
One-time setup on PyPI: create the prince-pdf project and add a trusted
publisher for this repository (yeslogic/prince-python, workflow
wheels.yml, environment pypi), and create the pypi environment in the
GitHub repo settings (protect it with required reviewers). No sdist is
published — there is nothing to build from source.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prince_pdf-16.2.0-py3-none-win_arm64.whl.
File metadata
- Download URL: prince_pdf-16.2.0-py3-none-win_arm64.whl
- Upload date:
- Size: 12.2 MB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fab0abfad5c31aa058165ef6c650ba9500671b105f6ff73007a1e4e0c9074027
|
|
| MD5 |
7d4a360812c15cc322607b8ee1f4d084
|
|
| BLAKE2b-256 |
c81fb0a1c24333e4ba19a13d3b5cb630d060db2e86479ad063a64227de218466
|
Provenance
The following attestation bundles were made for prince_pdf-16.2.0-py3-none-win_arm64.whl:
Publisher:
wheels.yml on yeslogic/prince-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prince_pdf-16.2.0-py3-none-win_arm64.whl -
Subject digest:
fab0abfad5c31aa058165ef6c650ba9500671b105f6ff73007a1e4e0c9074027 - Sigstore transparency entry: 2166948694
- Sigstore integration time:
-
Permalink:
yeslogic/prince-python@62a3087d3a7d28cf4f6018428865109921137d19 -
Branch / Tag:
refs/tags/v16.2.0 - Owner: https://github.com/yeslogic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@62a3087d3a7d28cf4f6018428865109921137d19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prince_pdf-16.2.0-py3-none-win_amd64.whl.
File metadata
- Download URL: prince_pdf-16.2.0-py3-none-win_amd64.whl
- Upload date:
- Size: 13.9 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c72f49e5f18d58b406edaa7d82646db73c813371eed9c3074c324bfe57ebfa79
|
|
| MD5 |
4f26d59b2db69920e7ca943644bb0032
|
|
| BLAKE2b-256 |
75537828501b57e5bc51dcee92ee5db32290887613aec97e7294c86f0db3de25
|
Provenance
The following attestation bundles were made for prince_pdf-16.2.0-py3-none-win_amd64.whl:
Publisher:
wheels.yml on yeslogic/prince-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prince_pdf-16.2.0-py3-none-win_amd64.whl -
Subject digest:
c72f49e5f18d58b406edaa7d82646db73c813371eed9c3074c324bfe57ebfa79 - Sigstore transparency entry: 2166948708
- Sigstore integration time:
-
Permalink:
yeslogic/prince-python@62a3087d3a7d28cf4f6018428865109921137d19 -
Branch / Tag:
refs/tags/v16.2.0 - Owner: https://github.com/yeslogic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@62a3087d3a7d28cf4f6018428865109921137d19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prince_pdf-16.2.0-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: prince_pdf-16.2.0-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 14.1 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dea89a23f7e06dd765095037e67d0dbf17e749c5a00b43b1a63669fc77679af9
|
|
| MD5 |
963d5693e0abda49db908f50d9f82c22
|
|
| BLAKE2b-256 |
6ff46698a49e59d9f97213f9cee444faff9205e263092e3cac0bd00643b812ef
|
Provenance
The following attestation bundles were made for prince_pdf-16.2.0-py3-none-musllinux_1_2_aarch64.whl:
Publisher:
wheels.yml on yeslogic/prince-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prince_pdf-16.2.0-py3-none-musllinux_1_2_aarch64.whl -
Subject digest:
dea89a23f7e06dd765095037e67d0dbf17e749c5a00b43b1a63669fc77679af9 - Sigstore transparency entry: 2166948668
- Sigstore integration time:
-
Permalink:
yeslogic/prince-python@62a3087d3a7d28cf4f6018428865109921137d19 -
Branch / Tag:
refs/tags/v16.2.0 - Owner: https://github.com/yeslogic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@62a3087d3a7d28cf4f6018428865109921137d19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prince_pdf-16.2.0-py3-none-manylinux_2_25_aarch64.whl.
File metadata
- Download URL: prince_pdf-16.2.0-py3-none-manylinux_2_25_aarch64.whl
- Upload date:
- Size: 13.3 MB
- Tags: Python 3, manylinux: glibc 2.25+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fafcf8c3f285531911f66438193b29c64e1c2992d020aae64156df285957fb78
|
|
| MD5 |
025ba380f440cd0ce7721783b31ba0af
|
|
| BLAKE2b-256 |
6c4758b016cff3ddfc5f24ddd9137c4d32076c75fb98827b7ebe11c71777cc7a
|
Provenance
The following attestation bundles were made for prince_pdf-16.2.0-py3-none-manylinux_2_25_aarch64.whl:
Publisher:
wheels.yml on yeslogic/prince-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prince_pdf-16.2.0-py3-none-manylinux_2_25_aarch64.whl -
Subject digest:
fafcf8c3f285531911f66438193b29c64e1c2992d020aae64156df285957fb78 - Sigstore transparency entry: 2166948655
- Sigstore integration time:
-
Permalink:
yeslogic/prince-python@62a3087d3a7d28cf4f6018428865109921137d19 -
Branch / Tag:
refs/tags/v16.2.0 - Owner: https://github.com/yeslogic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@62a3087d3a7d28cf4f6018428865109921137d19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prince_pdf-16.2.0-py3-none-manylinux_2_17_x86_64.whl.
File metadata
- Download URL: prince_pdf-16.2.0-py3-none-manylinux_2_17_x86_64.whl
- Upload date:
- Size: 14.6 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb083b4bf42d3a0c4dc728d9771a5060b8c727ab87d758d19a9dde36cd586561
|
|
| MD5 |
cdedee81c791220218d22a18d33a122a
|
|
| BLAKE2b-256 |
e3971f889d41c88c0471110a2eaa38aeb8b81fca615d46cd0eead520b866fe64
|
Provenance
The following attestation bundles were made for prince_pdf-16.2.0-py3-none-manylinux_2_17_x86_64.whl:
Publisher:
wheels.yml on yeslogic/prince-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prince_pdf-16.2.0-py3-none-manylinux_2_17_x86_64.whl -
Subject digest:
bb083b4bf42d3a0c4dc728d9771a5060b8c727ab87d758d19a9dde36cd586561 - Sigstore transparency entry: 2166948721
- Sigstore integration time:
-
Permalink:
yeslogic/prince-python@62a3087d3a7d28cf4f6018428865109921137d19 -
Branch / Tag:
refs/tags/v16.2.0 - Owner: https://github.com/yeslogic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@62a3087d3a7d28cf4f6018428865109921137d19 -
Trigger Event:
push
-
Statement type:
File details
Details for the file prince_pdf-16.2.0-py3-none-macosx_10_13_universal2.whl.
File metadata
- Download URL: prince_pdf-16.2.0-py3-none-macosx_10_13_universal2.whl
- Upload date:
- Size: 25.0 MB
- Tags: Python 3, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73667f960b6fffc9cde8abd8470b7b697a8f15653d3a32156a94cd57a0d2a3ea
|
|
| MD5 |
f5e8820b23a7ba8ab0ba7a0b3054c00e
|
|
| BLAKE2b-256 |
980385a583c12b52fbcc310d79272596ca94a6e3552457e803ef3f2454d79724
|
Provenance
The following attestation bundles were made for prince_pdf-16.2.0-py3-none-macosx_10_13_universal2.whl:
Publisher:
wheels.yml on yeslogic/prince-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prince_pdf-16.2.0-py3-none-macosx_10_13_universal2.whl -
Subject digest:
73667f960b6fffc9cde8abd8470b7b697a8f15653d3a32156a94cd57a0d2a3ea - Sigstore transparency entry: 2166948685
- Sigstore integration time:
-
Permalink:
yeslogic/prince-python@62a3087d3a7d28cf4f6018428865109921137d19 -
Branch / Tag:
refs/tags/v16.2.0 - Owner: https://github.com/yeslogic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@62a3087d3a7d28cf4f6018428865109921137d19 -
Trigger Event:
push
-
Statement type: