Skip to content

documents->preview

documents->preview(string $id): PoliPageDocumentPreviewResult

Retrieve a stored document’s paginated HTML preview. The deployed API responds with text/html directly and exposes the page count via the X-Document-Page-Count header — the SDK assembles the envelope from both.

Name Type Required Description
$id string required (no description)

\PoliPage\DocumentPreviewResult

Code When
DOCUMENT_NOT_FOUND See [errors](../../../production/errors/) for the full description.
INVALID_API_KEY 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;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
$documentId = $argv[1] ?? throw new RuntimeException('usage: documents-preview.php <documentId>');
$preview = $client->documents->preview($documentId);
echo "pageCount: {$preview->pageCount}\n";
file_put_contents('./preview.html', $preview->html);