Skip to content

render->document

render->document(PoliPageProjectModeInput $input): PoliPageDocumentDescriptor

Render a PDF, store it server-side, and return the descriptor with a fresh presigned URL. Same wire endpoint as — the difference is that pdf chains a second fetch for the bytes; document returns immediately so the caller can defer the download (or skip it entirely, e.g. when only the documentId is needed).

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

\PoliPage\DocumentDescriptor

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.
INTERNAL_ERROR See [errors](../../../production/errors/) for the full description.
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\ProjectModeInput;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
$doc = $client->render->document(new ProjectModeInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
));
echo "stored: {$doc->documentId}\n";
echo "presigned URL (15-minute TTL): {$doc->presignedPdfUrl}\n";
$pdf = $doc->downloadPdf();
file_put_contents('./invoice.pdf', $pdf);