High-fidelity HTML to PDF conversion using Chromium
Project description
printwell
High-fidelity HTML to PDF conversion using Chromium's rendering engine.
Installation
pip install printwell
Quick Start
from printwell import Converter, PdfOptions, PageSize
# Create a converter (reuse for multiple conversions)
converter = Converter()
# Simple conversion
result = converter.html_to_pdf("<h1>Hello, World!</h1>")
result.write_to_file("output.pdf")
# With options
result = converter.html_to_pdf(
"<h1>Hello</h1><p>World</p>",
pdf_options=PdfOptions(
page_size=PageSize.Letter,
print_background=True,
),
)
# Get PDF data as bytes
pdf_bytes = result.data()
print(f"Generated {result.page_count} pages, {len(pdf_bytes)} bytes")
Batch Processing
from printwell import ConverterPool
pool = ConverterPool(max_concurrent=4)
results = pool.convert_batch([
"<h1>Document 1</h1>",
"<h1>Document 2</h1>",
"<h1>Document 3</h1>",
])
for i, result in enumerate(results):
result.write_to_file(f"doc_{i}.pdf")
Features
- Rendering: Full HTML5/CSS3 support via Chromium's Blink engine
- Large Documents: Automatic chunking and parallel rendering for documents >50MB
- Watermarks: Text and image overlays with positioning and opacity control
- Bookmarks: Table of contents and navigation structure
- Annotations: Highlights, sticky notes, and geometric shapes
API Reference
Converter
Main converter class. Create once, reuse for multiple conversions.
html_to_pdf(html, render_options=None, pdf_options=None)- Convert HTML to PDFurl_to_pdf(url, render_options=None, pdf_options=None)- Convert URL to PDFinfo()- Get renderer information
PdfOptions
page_size- PageSize enum (A3, A4, A5, Letter, Legal, Tabloid)margins- Margins objectorientation- Orientation enum (Portrait, Landscape)print_background- Print background colors/imagesscale- Scale factor (0.1 to 2.0)metadata- PdfMetadata object
RenderOptions
base_url- Base URL for relative resourcesuser_stylesheets- Additional CSS stylesheetsviewport- Viewport configurationresources- ResourceOptions for network controlfonts- Font configuration optionsmax_chunk_size- Max HTML size before chunking (default 50MB, 0 to disable)
Other Packages
- Node.js: printwell on npm
- Rust: printwell on crates.io
- CLI: printwell-cli on crates.io
Links
License
AGPL-3.0
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 Distribution
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 printwell-0.1.11-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: printwell-0.1.11-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 23.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7fc8499e48c27e4ba1918af673992eac2b92fe35796ebf2e03471b8a344ac6a
|
|
| MD5 |
79e881fdf419d6a96b760b984f0a12d3
|
|
| BLAKE2b-256 |
0ff200404d3e2b75410da97274c1e667ed7c72fe72fed4eb3af92ee8accf3ee7
|
Provenance
The following attestation bundles were made for printwell-0.1.11-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
release-please.yml on printwell-dev/core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
printwell-0.1.11-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
b7fc8499e48c27e4ba1918af673992eac2b92fe35796ebf2e03471b8a344ac6a - Sigstore transparency entry: 857186890
- Sigstore integration time:
-
Permalink:
printwell-dev/core@fefcb69a2684defb5f74e49a25870587e20142d5 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/printwell-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@fefcb69a2684defb5f74e49a25870587e20142d5 -
Trigger Event:
push
-
Statement type: