PlatformXeDocs
Get API Key

PDF

SDK methods for generating PDF documents from templates.

The client.pdf namespace provides typed methods for generating PDF documents: from your own HTML or a stored template (generate), from the offer letter and property flyer layouts, and for rasterizing a PDF page to an image. Available in TypeScript, Python, and Go SDKs.

SDKInstallNamespace
TypeScriptnpm install @caldera/platformxe-sdkclient.pdf
Pythonpip install platformxeclient.pdf
Gogo get github.com/calderaxe/platformxe-goclient.Pdf

Generate a PDF from HTML or a template

Render your own HTML, or a stored template with data, to a PDF (POST /api/v1/pdf/generate). Send exactly one of html or templateId. By default the PDF is stored as a private file of your organisation and the answer carries fileId, a time-limited, read-only pdfUrl and its expiresAt (options.urlTtlSeconds, 60 to 604800, default 86400); with options.returnBase64: true it carries content (base64, at most 3 MiB of PDF) instead. The page runs no JavaScript and reaches no network; https: images are fetched by PlatformXe (options.remoteImages, default true). See Generate PDF for every option, limit and error code.

The SDKs wait up to 65 seconds for this call and never answer it with a fail-open placeholder. Pass an idempotency key so a retry returns the stored answer instead of rendering a second PDF; without one, a re-send would render, store and meter a second PDF. Without a key, the TypeScript and Go SDKs re-send only after a 429; the Python SDK does not re-send at all (a 429 is raised with its retry_after). With a key, the TypeScript and Go SDKs retry as for any call, and the Python SDK re-sends only when no answer came back (a network failure or its own timeout); a re-send that reaches the server while the first request is still running gets 409 CONFLICT: call again with the same key after about 30 seconds. A 408 RENDER_TIMEOUT and a base64 answer are never stored for idempotency: a retry renders (and meters) again.

const result = await client.pdf.generate(
  {
    html: '<h1>Invoice #1234</h1><p>Total: ₦106,425.00</p>',
    options: { size: 'A4', margins: { top: '20mm', bottom: '20mm' }, filename: 'invoice-1234.pdf' },
  },
  { idempotencyKey: 'invoice-1234-v1' },
);

if ('pdfUrl' in result) {
  console.log(result.fileId, result.pdfUrl, result.expiresAt, result.pages);
}

// From a stored template, returned inline
const receipt = await client.pdf.generate({
  templateId: 'tpl_abc',
  data: { customerName: 'Ada', total: '₦106,425.00' },
  options: { returnBase64: true },
});
const bytes = Buffer.from(receipt.content, 'base64');
result = client.pdf.generate(
    "<h1>Invoice #1234</h1><p>Total: ₦106,425.00</p>",
    options={"size": "A4", "filename": "invoice-1234.pdf"},
    idempotency_key="invoice-1234-v1",
)
print(result["fileId"], result["pdfUrl"], result["expiresAt"])

receipt = client.pdf.generate(
    template_id="tpl_abc",
    data={"customerName": "Ada", "total": "₦106,425.00"},
    options={"returnBase64": True},
)
result, err := client.Pdf.Generate(platformxe.GeneratePdfInput{
    HTML:    "<h1>Invoice #1234</h1><p>Total: ₦106,425.00</p>",
    Options: &platformxe.GeneratePdfOptions{Size: "A4", Filename: "invoice-1234.pdf"},
}, &platformxe.GeneratePdfCallOptions{IdempotencyKey: "invoice-1234-v1"})
if err != nil {
    log.Fatal(err)
}
fmt.Println(result.FileID, result.PdfURL, result.ExpiresAt)

receipt, err := client.Pdf.Generate(platformxe.GeneratePdfInput{
    TemplateID: "tpl_abc",
    Data:       map[string]interface{}{"customerName": "Ada", "total": "₦106,425.00"},
    Options:    &platformxe.GeneratePdfOptions{ReturnBase64: true},
})

