renderToFile
renderToFile(client: PoliPage, input: ProjectModeInput, outputPath: string): Promise<void> Render a PDF and write it to disk. Streams response bytes directly to the file (memory-bounded). Creates parent directories. Overwrites existing files.
Node-only — uses node:fs/promises and node:fs. Import from @poli-page/sdk/node rather than the main entry.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
client | PoliPage | required | (no description) |
input | ProjectModeInput | required | (no description) |
outputPath | string | required | (no description) |
Returns
Section titled “Returns”Promise<void>
Errors
Section titled “Errors”| Code | When |
|---|---|
VALIDATION_ERROR | See [errors](../../../production/errors/) for the full description. |
NOT_FOUND | See [errors](../../../production/errors/) for the full description. |
QUOTA_EXCEEDED | See [errors](../../../production/errors/) for the full description. |
timeout | See [errors](../../../production/errors/) for the full description. |
network_error | See [errors](../../../production/errors/) for the full description. |
INTERNAL_ERROR | See [errors](../../../production/errors/) for the full description. |
Example
Section titled “Example”// Demonstrates: renderToFile(client, input, outputPath) from @poli-page/sdk/node.import { PoliPage } from '@poli-page/sdk';import { renderToFile } from '@poli-page/sdk/node';
const client = new PoliPage({ apiKey: process.env.POLI_PAGE_API_KEY! });
await renderToFile( 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.console.log('Wrote ./invoices/INV-001.pdf');