Official Python SDK for the PDFik PDF generation API
Project description
pdfik
Official Python SDK for PDFik — the premium, fast, and reliable PDF generation API.
Convert HTML markup or any public URL into pixel-perfect PDF documents in seconds, powered by scalable browser rendering.
Features
- Type Safety: Type hints for all options and response objects.
- Sync & Async: Exposes both
PdfikClientandAsyncPdfikClientusing the modernhttpxengine. - Auto Retry: Automatic exponential backoff for
5xxand429(Rate Limit) errors powered bytenacity. - DX Affordances: Built-in polling logic (
wait_for_job) and file download helpers.
Installation
pip install pdfik
Quick Start
Convert public URL to PDF (Sync)
from pdfik import PdfikClient, PdfOptions, MarginOptions
# Initialize the client
client = PdfikClient(api_key="sk_live_...")
# 1. Submit the URL to be rendered
job = client.url_to_pdf(
"https://example.com",
options=PdfOptions(
format="A4",
landscape=False,
print_background=True,
margin=MarginOptions(top="10mm", bottom="10mm")
)
)
print(f"Job created: {job.job_id}. Waiting for rendering...")
# 2. Poll until the job completes
result = client.wait_for_job(job.job_id)
print(f"Job finished! Pages: {result.pages_count}")
# 3. Download the PDF bytes
pdf_bytes = client.download_pdf(job.job_id)
with open("output.pdf", "wb") as f:
f.write(pdf_bytes)
print("PDF saved to output.pdf")
# Close connection pool
client.close()
Convert raw HTML to PDF (Async)
import asyncio
from pdfik import AsyncPdfikClient, PdfOptions
async def main():
async with AsyncPdfikClient(api_key="sk_live_...") as client:
job = await client.html_to_pdf(
"<h1>Hello World</h1><p>Sent from PDFik Python SDK</p>",
options=PdfOptions(format="Letter")
)
result = await client.wait_for_job(job.job_id)
print(f"Job finished! Status: {result.status}")
pdf_bytes = await client.download_pdf(job.job_id)
asyncio.run(main())
Get the direct download URL
Get the direct API download URL for the generated PDF (requires the "X-API-Key" header to download):
file_info = client.get_file_url(job.job_id)
print(f"Direct Download URL: {file_info.download_url}")
License
MIT License.
Project details
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 pdfik-0.1.1.tar.gz.
File metadata
- Download URL: pdfik-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
130a8ba8dbcfc746cfb6182dea64b487fd0876da98b687e6564e6662da805e91
|
|
| MD5 |
1df9648849f04b5bf12dd64615eeb8ba
|
|
| BLAKE2b-256 |
8e5122ddf09deb2a12ed816b737d87fb60afa03def964ed37b64113140687cb4
|
File details
Details for the file pdfik-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pdfik-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ace130155b285e001a5cdb9f7acaa348ddbd02c0d9c9e6972adcfaa5087940f0
|
|
| MD5 |
48141669999c757a179c771f96bfa181
|
|
| BLAKE2b-256 |
a99f5d9b1cab62a3ff77b0fff787961c338bbc85e77494d1aa9a34e49af4e2f4
|