apyhub
FILE CONVERSION · FILE MANIPULATION

Convert and Format raw HTML to PDF API

What it does

HTML to PDF turns raw HTML into a PDF binary you can store, email, or attach to workflows. Send an HTML document in the required body.html field, and the response comes back as a PDF file.

Use the optional page settings to control how the document is rendered. You can switch between portrait and landscape with landscape, choose a paper format with page_size (A4, Letter, Legal, A3, or Tabloid), and tune the margins with margin_top, margin_left, margin_right, and margin_bottom. Set print_background when you need background colors and graphics preserved in the output.

This is a fit for invoice generation, report export, contract snapshots, and any workflow where HTML is already the source of truth. Build the page once in your app, send the rendered markup to HTML to PDF, and return a downloadable PDF without a manual print step.

Because the output is a binary PDF, it can slot directly into document pipelines, storage systems, or delivery jobs that expect a file rather than JSON.

POST
PDF from HTML
http://localhost:8080/chisleroff/pdf-from-html
QUICKSTARTGUIDE

Quickstart

Convert a small HTML snippet into a PDF file.

curl -X POST "http://localhost:8080/chisleroff/pdf-from-html" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"html":"<html><body><h1>Hello, world!</h1></body></html>"}'

What you'll get back

Returns a binary file download containing the 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*
Raw HTML content to convert to PDF (max 5,000,000 characters).
Page orientation: true for landscape, false for portrait.
Page size: A4, Letter, Legal, A3, Tabloid.
Top margin with CSS units.
Left margin with CSS units.
Right margin with CSS units.
Bottom margin with CSS units.
Print background graphics.

About this endpoint

What it does

Converts raw HTML into a PDF document. You send HTML plus optional page and margin settings, and the endpoint returns the generated PDF as a binary response.

Request Body

ParameterTypeMandatoryDescription
htmlStringYesRaw HTML content to convert to PDF. Max 5,000,000 characters.
landscapeBooleanNoPage orientation: true for landscape, false for portrait. Default: false.
page_sizeStringNoPage size. Allowed values: A4, Letter, Legal, A3, Tabloid. Default: A4.
margin_topStringNoTop margin with CSS units. Default: 10mm.
margin_leftStringNoLeft margin with CSS units. Default: 10mm.
margin_rightStringNoRight margin with CSS units. Default: 10mm.
margin_bottomStringNoBottom margin with CSS units. Default: 10mm.
print_backgroundBooleanNoPrint background graphics. Default: true.

Response

Returns a binary file response containing the generated PDF.

Body

Name
Type
Description
bodyREQUIRED
object
▣ 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.