Skip to content

render.pdfStream

render.pdfStream(input: ProjectModeInput): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

Like render.pdf but returns a ReadableStream of the PDF bytes.

Name Type Required Description
input ProjectModeInput required (no description)

Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

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.
timeout See [errors](../../../production/errors/) for the full description.
network_error See [errors](../../../production/errors/) for the full description.
INTERNAL_ERROR See [errors](../../../production/errors/) for the full description.
// Demonstrates: client.render.pdfStream(input) — project mode only.
import { PoliPage } from '@poli-page/sdk';
const client = new PoliPage({ apiKey: process.env.POLI_PAGE_API_KEY! });
const stream = await client.render.pdfStream({
project: 'billing',
template: 'invoice',
data: { invoiceNumber: 'INV-001', total: 1280 },
});
// Pipe directly to an HTTP response or upload destination — bounded memory.
// In a Fastify route handler:
// return reply.send(stream);
const reader = stream.getReader();
const { value: firstChunk } = await reader.read();
console.log(`First chunk: ${firstChunk?.byteLength ?? 0} bytes`);