Create
HTML to PDF
Render raw HTML markup, an uploaded HTML file, or a live web page URL to a PDF with headless Chromium — browser-grade fidelity, with control over paper size, margins, headers and footers.
Login required 40 credits / callSynchronous
Overview
Provide the source as exactly one of file, html or url; receive a public R2 URL for the rendered PDF.
POST
https://api.bytefuse.in/api/v1/html/to-pdfThis tool requires authentication
HTML→PDF is not on the free-try path — an anonymous call returns401. Send a dt_live_ key or JWT.Request
Content type multipart/form-data. Give the source via one of the first three fields — precedence is file > html > url:
filefileoptionalAn
.html file to render. Highest-precedence source.htmlstringoptionalRaw HTML markup. Used if no
file.urlstringoptionalA web page URL. Used only if neither
file nor html. http/https only — private, loopback and reserved IPs are rejected (SSRF guard). At least one of the three is required, else 422.Layout options
All optional form fields:
page_formatstringoptionalPaper size —
A4, Letter, Legal, A3, etc. Ignored when one_long_page is true.Default: A4landscapebooleanoptionalLandscape orientation.Default:
falsemarginstringoptionalA preset name (not a size):
none, small, default, or large. Applied to all four sides.Default: defaultprint_backgroundbooleanoptionalPrint CSS backgrounds and colors.Default:
truescreen_widthintoptionalRender viewport width in px, to emulate a screen size.
one_long_pagebooleanoptionalProduce one continuous page sized to the content (no pagination).Default:
falseblock_adsbooleanoptionalBest-effort ad blocking during render.Default:
falseremove_popupsbooleanoptionalBest-effort cookie/consent popup removal.Default:
falsepage_numbersbooleanoptionalPrint “Page X of Y” in the footer. Overridden by
footer_html.Default: falseheader_htmlstringoptionalHTML for a running header. May use Chromium’s
.pageNumber, .totalPages, .date, .title, .url spans.footer_htmlstringoptionalHTML for a running footer. Overrides
page_numbers if both are set.Response
200 OK, application/json:
200 OK
{
"success": true,
"url": "https://<r2-host>/html_to_pdf/20260704/<uuid>.pdf",
"meta": {
"source": "url",
"page_format": "A4",
"landscape": false,
"output_bytes": 48213,
"repaginated_from_css_canvas": false,
"processing_time_ms": 1820
},
"credits_charged": 3
}url is a public R2 link (permanent under the default config; no expires_at). X-Credits-Charged mirrors credits_charged.
Free preview screenshot
A sibling endpointPOST /api/v1/html/preview renders a URL or HTML to a PNG screenshot (returned as a base64 data URI). It’s authenticated but not metered — handy for a live preview before committing to the PDF render.Examples
# render a live URL
curl -X POST https://api.bytefuse.in/api/v1/html/to-pdf \
-H "X-API-Key: dt_live_your_key" \
-F "url=https://example.com" \
-F "page_format=A4" \
-F "margin=default" \
-F "page_numbers=true"
# render pasted raw HTML
curl -X POST https://api.bytefuse.in/api/v1/html/to-pdf \
-H "X-API-Key: dt_live_your_key" \
-F 'html=<h1>Invoice #42</h1><p>Thank you.</p>' \
-F "margin=small"Errors
401Anonymous / not signed in — HTML→PDF is login-only.
422None of
file/html/url was provided, a bad/unsafe url, or an invalid render option.402 / 429 / 503Insufficient credits, rate limited, or capacity/config error.
500The render failed (e.g. the browser couldn’t launch).
