Skip to main content

html2pdf4doc_python

html2pdf4doc_python is the Python wrapper/CLI for the html2pdf4doc JavaScript library that prints HTML pages into PDFs using Chrome/Chromedriver.

This repository focuses strictly on the Python-side automation layer. The rendering logic remains in the JS core.

Installation

  1. Install Google Chrome (or Chrome for Testing) on the machine that will run the CLI.

  2. Install the package from PyPI:

pip install html2pdf4doc

Python 3.8+ is required.

See also: the Ubuntu-based container Dockerfile and the GitHub CI files found in the .github/workflows folder.

Usage

Download or reuse ChromeDriver with SSL verification enabled by default:

python -m html2pdf4doc.main get_driver
python -m html2pdf4doc.main print input.html output.pdf

Disable SSL (corporate environments)

Disable SSL certificate verification only when needed, for example in a restricted corporate environment with custom TLS interception:

python -m html2pdf4doc.main get_driver --disable-ssl-check
python -m html2pdf4doc.main print --disable-ssl-check input.html output.pdf

Pin a specific Chrome binary

Pin a specific Chrome/Chromium binary with --chrome-binary, for example to use Chrome for Testing or a binary in a non-standard location. Without this flag, html2pdf4doc auto-detects the Chrome/Chromium binary on the machine.

python -m html2pdf4doc.main get_driver --chrome-binary /path/to/chrome
python -m html2pdf4doc.main print --chrome-binary /path/to/chrome input.html output.pdf

Set the HTML2PDF4DOC_CHROME_BINARY environment variable instead of the flag, for example in CI or Docker environments:

export HTML2PDF4DOC_CHROME_BINARY=/path/to/chrome
python -m html2pdf4doc.main print input.html output.pdf

html2pdf4doc resolves the Chrome binary in this order:

  • --chrome-binary
  • HTML2PDF4DOC_CHROME_BINARY
  • auto-detection.

Developer guide

Getting started

1. (Optional) Create and activate a virtual environment

python -m venv .venv && source .venv/bin/activate

2. Install the dependencies

git clone https://github.com/strictdoc-project/html2pdf4doc_python.git
cd html2pdf4doc_python

# Bootstrap minimal Python dependencies: Invoke and TOML.
pip install invoke toml

# Install all Python dependencies and update the submodule with the html2pdf4doc.js.
invoke bootstrap

3. The JS library is maintained in a Git submodule submodules/html2pdf.

When the submodule is updated after a release or during the development, rebuild the JS library, i.e., regenerate the html2pdf4doc.min.js:

invoke build

4. To validate changes, use the following commands:

invoke lint
invoke test  # Normal tests.
invoke test-fuzz  # More robust testing.

License

The project is distributed under the Apache License 2.0 (see LICENSE).

Metadata

Release files for html2pdf4doc 0.1.0

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

Source distribution (sdist)

Source distribution for html2pdf4doc 0.1.0
File Size Uploaded Provenance Actions
html2pdf4doc-0.1.0.tar.gz 63.7 kB Without provenance Details for html2pdf4doc-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for html2pdf4doc 0.1.0
File Interpreter ABI Platform Actions
html2pdf4doc-0.1.0-py3-none-any.whl Python 3 none any Details for html2pdf4doc-0.1.0-py3-none-any.whl

Total release size: 129.5 kB

Release files / html2pdf4doc-0.1.0.tar.gz

Download URL html2pdf4doc-0.1.0.tar.gz
Size 63.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4b9f4bf8c4735bf3620944e3aaaebd474441c2437130852a5ed7cb62dc6159a3
BLAKE2b-256 checksum
How to use checksums
f7fff7e2ed52560549835c941d6783d04c9473ef46b30d7716c52458bcbb0c18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / html2pdf4doc-0.1.0-py3-none-any.whl

Download URL html2pdf4doc-0.1.0-py3-none-any.whl
Size 65.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee5bc3f8baa09c13bfd993c2cd46a7bf42b1d14de99d928e002b8bfb1a4f869a
BLAKE2b-256 checksum
How to use checksums
93e2e7186d195a55313ad6725c4fac8def35ca3d7840e403209f4cac1448d28d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for html2pdf4doc 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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