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.
Required keywords
Section titled “Required keywords”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.
Optional keywords
Section titled “Optional keywords”format:— one ofPoliPage::PageFormat::FORMATS(e.g."A4","Letter"). The SDK sends what you give; the API answers any other value with400 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 theDocumentDescriptor(with the API’s string keys:doc.metadata["customerId"]).idempotency_key:— overrides the auto-generatedIdempotency-Keyheader.
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.
Previews and inline HTML
Section titled “Previews and inline HTML”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.
Example
Section titled “Example”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" })