Skip to content

render->pdfStream

render->pdfStream(PoliPageRenderInput $input): PsrHttpMessageStreamInterface

Like but returns the PSR-7 body stream directly so the caller can pipe it to disk or a response without buffering the whole PDF in memory. The caller owns the stream’s lifecycle — close it (or let __destruct close it) when done.

Name Type Required Description
$input \PoliPage\RenderInput required (no description)

\Psr\Http\Message\StreamInterface

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.
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\RenderInput;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
$stream = $client->render->pdfStream(new RenderInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
));
$out = fopen('./invoice.pdf', 'wb');
try {
while (!$stream->eof()) {
$chunk = $stream->read(8192);
if ($chunk === '') {
break;
}
fwrite($out, $chunk);
}
} finally {
fclose($out);
$stream->close();
}