apyhub
Back
▣ FILE CONVERSION

Convert HTML to PDF API

Hosted on ApyHub

What it does

The HTML to PDF API converts HTML into PDF documents. Send a remote HTML file url, a base64 string, or upload an .html file (up to 100MB), and get the result back as a PDF download or as a signed link in data.

Download endpoints return the PDF bytes for immediate use, and you can name the file with output on file uploads. Link endpoints return a shareable URL for storage or email. Set landscape=true on most endpoints for wide tables and dashboards.

Use it for PDF generation from the HTML templates you already have: invoices, receipts, reports, contracts, certificates and archived snapshots. Render the template in your app, call the HTML to PDF API, and attach or store the result. AI agents can call it through ApyHub MCP to produce documents inside a workflow.

Working with a raw HTML string or a live website instead? Use the HTML String to PDF API or the Webpage to PDF API.

Pairs well with the Convert Markdown to HTML API before conversion and the PDF Watermark API after it, to brand or mark documents as drafts.

▣ ENDPOINT 01 / 06
POST
Convert remote HTML file URL to PDF signed link
https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/url/link

QUICKSTART

GUIDE

Quickstart

Send the HTML page URL you want to convert to PDF.

curl -X POST "https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/url/link" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.html"}'

What you'll get back

Returns a JSON object with a data string field containing a URI for the generated PDF.

{
  "data": "https://example.com/generated.pdf"
}
TRY ITLIVE · 100 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.
body*

About this endpoint

What it does

Converts a remote HTML file at the given URL into a PDF and returns a signed PDF link. The request sends the source url in the body, and the response returns the generated PDF link in a data string.

Request Body

ParameterTypeDescription
urlStringRemote HTML file URL to convert to PDF. Must be a URI.

Response

Returns a JSON object with a data string field containing a URI to the generated PDF file. Success response: 200.

ParameterTypeDescription
dataStringURI of the generated signed PDF link.
▣ ENDPOINT 02 / 06
POST
Convert base64-encoded HTML file to PDF download
https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/base64/download

QUICKSTART

GUIDE

Quickstart

Convert base64-encoded HTML into a PDF download with a single JSON request.

curl -X POST "https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/base64/download" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"base64":"PGh0bWw+PGJvZHk+PGgxPkhlbGxvPC9oMT48L2JvZHk+PC9odG1sPg=="}'

What you'll get back

Returns a binary file response (string with format: binary), which is the generated PDF content.

(binary PDF data)
TRY ITLIVE · 100 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.
body*
Base64-encoded file bytes.

About this endpoint

What it does

Converts a base64-encoded HTML file into a PDF and returns the PDF as a download. The request body must include the base64 input, and you can optionally set landscape as a query parameter.

Query Parameter(s)

AttributeTypeDescription
landscapeBooleanDefault: false

Request Body

ParameterTypeDescription
base64StringBase64-encoded file bytes.

Response

Returns a binary file response containing the generated PDF for download. The output schema is a binary string, so the success response body is the PDF content itself.

ParameterTypeDescription
fileStringBinary PDF content returned as the response body.
▣ ENDPOINT 03 / 06
POST
Convert base64-encoded HTML file to PDF signed link
https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/base64/link

QUICKSTART

GUIDE

Quickstart

Convert a base64-encoded HTML file into a PDF link by sending the encoded bytes in the request body.

curl -X POST "https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/base64/link" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"base64":"PGh0bWw+PGJvZHk+SGVsbG8sIHBkZjwvYm9keT48L2h0bWw+"}'

What you'll get back

Returns a JSON object with a data string field containing the generated file URI.

{
  "data": "https://example.com/generated-file.pdf"
}
TRY ITLIVE · 100 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.
body*
Base64-encoded file bytes.

About this endpoint

What it does

Converts a base64-encoded HTML file into a PDF and returns a signed link to the generated PDF. The request body must include the base64 file contents, and the response returns the resulting PDF URL in a JSON object.

Request Body

ParameterTypeDescription
base64StringBase64-encoded file bytes.

Response

Returns a JSON object with a data string field formatted as a URI — this is the signed link to the generated PDF.

ParameterTypeDescription
dataStringSigned PDF link as a URI.
▣ ENDPOINT 04 / 06
POST
Convert HTML file upload to PDF download
https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/file/download

QUICKSTART

GUIDE

Quickstart

Upload an HTML file to download the converted PDF.

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

What you'll get back

Returns a binary file stream, which is the generated PDF document.

TRY ITLIVE · 100 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*
.html

About this endpoint

What it does

Uploads an HTML file and returns the generated PDF as a binary download.

Query Parameter(s)

AttributeTypeDescription
outputStringOutput filename for the generated PDF. Example: output.pdf.
landscapeBooleanWhen true, generates the PDF in landscape orientation. Default: false.

Request Body

ParameterTypeDescription
fileBinaryHTML file to convert. Binary upload; expected file type: .html.

Response

Returns a binary file containing the generated PDF.

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

▣ ENDPOINT 05 / 06
POST
Convert HTML file upload to PDF signed link
https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/file/link

QUICKSTART

GUIDE

Quickstart

Upload an HTML file and get back a PDF link; this example also sets the optional landscape query flag to false by omission.

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

What you'll get back

Returns a JSON object with a data string field containing a URI to the generated PDF.

{
  "data": "https://example.com/generated.pdf"
}
TRY ITLIVE · 100 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*

About this endpoint

What it does

Converts an uploaded HTML file into a PDF and returns a signed link to the generated PDF. The request sends the file in the body, and the response returns a JSON object containing the PDF URL.

Query Parameter(s)

AttributeTypeDescription
landscapeBooleanOptional page orientation flag. Default: false.

Request Body

ParameterTypeDescription
fileBinaryHTML file to convert. Binary upload.

Response

Returns a JSON object with a data string field containing a URI for the generated PDF signed link.

ParameterTypeDescription
dataStringURI of the generated PDF signed link.

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

▣ ENDPOINT 06 / 06
POST
Convert remote HTML file URL to PDF download
https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/url/download

QUICKSTART

GUIDE

Quickstart

Download a PDF from a webpage URL by sending the page link in the JSON body.

curl -X POST "https://api.eu.apyhub.com/apyhub/convert-html-to-pdf/url/download" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.html"}'

What you'll get back

Returns a binary PDF file response.

TRY ITLIVE · 100 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.
body*

About this endpoint

What it does

Converts a remote HTML file accessible by URL into a PDF download. The request accepts the source HTML URL in the body and can optionally set landscape orientation via a query parameter.

Query Parameter(s)

AttributeTypeDescription
landscapeBooleanWhen true, generates the PDF in landscape orientation. Default: false.

Request Body

ParameterTypeDescription
urlStringThe remote HTML file URL to convert. Must be a valid URI.

Response

Returns a binary PDF file as the response body. The output schema is a single string with binary format, so the success response is the downloadable PDF content rather than a JSON object.

ParameterTypeDescription
response bodyStringBinary PDF data.
▣ 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.