What it does
X-Convert-Type: html-to-pdfrenders the HTML you send insource;url-to-pdfloads a live page fromsource_url.- Rendering is Chromium, so web fonts, SVG, flexbox/grid,
@pagerules and repeated table headers print the way Chrome prints them. - The response is the PDF itself (
application/pdf), withX-Sigli-Processing-Mstelling you how long the render took. - 1 credit per successful render; failed renders are free.
URL to PDF with curl
API=${SIGLI_API_URL:-https://api.sigli.dev}
curl -sS "$API/v1/process" \
-H "X-API-Key: $SIGLI_API_KEY" \
-H "X-Convert-Type: url-to-pdf" \
-H "Content-Type: application/json" \
-d '{
"source_url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching",
"format": "A4",
"wait_for": "main",
"block_cookie_banners": true
}' \
-o mdn-caching.pdf
HTML to PDF in Python
Renders a local HTML report to A4 with a "Page x of y" footer, then prints a live page.
# Render an HTML file to PDF (A4, page-numbered footer), then a live URL.
# pip install requests
import os
import requests
API = os.environ.get("SIGLI_API_URL", "https://api.sigli.dev")
HEADERS = {"X-API-Key": os.environ["SIGLI_API_KEY"]}
# 1. Your own HTML. Chromium fills .pageNumber / .totalPages in the footer.
with open("board-report.html", encoding="utf-8") as f:
html = f.read()
resp = requests.post(
f"{API}/v1/process",
headers={**HEADERS, "X-Convert-Type": "html-to-pdf"},
json={
"source": html,
"format": "A4",
"margin": {"top": "20mm", "bottom": "20mm", "left": "15mm", "right": "15mm"},
"footer": {
"html": '<div style="font-size:8px;width:100%;text-align:center">'
'Page <span class="pageNumber"></span> of '
'<span class="totalPages"></span></div>',
"height": "12mm",
},
"title": "Board report Q2",
},
timeout=120,
)
resp.raise_for_status()
with open("board-report.pdf", "wb") as f:
f.write(resp.content)
print("board-report.pdf:", len(resp.content), "bytes in",
resp.headers.get("X-Sigli-Processing-Ms"), "ms")
# 2. A live page: wait for its main content and hide cookie banners.
resp = requests.post(
f"{API}/v1/process",
headers={**HEADERS, "X-Convert-Type": "url-to-pdf"},
json={
"source_url": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching",
"wait_for": "main",
"block_cookie_banners": True,
"format": "A4",
},
timeout=120,
)
resp.raise_for_status()
with open("mdn-caching.pdf", "wb") as f:
f.write(resp.content)
print("mdn-caching.pdf:", len(resp.content), "bytes")
Options
Send options as JSON fields next to source or source_url. The full list is in the API reference.
| Field | What it does |
|---|---|
format, orientation | A4 (default), A3, A5, Letter, Legal, Tabloid; portrait or landscape |
margin | One length or {"top","right","bottom","left"} in mm, cm, in, px or pt (default 1cm) |
header, footer | {"html", "height"}; .pageNumber / .totalPages / .date are filled per page |
wait_for, wait_delay | Wait for a CSS selector, or up to 30,000 ms, before printing |
css, javascript, base_url | Inject CSS or JS; resolve relative asset URLs in inline HTML |
print_background, scale | Background colours/images (default on); scale 0.1–2.0 |
block_cookie_banners, block_ads | Hide cookie banners and ads on live pages |
watermark, encryption | Text or image watermark; password-protect the output |
title, author, subject, keywords | PDF document metadata |
return_url | Return JSON with a signed download URL instead of the bytes |
Responses and limits
- Inline HTML is limited to 5 MB (
413 source_too_large); a render that runs out of time returns504 render_timeout.timeoutaccepts 1–60 seconds (default 30). - Add a
webhookURL (Pro plan) to have the render queued and your endpoint called when it finishes; download the file fromGET /v1/jobs/{job_id}/output. - Many documents at once:
POST /v1/batch/submittakes up to 500 items (Pro plan). Reusable layouts: templates. Invoices from JSON have their own GST invoice API. - Other formats from the same call: PNG, JPEG and WebP screenshots, PDF to Markdown and OCR.
FAQ
Which browser renders the PDF?
Headless Chromium, so CSS, web fonts, SVG, @page rules and repeated table headers come out as they do in Chrome's print preview.
How do I add page numbers?
Pass a footer (or header) with HTML containing <span class="pageNumber"></span> and <span class="totalPages"></span>; Chromium fills them in on every page.
What does it cost?
1 credit per successful HTML→PDF or URL→PDF render. Starter is $29/month for 3,000 credits, and new workspaces get a 14-day Starter trial.
Try it on your own files
New workspaces start with a 14-day Starter trial (3,000 credits). Create an API key on the API Keys page and run the examples above as they are.