Create PDF from HTML
Send a POST request to this endpoint to render your HTML into a PDF document.
ℹ️
You will need to authenticate to use this API. See authentication.
ℹ️
This endpoint consumes 1 credit per PDF, up to 20 pages. A PDF longer than 20 pages is refused and costs nothing.
Request
POST https://api.ojo.so/v1/pdf/htmlHeaders
| Header | Value | Description |
|---|---|---|
| Content-Type | text/html | Specify that the request body contains HTML |
Request Body
The request body should contain the HTML you want to render as a PDF.
Page size and margins
Pages are A4 by default. Set the size and margins with a CSS @page rule in your HTML:
@page {
size: letter; /* or A4, A5, legal, landscape, 210mm 297mm */
margin: 20mm;
}Content that does not fit on one page flows onto the next. Use break-before: page to start a
new page. Backgrounds and colours are printed.
cURL
curl --request POST \
--url https://api.ojo.so/v1/pdf/html \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: text/html' \
--data '<html><body><h1>Invoice #1024</h1><p>Total: $120.00</p></body></html>'Response
200
Everything went as planned and your PDF is generated.
{
"id": "pdf-id.pdf",
"pdfUrl": "<content domain>/path/to/document.pdf",
"pages": 2,
"createdAt": "2026-09-28T12:34:56Z"
}pdfUrl has no scheme. Prefix it with https:// to fetch the file.