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
-
Install Google Chrome (or Chrome for Testing) on the machine that will run the CLI.
-
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-binaryHTML2PDF4DOC_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.35
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| html2pdf4doc-0.0.35.tar.gz | 62.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| html2pdf4doc-0.0.35-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 127.2 kB
Release files / html2pdf4doc-0.0.35.tar.gz
| Download URL | html2pdf4doc-0.0.35.tar.gz |
|---|---|
| Size | 62.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
747cbc228295049405288801416b46558a7bed50664b12d9fd1635221864c56c
|
|
BLAKE2b-256 checksum How to use checksums |
be541faec6ac85242e2e71ef7347c306a9d6f6d39b222d73dc783d181766e523
|
| 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.35-py3-none-any.whl
| Download URL | html2pdf4doc-0.0.35-py3-none-any.whl |
|---|---|
| Size | 64.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b35b58da83b300bc6ab1eb556ef5ec703e27bc79ec2c1ffeebccbd56683544b
|
|
BLAKE2b-256 checksum How to use checksums |
30f16b1a7fab03a880211e58df1bdc90c388f14920227c38bc263525d6391555
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|