render_to_file
render_to_file(client: PoliPage, input: ProjectModeInput, path: str | os.PathLike[str]) -> None Render a PDF and write it to disk (sync).
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
client | PoliPage | required | A `PoliPage` instance. |
input | ProjectModeInput | required | Project-mode render input. |
path | str | os.PathLike[str] | required | Destination path. Parent directories are created automatically. |
Returns
Section titled “Returns”None — None. The PDF is streamed to disk at path.
Errors
Section titled “Errors”| Code | When |
|---|---|
PROJECT_REQUIRED_FOR_DOCUMENT | Inline-shaped input. Rejected locally before the HTTP call. |
VALIDATION_ERROR | The `data` mapping does not satisfy the template schema. |
NOT_FOUND | The `project/template` slug does not exist. |
QUOTA_EXCEEDED | Per-key rate limit or monthly quota reached. Retryable. |
DOWNLOAD_FAILED | The S3 second-hop streaming download failed. |
Example
Section titled “Example”# Demonstrates: render_to_file(client, input, path) from poli_page.fs.from poli_page import PoliPagefrom poli_page.fs import render_to_file
client = PoliPage()
render_to_file( client, { "project": "billing", "template": "invoice", "data": {"invoiceNumber": "INV-001", "total": 1280}, }, "./invoices/INV-001.pdf",)
# Streams response bytes directly to disk with bounded memory.# Parent directories are created automatically.print("Wrote ./invoices/INV-001.pdf")