Bytefusedocs

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.

POSThttps://api.bytefuse.in/api/v1/html/to-pdf

This tool requires authentication

HTML→PDF is not on the free-try path — an anonymous call returns 401. 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:

filefileoptional
An .html file to render. Highest-precedence source.
htmlstringoptional
Raw HTML markup. Used if no file.
urlstringoptional
A 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_formatstringoptional
Paper size — A4, Letter, Legal, A3, etc. Ignored when one_long_page is true.Default: A4
landscapebooleanoptional
Landscape orientation.Default: false
marginstringoptional
A preset name (not a size): none, small, default, or large. Applied to all four sides.Default: default
print_backgroundbooleanoptional
Print CSS backgrounds and colors.Default: true
screen_widthintoptional
Render viewport width in px, to emulate a screen size.
one_long_pagebooleanoptional
Produce one continuous page sized to the content (no pagination).Default: false
block_adsbooleanoptional
Best-effort ad blocking during render.Default: false
remove_popupsbooleanoptional
Best-effort cookie/consent popup removal.Default: false
page_numbersbooleanoptional
Print “Page X of Y” in the footer. Overridden by footer_html.Default: false
header_htmlstringoptional
HTML for a running header. May use Chromium’s .pageNumber, .totalPages, .date, .title, .url spans.
footer_htmlstringoptional
HTML 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 endpoint POST /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).