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>"
const data = new FormData();
data.append('html', '<html><body><h1>Hello World!</h1></body></html>');
fetch('https://apdf.io/api/pdf/file/create', {
headers: {'Authorization': 'Bearer TOKEN'},
method: 'POST',
body: data
})
.then(response => response.json())
.then(json => console.log(json));
use GuzzleHttp\Client;
$client = new Client();
$response = $client->post(
'https://apdf.io/api/pdf/file/create', [
'headers' => [
'Authorization' => 'Bearer TOKEN'
],
'form_params' => [
'html' => '<html><body><h1>Hello World!</h1></body></html>'
]
]);
$body = $response->getBody();
echo json_encode($body->getContents());
require 'rest-client'
response = RestClient.post(
'https://apdf.io/api/pdf/file/create',
{
'html' => '<html><body><h1>Hello World!</h1></body></html>'
},
{
Authorization: "Bearer TOKEN"
}
)
puts response.body
import requests
response = requests.post(
'https://apdf.io/api/pdf/file/create',
headers = {
'Authorization': 'Bearer TOKEN'
},
data = {
'html': '<html><body><h1>Hello World!</h1></body></html>'
}
)
print(response.text)
import (
"fmt"
"github.com/go-resty/resty/v2"
)
func main() {
client := resty.New()
data := map[string]string{
"html": "<html><body><h1>Hello World!</h1></body></html>"
}
resp, _ := client.R().
SetFormData(data).
SetHeader("Authorization", "Bearer TOKEN").
Post("https://apdf.io/api/pdf/file/create")
fmt.Println(resp.String())
}
import okhttp3.*;
class Pdf {
public static void main(String[] args) throws Exception {
OkHttpClient client = new OkHttpClient();
FormBody formBody = new FormBody.Builder()
.add("html", "<html><body><h1>Hello World!</h1></body></html>")
.build();
Request request = new Request.Builder()
.url("https://apdf.io/api/pdf/file/create")
.addHeader("Authorization", "Bearer TOKEN")
.post(formBody)
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
Write HTML.
Get a document.
Your CSS, fonts and layout carry over into the PDF.
The options decide the paper, margins and what repeats.
<h1>Invoice 1042</h1> <p>Due in 14 days</p> <table class="items">…</table> <p class="total">1,530.00</p>
Page <span class="pageNumber"></span>
- 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.
One authenticated POST from any language. Copy-paste samples in cURL, Node.js, Python and more.
POST /api/pdf/file/create
Pick the action in any Zap and map files from earlier steps. No code and no servers to run.
Create PDF From HTML
Add the Apdf node to any workflow, on n8n Cloud or self-hosted, and chain it with your automation.
Create PDF from HTML
Let Claude, ChatGPT, Gemini or your own agent run it through the MCP server, on any paid plan.
create-pdf-file
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.
HTML to PDF, answered
Create PDF tutorials
Build an Automated Invoice Generator using HTML & Python
The tutorial explains how to build a Python invoice generator by using Jinja2 to merge data into standard HTML/CSS templates. Instead of manually coding complex PDF layouts, the script sends the rendered HTML to the Apdf API, which instantly converts it into a professional, downloadable PDF.
Dynamic Certificate Generation for Online Courses (LMS)
Learn how to dynamically generate professional PDF certificates for online course platforms using PHP. Design certificates with HTML/CSS, use landscape orientation, and automatically generate them when students complete courses.
How to Generate PDFs from Claude
Describe the document, get the PDF: Claude drafts the HTML layout and renders it through the Apdf MCP tools — invoices, reports and one-pagers straight from the conversation, with page format, margins and headers steered in plain English. Revisions are just more chat.
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.
API · Webhook · MCP