pdfpipe-python
Official Python SDK for PDFPipe. Turn HTML or a URL into a PDF with one call, backed by a real browser engine.
pip install pdfpipe-python
Quick start
from pdfpipe import PDFPipe
pdfpipe = PDFPipe(api_key="pp_live_...")
# From HTML
pdf = pdfpipe.from_html("<h1>Invoice #4012</h1>", {"format": "A4"})
with open("invoice.pdf", "wb") as f:
f.write(pdf)
# From a URL
pdf = pdfpipe.from_url("https://example.com")
with open("example.pdf", "wb") as f:
f.write(pdf)
Get an API key at pdfpipe.xyz. Keys look like pp_live_....
API
PDFPipe(api_key, base_url="https://api.pdfpipe.xyz", session=None)
from_html(html, options=None) -> bytes
from_url(url, options=None) -> bytes
Both return the raw PDF bytes. options is a dict, all keys optional:
| Key | Values | Default |
|---|---|---|
format |
A4, A3, A5, Letter, Legal, Tabloid | A4 |
landscape |
bool | False |
margin |
any CSS length | 1cm |
print_background |
bool | True |
scale |
0.1 to 2.0 | 1.0 |
page_ranges |
e.g. "1-3, 5" | all pages |
prefer_css_page_size |
bool | False |
media |
print, screen | |
timeout_ms |
1000 to 60000 | 30000 |
wait_until |
load, domcontentloaded, networkidle0, networkidle2 | networkidle0 |
wait_for |
CSS selector | none |
wait_ms |
up to 5000 | 0 |
header_html |
HTML string | none |
footer_html |
HTML string | none |
tabular_nums |
bool | False |
deduplicate_images |
bool | False |
pdf_a |
bool | False |
Running headers and footers
header_html and footer_html render on every page. Five class names are
substituted per page as the document is laid out:
| Class | Becomes |
|---|---|
.pageNumber |
the current page number |
.totalPages |
the total page count |
.date |
the render date |
.title |
the document title |
.url |
the source URL, when rendering from a URL |
pdf = pdfpipe.from_html(
html,
{
"header_html": '<div style="font-size:9px;width:100%;text-align:center">Q3 Report</div>',
"footer_html": '<div style="font-size:9px;width:100%;text-align:center">'
'Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>',
},
)
Inline your styles. The header and footer are laid out separately from the page body, so a stylesheet in your HTML does not reach them, and they inherit a very small default font size.
If you leave margin at its 1cm default, the top or bottom margin widens to
2cm automatically so the header or footer has room. Set margin yourself if
you want different spacing.
The other three
tabular_nums forces font-variant-numeric: tabular-nums, so digits share one
width. Use it whenever a column of numbers has to line up, which is most
invoices and statements.
deduplicate_images merges identical image XObjects after rendering. It only
pays off when the same image repeats across pages, a logo in a running header
being the usual case, and it costs a little post-processing time.
pdf_a writes PDF/A-1b XMP metadata on a best-effort basis. It marks the file
for archival tooling but does not guarantee full conformance, which would also
require tagged structure and an embedded ICC profile.
Errors
Non-2xx responses raise PDFPipeError with a .status attribute and a clear message.
from pdfpipe import PDFPipe, PDFPipeError
try:
pdf = pdfpipe.from_url("https://example.com", {"timeout_ms": 45000})
except PDFPipeError as e:
print(e.status, str(e))
License
MIT
Metadata
Release files for pdfpipe-python 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pdfpipe_python-0.2.2.tar.gz | 3.9 kB | Without provenance | Details for pdfpipe_python-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pdfpipe_python-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for pdfpipe_python-0.2.2-py3-none-any.whl |
Total release size: 8.8 kB
Release files / pdfpipe_python-0.2.2.tar.gz
| Download URL | pdfpipe_python-0.2.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1330634d5a372a8842510a742d5d20a728ec227e6b5ba283f9a9c2ab46962abf
|
|
BLAKE2b-256 checksum How to use checksums |
0fda179ac4cc0e6b6542c73a461252bc40bc915bebe42bbcfedf9b7e9e4cf05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.1
|
Release files / pdfpipe_python-0.2.2-py3-none-any.whl
| Download URL | pdfpipe_python-0.2.2-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
922db65fe305a90139dd08d5326a539deb05cf2a09f29fdd1412c8860f0ab37a
|
|
BLAKE2b-256 checksum How to use checksums |
c25baf2e9ddc0db2ef12cd8d6c21861e06984180baa462c1c346935913b17cd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.1
|
Security for pdfpipe-python 0.2.2
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.