Skip to content

Render modes

The PHP SDK exposes two ways to describe what to render: project mode (a stored template at project/template) and inline mode (raw HTML you pass directly).

Project mode is required by every PDF-producing method ($client->render->pdf(), $client->render->pdfStream(), $client->render->document(), and the renderToFile() helper). Inline mode is supported only by $client->render->preview(), which returns HTML rather than PDF bytes — useful for debugging template data without engaging the PDF pipeline.

You reference a template by its project and template slugs, plus a data array that fills the template’s placeholders. Optionally pin a version.

use PoliPage\ProjectModeInput;
$pdf = $client->render->pdf(new ProjectModeInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
));

Project mode keeps templates centralized — anyone with dashboard access can edit them without touching code.

For one-off layout experiments, pass the HTML directly. InlineModeInput accepts a template string when there is no project:

use PoliPage\InlineModeInput;
$preview = $client->render->preview(new InlineModeInput(
template: '<h1>Hello {{ name }}</h1>',
data: ['name' => 'World'],
));

Inline mode only works with $client->render->preview(). To turn inline HTML into a PDF, save it as a template in the dashboard first, then use project mode.

<?php
require __DIR__ . '/vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\ProjectModeInput;
use PoliPage\InlineModeInput;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
// Project mode — PDF
$invoicePdf = $client->render->pdf(new ProjectModeInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
));
// Inline mode — preview HTML only
$greeting = $client->render->preview(new InlineModeInput(
template: '<h1>Hello {{ name }}</h1>',
data: ['name' => 'World'],
));