Available from TypeScript SDK 1.18.0, Python 1.14.0 and Go v1.14.0 (pending release).

Requires the pdf:generate scope (not one of the scopes a self-registered or portal sign-up key starts with: a key holds it when its scope list names it or holds *, or when it has no scope list), and is limited to 100 requests/hr per API key. Errors: 400 VALIDATION_ERROR, 404 TEMPLATE_NOT_FOUND, 408 RENDER_TIMEOUT, 409 CONFLICT (idempotency key in flight), 413 PAYLOAD_TOO_LARGE / OUTPUT_TOO_LARGE, 503 STORAGE_UNAVAILABLE / RENDERER_UNAVAILABLE, 500 INTERNAL_ERROR, plus 401, 403 and 429 from authentication.

Generate offer letter

Render an offer letter PDF from structured data.

const result = await client.pdf.offerLetter({
  tenantName: 'Ada Okafor',
  propertyAddress: '15 Admiralty Way, Lekki Phase 1, Lagos',
  monthlyRent: 450000,
  currency: 'NGN',
  startDate: '2026-06-01',
  duration: 12,
  landlordName: 'Caldera Properties Ltd',
});

console.log(result.url);      // Signed download URL
console.log(result.fileSize);  // Size in bytes
result = client.pdf.offer_letter(
    tenant_name="Ada Okafor",
    property_address="15 Admiralty Way, Lekki Phase 1, Lagos",
    monthly_rent=450000,
    currency="NGN",
    start_date="2026-06-01",
    duration=12,
    landlord_name="Caldera Properties Ltd",
)
result, err := client.Pdf.OfferLetter(map[string]interface{}{
    "tenantName":      "Ada Okafor",
    "propertyAddress": "15 Admiralty Way, Lekki Phase 1, Lagos",
    "monthlyRent":     450000,
    "currency":        "NGN",
    "startDate":       "2026-06-01",
    "duration":        12,
    "landlordName":    "Caldera Properties Ltd",
})

Generate property flyer

Render a property flyer PDF for marketing or listing purposes.

const result = await client.pdf.propertyFlyer({
  title: 'Luxury 3-Bedroom Apartment',
  address: '15 Admiralty Way, Lekki Phase 1, Lagos',
  price: 4500000,
  currency: 'NGN',
  bedrooms: 3,
  bathrooms: 2,
  features: ['Swimming pool', 'Gym', '24hr power', 'Secure parking'],
  images: [
    'https://storage.example.com/property/exterior.jpg',
    'https://storage.example.com/property/living-room.jpg',
  ],
  agentName: 'Bimpe Adeyemi',
  agentPhone: '+2348012345678',
});

console.log(result.url);
result = client.pdf.property_flyer(
    title="Luxury 3-Bedroom Apartment",
    address="15 Admiralty Way, Lekki Phase 1, Lagos",
    price=4500000,
    currency="NGN",
    bedrooms=3,
    bathrooms=2,
    features=["Swimming pool", "Gym", "24hr power", "Secure parking"],
    images=[
        "https://storage.example.com/property/exterior.jpg",
        "https://storage.example.com/property/living-room.jpg",
    ],
    agent_name="Bimpe Adeyemi",
    agent_phone="+2348012345678",
)
result, err := client.Pdf.PropertyFlyer(map[string]interface{}{
    "title":      "Luxury 3-Bedroom Apartment",
    "address":    "15 Admiralty Way, Lekki Phase 1, Lagos",
    "price":      4500000,
    "currency":   "NGN",
    "bedrooms":   3,
    "bathrooms":  2,
    "features":   []string{"Swimming pool", "Gym", "24hr power", "Secure parking"},
    "images":     []string{
        "https://storage.example.com/property/exterior.jpg",
        "https://storage.example.com/property/living-room.jpg",
    },
    "agentName":  "Bimpe Adeyemi",
    "agentPhone": "+2348012345678",
})

