YepAPI
Dev Utilities

PDF Generation

Generate PDFs from HTML content or URLs.

POST/v1/tools/pdf/from-html
$0.01/call

Usage

const res = await fetch('https://api.yepapi.com/v1/tools/pdf/from-html', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    html: '<h1>Invoice #123</h1><p>Total: $99.00</p>',
  }),
});
const { data } = await res.json();
console.log(data.url); // CDN URL to the generated PDF
curl -X POST https://api.yepapi.com/v1/tools/pdf/from-html \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Invoice #123</h1><p>Total: $99.00</p>"}'

Request Body

ParameterTypeRequiredDescriptionDefault
htmlstringYesHTML content to convert
formatstringNoPage size: a4, letter, legal"a4"
landscapebooleanNoLandscape orientationfalse
marginobjectNoPage margins {top, right, bottom, left} in px{40, 40, 40, 40}

Response

{
  "ok": true,
  "data": {
    "url": "https://cdn.yepapi.com/pdf/def456.pdf",
    "pages": 1,
    "size": 45231,
    "expiresAt": "2025-04-30T00:00:00Z"
  }
}

Response Fields

FieldTypeDescription
okbooleanWhether the request succeeded
dataobjectResponse payload
data.urlstringCDN URL to the generated PDF file
data.pagesnumberTotal number of pages in the generated PDF
data.sizenumberFile size of the PDF in bytes
data.expiresAtstringISO 8601 timestamp when the CDN-hosted PDF expires
Info

Generated PDFs are hosted on our CDN for 30 days. Download them immediately if you need permanent storage.

On this page