Complete Python code examples for the PixDoc API
pip install requestsSend HTML to the /api/v1/pdf endpoint and save the binary response.
import requests
response = requests.post(
"https://pixdoc.dev/api/v1/pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"html": "<h1>Hello World</h1>"}
)
with open("output.pdf", "wb") as f:
f.write(response.content)The /api/v1/screenshot endpoint returns a PNG image.
import requests
response = requests.post(
"https://pixdoc.dev/api/v1/screenshot",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"html": "<h1>Hello World</h1>"}
)
with open("screenshot.png", "wb") as f:
f.write(response.content)Pass a template_id and variables instead of raw HTML.
import requests
response = requests.post(
"https://pixdoc.dev/api/v1/pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"template_id": "invoice",
"variables": {
"company": "Acme Corp",
"total": "$1,250.00"
}
}
)
with open("invoice.pdf", "wb") as f:
f.write(response.content)