Skip to content

PoliPage\renderToFile

PoliPage
enderToFile(PoliPagePoliPage $client, PoliPageProjectModeInput $input, string $path): void

Render a PDF and stream the bytes to $path. Creates parent directories if missing. Overwrites existing files. Memory-bounded — reads from the PSR-7 body stream in 8 KB chunks regardless of document size.

Name Type Required Description
$client \PoliPage\PoliPage required (no description)
$input \PoliPage\ProjectModeInput required (no description)
$path string required (no description)

void

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.
invalid_options See [errors](../../../production/errors/) for the full description.
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\ProjectModeInput;
use function PoliPage\renderToFile;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
renderToFile(
$client,
new ProjectModeInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
),
'./invoices/INV-001.pdf',
);
echo "wrote ./invoices/INV-001.pdf\n";