PAD Showcase
All tags/PDF documents

An invoice as PDF

An order rendered on a sheet, the same template one click away as an A4 PDF made in plain PHP.

1 The data pdf/invoice.php php
<?php

  $invoice  = '2026-114';
  $issued   = '8 October 2026';
  $due      = '7 November 2026';
  $customer = [ 'name' => 'Noordkaap Sailing School', 'street' => 'Havenkade 12', 'city' => '1781 AB Den Helder' ];

  $lines = [
    [ 'item' => 'Mooring rope, 12 mm, per 20 m',     'qty' => 4,  'price' => 38.50 ],
    [ 'item' => 'Fender, inflatable, large',         'qty' => 6,  'price' => 27.95 ],
    [ 'item' => 'Life jacket 150 N, adult',          'qty' => 10, 'price' => 64.00 ],
    [ 'item' => 'Shackle, stainless, 8 mm',          'qty' => 24, 'price' => 3.20  ],
    [ 'item' => 'Delivery to the harbour',           'qty' => 1,  'price' => 45.00 ] ];

  $subtotal = 0;

  foreach ( $lines as $key => $line ) {
    $lines [$key] ['amount'] = $line ['qty'] * $line ['price'];
    $subtotal += $lines [$key] ['amount'];
  }

  $vat   = round ( $subtotal * 0.21, 2 );
  $total = $subtotal + $vat;

?>
2 The template pdf/invoice.pad pad
{pdf preview, file='invoice-{$invoice}', title='Invoice {$invoice}'}
  <img src="photos/logo.jpg" width="56" height="56" alt="Harbour Supplies">
  <h1>Invoice {$invoice}</h1>
  <p><b>Harbour Supplies</b><br>Kaai 3, 1781 AA Den Helder<br>info@harbour.example</p>
  <p>To: <b>{$customer.name}</b><br>{$customer.street}<br>{$customer.city}</p>
  <p>Issued {$issued} - due {$due}</p>
  <table>
    <tr><th>Item</th><th align="right">Qty</th><th align="right">Price</th><th align="right">Amount</th></tr>
    {lines}
    <tr><td>{$item}</td><td align="right">{$qty}</td><td align="right">{$price | currency('EUR', 'nl_NL')}</td><td align="right">{$amount | currency('EUR', 'nl_NL')}</td></tr>
    {/lines}
    <tr><td colspan="3" align="right">Subtotal</td><td align="right">{$subtotal | currency('EUR', 'nl_NL')}</td></tr>
    <tr><td colspan="3" align="right">VAT 21%</td><td align="right">{$vat | currency('EUR', 'nl_NL')}</td></tr>
    <tr><td colspan="3" align="right"><b>Total</b></td><td align="right"><b>{$total | currency('EUR', 'nl_NL')}</b></td></tr>
  </table>
  <p>Please pay within 30 days to <b>NL91 ABNA 0417 1643 00</b>, quoting invoice {$invoice}.</p>
{/pdf}
3 The result rendered on the server
Harbour Supplies

Invoice 2026-114

Harbour Supplies
Kaai 3, 1781 AA Den Helder
info@harbour.example

To: Noordkaap Sailing School
Havenkade 12
1781 AB Den Helder

Issued 8 October 2026 - due 7 November 2026

Item Qty Price Amount
Mooring rope, 12 mm, per 20 m 4 € 38,50 € 154,00
Fender, inflatable, large 6 € 27,95 € 167,70
Life jacket 150 N, adult 10 € 64,00 € 640,00
Shackle, stainless, 8 mm 24 € 3,20 € 76,80
Delivery to the harbour 1 € 45,00 € 45,00
Subtotal € 1.083,50
VAT 21% € 227,54
Total € 1.311,04

Please pay within 30 days to NL91 ABNA 0417 1643 00, quoting invoice 2026-114.