Skip to content

Render input

Every render method (render.pdf, render.pdf_stream, render.document, and the render_to_file helper) takes the same keyword arguments, PoliPage::RenderInput in the types reference: a project: slug, a template: slug inside it, and a data: hash that fills the template’s placeholders.

pdf = client.render.pdf(
project: "billing",
template: "invoice",
data: { invoiceNumber: "INV-001", total: 1280 }
)

There is no version to pick: the API renders the project’s copy published in the API key’s environment (see Authentication). To render your own templates, publish the project to that environment first. A missing keyword, or an unknown one, raises ArgumentError before any request.

  • format: — one of PoliPage::PageFormat::FORMATS (e.g. "A4", "Letter"). The SDK sends what you give; the API answers any other value with 400 VALIDATION_ERROR.
  • orientation: — "portrait" or "landscape".
  • locale: — a BCP 47 tag (e.g. "en-US").
  • metadata: — your own primitive-valued audit data, sent as is and echoed unchanged on the DocumentDescriptor (with the API’s string keys: doc.metadata["customerId"]).
  • idempotency_key: — overrides the auto-generated Idempotency-Key header.

Unset optional keywords are left out of the request, so the API’s defaults apply.

The SDK renames only its own keywords for the wire. The keys inside data: and metadata: are yours and are sent exactly as you write them: data: { invoiceNumber: "INV-001" } reaches the template as invoiceNumber, data: { invoice_number: "INV-001" } as invoice_number.

The API renders published templates only. To preview a template or render inline HTML while you design it, use the playground at play.poli.page. client.documents.preview(id) returns the stored HTML of a document you already rendered.

require "poli_page"
client = PoliPage::Client.new(api_key: ENV.fetch("POLI_PAGE_API_KEY"))
invoice_pdf = client.render.pdf(
project: "billing",
template: "invoice",
data: { invoiceNumber: "INV-001", total: 1280 },
format: "A4",
orientation: "portrait",
metadata: { customerId: "cust_123" }
)