Skip to content

documents.preview

documents.preview(id: string): Promise<DocumentPreviewResult>

Retrieve a stored document’s paginated HTML. No counter — the engine performs no work. Spec §6.2. GET /v1/documents/:id/preview.

Name Type Required Description
id string required (no description)

Promise<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.
// Demonstrates: client.documents.preview(id) — get a stored document's HTML preview.
import { PoliPage } from '@poli-page/sdk';
const client = new PoliPage({ apiKey: process.env.POLI_PAGE_API_KEY! });
const preview = await client.documents.preview('doc_abc123');
// `preview.html` is the server-rendered HTML with the stored document's data
// applied to its template — useful for in-browser previews without a PDF.
console.log(`Preview: ${preview.pageCount} pages, HTML length ${preview.html.length}`);