Skip to content

Quick start

This page walks through your first render — from key to PDF — without touching the dashboard.

Export your key into the environment your script runs in:

Terminal window
export POLI_PAGE_API_KEY=pp_test_...
<?php
require __DIR__ . '/vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\ProjectModeInput;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
$pdf = $client->render->pdf(new ProjectModeInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
));

$pdf is a binary string. Write it to disk, stream it to S3, or send it back through an HTTP response.

<?php
require __DIR__ . '/vendor/autoload.php';
use PoliPage\PoliPage;
use PoliPage\ProjectModeInput;
$client = PoliPage::client($_ENV['POLI_PAGE_API_KEY']);
$pdf = $client->render->pdf(new ProjectModeInput(
project: 'billing',
template: 'invoice',
data: ['invoiceNumber' => 'INV-001', 'total' => 1280],
));
file_put_contents('./invoice.pdf', $pdf);