Official PDFPipe SDK. Turn HTML or a URL into a PDF with one call.
Project description
pdfpipe-python
Official Python SDK for PDFPipe. Turn HTML or a URL into a PDF with one call, backed by real Chromium rendering.
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 10000 | 0 |
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
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 Distribution
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 pdfpipe_python-0.1.0.tar.gz.
File metadata
- Download URL: pdfpipe_python-0.1.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c2a0fcdd9ca3bfb1d56a6a8670740c4b8c319ec2180f6e148859f4ad086dcf2
|
|
| MD5 |
e808654c05ca02d101c2336822060485
|
|
| BLAKE2b-256 |
c1021fde58c7755ca21fab46ebf0f1bb51a8460f48a85ba83340de7e33ca86c1
|
File details
Details for the file pdfpipe_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pdfpipe_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c20e627549ab38a0b8b61cc61dd29bbe55bcf794c07508c6e8f8b6ee5efa5e9e
|
|
| MD5 |
33e342b613765afeef7aae97ed1b701b
|
|
| BLAKE2b-256 |
9ae0672806735bc0676dd275dd39a38bcb42a1a39f43676be56961ad209b56f2
|