Logo
POST /api/pdf/file/create

Create PDF From HTML API

Send your HTML and get a professional, print-ready PDF back, with your CSS, web fonts and scripts. Set the page size, margins, header and footer in the same call.

  • Free plan
  • No credit card

Request

curl -X POST https://apdf.io/api/pdf/file/create \
  -H "Authorization: Bearer TOKEN" \
  -d html="<html><body><h1>Hello World!</h1></body></html>"

Write HTML.
Get a document.

Your CSS, fonts and layout carry over into the PDF. The options decide the paper, margins and what repeats.

html
<h1>Invoice 1042</h1>
<p>Due in 14 days</p>
<table class="items">…</table>
<p class="total">1,530.00</p>
footer
Page <span class="pageNumber"></span>
format=a4 margin_bottom=20
Generate
invoice.pdf A4
Invoice 1042
Due in 14 days
Design1,200.00
Hosting90.00
Support240.00
1,530.00
Page 1
The page options
format
a4, letter, legal, a3 and more
width, height
A custom size, in mm, cm, in or px
orientation
portrait or landscape
margin_*
Top, right, bottom and left margins
header, footer
HTML repeated on every page

Documents from your data.

Your app already has the data and the templates. One call turns each record into a PDF your customers can keep.

Invoices and receipts

Render every invoice from the HTML template your app already uses for email, with line items, totals and your logo.

Reports and statements

Turn monthly statements and reports into PDFs, with charts drawn by your own JavaScript before the page is printed.

Certificates and tickets

Fill a fixed layout with a name, a date or a QR code and get one PDF per participant at exactly the size you set.

Quotes and contracts

Generate quotes and contracts from customer data, with your header and the page numbers repeated on every page.

Generate from anywhere.

Render the same template from your code or your automations. One account and one monthly allowance behind every route.

Your code

One authenticated POST from any language. Copy-paste samples in cURL, Node.js, Python and more.

POST /api/pdf/file/create
Open the endpoint docs
Zapier

Pick the action in any Zap and map files from earlier steps. No code and no servers to run.

Create PDF From HTML
Use it in Zapier
n8n

Add the Apdf node to any workflow, on n8n Cloud or self-hosted, and chain it with your automation.

Create PDF from HTML
Use it in n8n
AI agents

Let Claude, ChatGPT, Gemini or your own agent run it through the MCP server, on any paid plan.

create-pdf-file
See what agents can do

1,000 PDFs
a month. Free.

Start on the free plan and move up only when your volume does — up to 1,000,000 operations a month on Business.

  • One call is one operation, however many pages.
  • Only calls that do the work are counted.
  • Hard limits, so no surprise overage charges.
Plan PDF operations / month
Hobby Free
$0 / month
1,000
Pro
$39–$99 / month
20,000 – 60,000
Business
$149–$899 / month
100,000 – 1,000,000

HTML to PDF, answered

Yes. The PDF is created once the network is quiet, so linked stylesheets, web fonts and images load and your scripts run before the page is printed, with your print styles applied. Inline event handlers, iframes and references to private network addresses are rejected.
Letter is the default. Pass format=a4 or another paper size, or set width and height for a custom page. Sizes set with CSS @page are ignored.
Add elements with the classes pageNumber and totalPages to the footer or header, and leave room for them with margin_bottom or margin_top. Images in the header and footer can be linked by URL, they are embedded for you.
Every generated PDF goes through the same step as the Compress endpoint: color and grayscale images are resampled to 150 dpi when that makes the file smaller. Text and vector graphics stay sharp.
PDF generation always runs in the background. Check the job on the job status endpoint, or pass a webhook_url and the result is posted to you. It holds a download URL valid for 60 minutes, the page count and the file size.
After the API call

Your code made the PDF.
Then it went dark.

Opened, read, re-read, dropped on page 4 — you never see any of it. Share the PDFs you generate through Apdf recipient links, and every signal becomes something you can act on: ping Slack, update the CRM, let an agent follow up. Same account, same API token, one more call.

Your PDF, after sending Live
document:loaded CFO
page:read p4 · 38s
link:clicked pricing

API · Webhook · MCP

Your next PDF
starts as HTML.