Rasterize a PDF page

Convert one page of a base64-encoded PDF into a JPEG or PNG image — for example, to show a downloadable preview of an invoice PDF without shipping a PDF renderer in your own app.

const result = await client.pdf.rasterize({
  pdfBase64: '<base64-encoded PDF, about 3.3 MB at most>',
  format: 'jpeg',
  page: 1,     // optional, defaults to 1
  dpi: 150,    // optional, defaults to 150, clamped server-side to [1, 300]
});

console.log(result.imageBase64);  // base64-encoded JPEG/PNG
console.log(result.contentType);  // "image/jpeg" | "image/png"
console.log(result.width, result.height); // rendered pixel dimensions
console.log(result.pageCount);    // total pages in the source PDF
result = client.pdf.rasterize(
    pdf_base64="<base64-encoded PDF, about 3.3 MB at most>",
    format="jpeg",
    page=1,   # optional, defaults to 1
    dpi=150,  # optional, defaults to 150, clamped server-side to [1, 300]
)

print(result["imageBase64"])
print(result["contentType"])
print(result["width"], result["height"])
print(result["pageCount"])
result, err := client.Pdf.Rasterize(platformxe.RasterizePdfInput{
    PdfBase64: "<base64-encoded PDF, about 3.3 MB at most>",
    Format:    "jpeg",
    Page:      1,   // optional, zero value omits the field — server defaults to page 1
    DPI:       150, // optional, zero value omits the field — server defaults to 150, clamps to [1, 300]
})

fmt.Println(result.ImageBase64)
fmt.Println(result.ContentType)
fmt.Println(result.Width, result.Height)
fmt.Println(result.PageCount)

The source PDF is limited to 20 pages, and the request body to 4.5 MB, so the largest PDF one request can carry is about 3.3 MB (its base64 is 4/3 larger); the route's own 10 MB decoded cap is never reached; the rendered image is capped at 6000px per side. Requests are limited to 200/hr per API key (scope pdf:rasterize) — see Error responses for the full list of status codes, including 408 on a render timeout.

Processor configuration

Get processor config

const config = await client.pdf.getProcessor();
config = client.pdf.get_processor()
config, err := client.Pdf.GetProcessor()

Update processor config

Configure PDF rendering options such as page size, margins, and header/footer templates.

const updated = await client.pdf.updateProcessor({
  enabled: true,
  config: {
    defaultPageSize: 'A4',
    defaultMargins: { top: 20, right: 15, bottom: 20, left: 15 },
    headerTemplate: '<div style="font-size:10px;">Caldera Properties</div>',
  },
});
updated = client.pdf.update_processor(
    enabled=True,
    config={
        "defaultPageSize": "A4",
        "defaultMargins": {"top": 20, "right": 15, "bottom": 20, "left": 15},
    },
)
updated, err := client.Pdf.UpdateProcessor(map[string]interface{}{
    "enabled": true,
    "config": map[string]interface{}{
        "defaultPageSize": "A4",
        "defaultMargins":  map[string]interface{}{"top": 20, "right": 15, "bottom": 20, "left": 15},
    },
})

PDFs from pdf.generate() are stored as private files of your organisation until you delete them (DELETE /api/v1/storage/media/files/{fileId}, which needs storage:upload: a key that holds only pdf:generate cannot delete them); their links are time-limited and read-only, and expire after urlTtlSeconds (24 hours by default, at most 7 days). Offer letters and property flyers are returned inline as base64 and are not stored.

Scopes required

MethodScopeRate limit
pdf.offerLetter()templates:readDefault (1,000/hr)
pdf.propertyFlyer()templates:readDefault (1,000/hr)
pdf.rasterize()pdf:rasterize200/hr
pdf.generate()pdf:generate100/hr
pdf.getProcessor()pdf:manageDefault (1,000/hr)
pdf.updateProcessor()pdf:manageDefault (1,000/hr)