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

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.0.36
File Size Uploaded Provenance Actions
html2pdf4doc-0.0.36.tar.gz 63.3 kB Without provenance Details for html2pdf4doc-0.0.36.tar.gz

Built distribution (wheel)

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

Total release size: 128.7 kB

Release files / html2pdf4doc-0.0.36.tar.gz

Download URL html2pdf4doc-0.0.36.tar.gz
Size 63.3 kB
Tags Source
SHA-256 checksum
How to use checksums
89fdba4b24bc0859d358127f46172694ff58bc16288d30d0f1d8b491544e36d6
BLAKE2b-256 checksum
How to use checksums
6484c21555dccf53df2ab94a0d1ba59b2166cbf8dc8cd9e6093a3cd4f3f10958
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.0.36-py3-none-any.whl

Download URL html2pdf4doc-0.0.36-py3-none-any.whl
Size 65.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e272bc2ea82f977f4dffa7e857b42e624feceadd4c0de581e9219d92ec1e5be4
BLAKE2b-256 checksum
How to use checksums
806c6b921d6e659d44421ae1766855ace0c9d9416fc14c2afb71012f9ad0759b
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.0.36

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