PPPHP

Print & PDF pages

A print page is a clean, branded rendering of one record; a PDF page is the same content saved as a file. Both are read-only, so — like the View page — you read and style displayed values. Each recipe says exactly where the code goes.

Events these pages fire

EventWhereUse for
On PrintTable → Page Events (PHP)Add computed values / adjust data before the printable page renders.
Process Record ValuesTable → Page Events (PHP)Format a single value for the printout.
On Page InitTable → Client Events (JS)Auto-print, tweak the layout, or trigger a download.

Recipes

1 · Add a computed value to the printout

WhereEvents → invoices → Page Events → On PrintPHP
$data['amount_due'] = (float) $data['total'] - (float) $data['paid'];
$data['printed_at'] = now();

2 · Format money / dates for the printed copy

WhereEvents → invoices → Page Events → Process Record ValuesPHP
if (isset($data['total'])) $data['total'] = '$' . number_format((float) $data['total'], 2);
if (!empty($data['due_date'])) $data['due_date'] = date('j M Y', strtotime($data['due_date']));

3 · Auto-open the print dialog

WhereEvents → invoices → Client Events → On Page InitJS
setTimeout(function () { window.print(); }, 400);   // pop the browser print dialog

4 · Read a shown value

WhereEvents → invoices → Client Events → On Page InitJS
var ref = Runner.getControl('reference').getValue();   // getValue() reads the printed text
document.title = 'Invoice ' + ref;

5 · A “Save as PDF” button on the View page

Drop a Custom Button. The app ships a server-side PDF endpoint per record — link straight to it, or generate + email it.

WhereDesigner → Custom Button → Client AfterJS
// open the record's PDF in a new tab (PP_BASE + the generated pdf route)
window.open((window.PP_BASE || '') + '/generated/invoices/pdf.php?id=' + pp.page.id, '_blank');

6 · Email a generated PDF after saving

WhereEvents → invoices → Page Events → After Add SavePHP
// Build the record's HTML, render it to a PDF file with PdfService, then email it.
$html = '<h1>Invoice ' . htmlspecialchars((string) $data['reference']) . '</h1>'
      . '<p>Total: ' . number_format((float) $data['total'], 2) . '</p>';
$file = \PpPhp\Core\PdfService::save($html, sys_get_temp_dir() . "/invoice-$id.pdf");
// attach $file with your mailer — see the PDF + Email guides for the details.
The read/style API (Runner.getControl(field).getValue(), .addStyle()) is the same one you use on View. Full server-side PDF options are in the PDF guide.