Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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, and neither installing the package nor launching the engine downloads anything. (Prince will access the network only if a document being converted references remote resources such as images or stylesheets.)

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.

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.

Files vs. strings

convert() always interprets strings as filesystem paths, never as document content. To convert an HTML string, use html_to_pdf().

The *_to_pdf functions pipe the document through the engine's standard input, so the engine never sees a filename: relative URLs in the document are resolved against the current working directory, not against wherever the content originally came from. If a string derived from /tmp/report/index.html references images/chart.svg, pass the original location as a base URL:

prince_pdf.html_to_pdf(html, args=("--baseurl", "/tmp/report/"))

Python API

The package ships inline type annotations (py.typed).

  • 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 in args as a sequence of individual argument tokens — args=("--baseurl", "https://x.example/"), never a shell string like "--baseurl https://x.example/". Returns the output path, or the PDF as bytes when output is 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. Markdown input requires a bundled Prince 17 or later (pip install --pre prince-pdf while 17 is in pre-release); on older engines markdown_to_pdf raises an error saying exactly that.
  • Failures raise PrinceError carrying .returncode, raw .stderr, and .messages — the engine's diagnostics parsed into Message(severity, location, text) tuples. Engine warnings during successful conversions are emitted on the "prince_pdf" logger.
  • prince_pdf.run(*args, **kwargs) — a thin subprocess.run() wrapper for raw engine access. It does not apply the error handling or diagnostic parsing that convert() provides: nonzero exits do not raise (pass check=True for CalledProcessError), and output is not captured unless requested.
  • prince_pdf.command(*args) — the argv list that would be run, for use with external process tooling (same caveats as run()).
  • 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 (prefer PRINCE_LICENSE_FILE, which survives reinstalls).

Licensing

Prince may be used without a purchased license under the conditions in the included Prince License Agreement (LICENSE-Prince.txt); unlicensed output carries a watermark on the first page. Commercial use requires an appropriate 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(). The Python wrapper code itself is MIT-licensed (LICENSE).

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) or apk 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 — see Licensing above.
  • 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.stderr carries the engine's warnings and errors; add --verbose (or -o plus --log=FILE) for more detail.

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).


Maintainer documentation — how wheels are built, verified, and released — is in RELEASING.md.

Metadata

Release files for prince-pdf 17.0.0.dev2026063001

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for prince-pdf 17.0.0.dev2026063001
File
prince_pdf-17.0.0.dev2026063001-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
prince_pdf-17.0.0.dev2026063001-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
prince_pdf-17.0.0.dev2026063001-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
prince_pdf-17.0.0.dev2026063001-py3-none-manylinux_2_25_x86_64.whl Python 3 none Linux glibc 2.25+ x86-64 Details
prince_pdf-17.0.0.dev2026063001-py3-none-manylinux_2_25_aarch64.whl Python 3 none Linux glibc 2.25+ ARM64 Details
prince_pdf-17.0.0.dev2026063001-py3-none-macosx_10_13_universal2.whl Python 3 none macOS 10.13+ universal2 (ARM64, x86-64) Details

Total release size: 102.7 MB

Release files / prince_pdf-17.0.0.dev2026063001-py3-none-win_arm64.whl

Download URL prince_pdf-17.0.0.dev2026063001-py3-none-win_arm64.whl
Size 13.6 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
c0b960d032017af37510dfff692abd4864e66ac0997e5f445b2fabc9408a7288
BLAKE2b-256 checksum
How to use checksums
2e235f5cf8c03b9ae8af5d15c2ad9db4ccf4dc0f8dc35b4ca4b2bf6bb36726e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / prince_pdf-17.0.0.dev2026063001-py3-none-win_amd64.whl

Download URL prince_pdf-17.0.0.dev2026063001-py3-none-win_amd64.whl
Size 15.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
92e79048f73fe14f4716067aa46941817be64ec2ef7f7ad1bf92a58f200c06df
BLAKE2b-256 checksum
How to use checksums
a5ee1ff33cda298843b079b261464b09d1f65246774685f8e0fbea8ee1a1781a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / prince_pdf-17.0.0.dev2026063001-py3-none-musllinux_1_2_aarch64.whl

Download URL prince_pdf-17.0.0.dev2026063001-py3-none-musllinux_1_2_aarch64.whl
Size 15.5 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
baf56150f6d54c0e3f3a5c7984eee01f4ef19f49bda705d51494c4fa1028c663
BLAKE2b-256 checksum
How to use checksums
54c8021b862b44913878559a1aa702634c297134313041b4629500d12bac59c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / prince_pdf-17.0.0.dev2026063001-py3-none-manylinux_2_25_x86_64.whl

Download URL prince_pdf-17.0.0.dev2026063001-py3-none-manylinux_2_25_x86_64.whl
Size 15.9 MB
Tags Linux glibc 2.25+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b36dbb4c78c48ba271f90a257d3e20d318d27dd1d3dd0ab54c436b274cec3a56
BLAKE2b-256 checksum
How to use checksums
d7d836c0efe98c4f682a9328ebda305c9ebfc1cf9e2647931147df62110db6f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / prince_pdf-17.0.0.dev2026063001-py3-none-manylinux_2_25_aarch64.whl

Download URL prince_pdf-17.0.0.dev2026063001-py3-none-manylinux_2_25_aarch64.whl
Size 14.7 MB
Tags Linux glibc 2.25+ ARM64 Python 3
SHA-256 checksum
How to use checksums
74d550b3f0e406c8e4be9e8b6eb25b28eee0146e4afa396637d99e2febe7fdae
BLAKE2b-256 checksum
How to use checksums
3e83480a2427c7cf2f55a37a50bb367f4687e8f227366db1fb40ed5f44ad1184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Release files / prince_pdf-17.0.0.dev2026063001-py3-none-macosx_10_13_universal2.whl

Download URL prince_pdf-17.0.0.dev2026063001-py3-none-macosx_10_13_universal2.whl
Size 27.4 MB
Tags Python 3 macOS 10.13+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
dc8024a87616368291d0edb7c8ebb6f365e84256c3e85bd769632562db179afd
BLAKE2b-256 checksum
How to use checksums
f0f6329177f094242f55d7a728428c1c8c8ba2609b99eafce8b2c779791f5baf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

Security for prince-pdf 17.0.0.dev2026063001

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for prince_pdf-17.0.0.dev2026063001-py3-none-win_arm64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page