apyhub
Back
▣ DOCUMENT INTELLIGENCE KIT · OUTPUT KIT

Convert HTML File to PDF API

What it does

HTML to PDF converts HTML into a PDF binary you can store, email, or hand off to another workflow. Send either an html string or a file containing the HTML document, and get a PDF file back.

Use paper to choose the page size, landscape for orientation, and print_background when you need backgrounds and images preserved in the output. If you are generating archival documents, set pdfa to one of PDF/A-1b, PDF/A-2b, or PDF/A-3b.

For rendered pages that depend on JavaScript, wait_delay gives the page time to finish loading before conversion. You can also attach up to 20 referenced assets such as images or stylesheets, and set header_html or footer_html for repeated content on every page. Margins are configurable on all sides, including margin_top, margin_bottom, margin_left, and margin_right.

Use HTML to PDF when you need invoices, reports, receipts, or printable previews from application content without building a separate document pipeline.

POST
HTML to PDF
https://api.eu.apyhub.com/frolic/convert-html-file-to-pdf/html-to-pdf

QUICKSTART

GUIDE

Quickstart

Convert an HTML file or HTML string into a PDF by sending the required multipart form field.

curl -X POST "https://api.eu.apyhub.com/frolic/convert-html-file-to-pdf/html-to-pdf" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/document.html"

What you'll get back

Returns a binary file (string with format: binary) — the generated PDF content.

TRY ITLIVE · 25 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body
The HTML document as a file, instead of html
The HTML document
Archival format: PDF/A-1b, PDF/A-2b or PDF/A-3b

About this endpoint

What it does

Converts an HTML document into a PDF file and returns the generated PDF as binary data. You can provide the HTML either inline as text or as an uploaded file, and optionally include referenced asset files and PDF layout options.

Request Body

ParameterTypeMandatoryDescription
fileStringNoThe HTML document as a file, instead of html.
htmlStringNoThe HTML document. Example: <h1>Hello, world!</h1>.
pdfaENUMNoArchival format. Allowed values: PDF/A-1b, PDF/A-2b, PDF/A-3b.
paperENUMNoPage size. Allowed values: A3, A4 (default), A5, A6, Letter, Legal, Tabloid.
assetsString ArrayNoUp to 20 files the HTML references by name, e.g. logo.png or style.css.
landscapeBooleanNoLandscape pages. Default: false.
margin_topNumberNoTop margin in inches. Range: 0-4. Default: 0.39.
wait_delayIntegerNoSeconds to wait after the page loads, for JavaScript-heavy pages. Range: 0-10.
footer_htmlStringNoHTML repeated at the bottom of every page; same placeholders as header_html.
header_htmlStringNoHTML repeated at the top of every page. <span class="pageNumber"></span> and <span class="totalPages"></span> are filled in.
margin_leftNumberNoLeft margin in inches. Range: 0-4. Default: 0.39.
margin_rightNumberNoRight margin in inches. Range: 0-4. Default: 0.39.
margin_bottomNumberNoBottom margin in inches. Range: 0-4. Default: 0.39.
print_backgroundBooleanNoPrint background colours and images. Default: true.

Response

Returns a binary PDF file as the success response body.

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.