Skip to content

client.render.pdf

client.render.pdf(project:, template:, data:, version: nil, format: nil, orientation: nil, locale: nil, metadata: nil, idempotency_key: nil)

Two-hop: render the document, then fetch the presigned PDF URL and return the raw bytes (binary-encoded String). The presigned fetch is unauthenticated and NOT subject to the retry policy.

String — raw PDF bytes

Code When
PoliPage::ValidationError See [errors](../../../production/errors/) for the full description.
PoliPage::NotFoundError See [errors](../../../production/errors/) for the full description.
PoliPage::RateLimitError See [errors](../../../production/errors/) for the full description.
PoliPage::TimeoutError See [errors](../../../production/errors/) for the full description.
PoliPage::ConnectionError See [errors](../../../production/errors/) for the full description.
PoliPage::DownloadError See [errors](../../../production/errors/) for the full description.
PoliPage::InternalError See [errors](../../../production/errors/) for the full description.
PoliPage::APIError See [errors](../../../production/errors/) for the full description.
# frozen_string_literal: true
# Demonstrates: client.render.pdf — fetch the rendered PDF bytes in memory.
require "poli_page"
client = PoliPage::Client.new(api_key: ENV.fetch("POLI_PAGE_API_KEY"))
pdf = client.render.pdf(
project: "billing",
template: "invoice",
data: { invoice_number: "INV-001", total: 1280 }
)
# `pdf` is a binary-encoded String of PDF bytes.
File.binwrite("invoice.pdf", pdf)
puts "wrote #{pdf.bytesize} bytes"