Skip to content

PoliPage\renderToFile

PoliPage
enderToFile(PoliPagePoliPage $client, PoliPageRenderInput $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\RenderInput required (no description)
$path string required (no description)

void

Code When
PROJECT_REQUIRED_FOR_DOCUMENT See [errors](../../../production/errors/) for the full description.
invalid_options See [errors](../../../production/errors/) for the full description.
MISSING_API_KEY See [errors](../../../production/errors/) for the full description.
INVALID_API_KEY See [errors](../../../production/errors/) for the full description.
ORGANIZATION_PURGED See [errors](../../../production/errors/) for the full description.
ORGANIZATION_PAYMENT_GRACE See [errors](../../../production/errors/) for the full description.
ORGANIZATION_CANCELLED See [errors](../../../production/errors/) for the full description.
ORGANIZATION_MIGRATING See [errors](../../../production/errors/) for the full description.
RATE_LIMIT_EXCEEDED See [errors](../../../production/errors/) for the full description.
VALIDATION_ERROR See [errors](../../../production/errors/) for the full description.
RENDER_BODY_TOO_LARGE See [errors](../../../production/errors/) for the full description.
PROJECT_NOT_FOUND See [errors](../../../production/errors/) for the full description.
PROJECT_NOT_IN_ENVIRONMENT See [errors](../../../production/errors/) for the full description.
TEMPLATE_NOT_FOUND See [errors](../../../production/errors/) for the full description.
TEMPLATE_ERROR See [errors](../../../production/errors/) for the full description.
TEMPLATE_UNSAFE See [errors](../../../production/errors/) for the full description.
EMPTY_DOCUMENT See [errors](../../../production/errors/) for the full description.
DOCUMENT_TOO_LARGE See [errors](../../../production/errors/) for the full description.
RENDER_TIMEOUT See [errors](../../../production/errors/) for the full description.
QUOTA_EXCEEDED See [errors](../../../production/errors/) for the full description.
OVERAGE_CAP_EXCEEDED See [errors](../../../production/errors/) for the full description.
PUBLISH_IN_PROGRESS See [errors](../../../production/errors/) for the full description.
STORAGE_ACCESS_DENIED See [errors](../../../production/errors/) for the full description.
INTERNAL_ERROR See [errors](../../../production/errors/) for the full description.
unknown_error 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_response See [errors](../../../production/errors/) for the full description.
DOWNLOAD_FAILED See [errors](../../../production/errors/) for the full description.
io_error See [errors](../../../production/errors/) for the full description.
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\RenderInput;
use function PoliPage\renderToFile;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
renderToFile(
$client,
new RenderInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
),
'./invoices/INV-001.pdf',
);
echo "wrote ./invoices/INV-001.pdf\n";