Skip to main content

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 print
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdfpipe_python-0.2.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file pdfpipe_python-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pdfpipe_python-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for pdfpipe_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa72385ac3cf64f37ff09ecd8b7907c8a150193f64915065c7b9a5e90b44e5e8
MD5 261e6bc0464d17a417e958ed782351ef
BLAKE2b-256 ce6e690e0273c059264f7002e2c4f8ae22d710453756ab530dac27ec20bb5e82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page