Documents: Invoice, Ledger & PDF
A Document page is a blank, paper-sized sheet (A4, Letter, Legal, A5, A3) that you
design freely in the Designer — a letterhead, rules, a line-items table with totals, notes, signatures — and then
print or download as a real PDF. Bind it to a table and it opens for one record
(Invoice #42, a customer’s statement, a ledger page), reading that record everywhere with
:master.<field>. Built for accounts & audit apps: invoices, tax invoices, receipts, delivery notes,
ledgers, statements of account and reports.
generated/<table>/<slug>.php — so it now appears on that
table’s Pages screen under Document pages, alongside List, Add, Edit and
View. That panel shows the paper, whether the document auto-numbers, how many copies it prints and whether it is
watermarked, protected or e-mailable, and it lets you switch a document off without deleting its
design — it is simply left out of the next build and its buttons disappear from the List and View
pages. Documents with no saved switch stay on, so nothing you built before changed.Contents
- How it works
- The paper canvas (size, orientation, margins)
- Binding a document to a record
- Reading the record:
:master.<field> - Opening it — the Documents button
- Print vs Download PDF
- Ready-made layouts: Invoice, Tax Invoice, Receipt, Delivery Note, Ledger, Statement, Report
- The Letterhead component
- The Line Items + Totals component (VAT, discount, amount in words)
- Footer text & page numbers
- Documents from the List — per row and in bulk (merged PDF / ZIP / e-mail)
- E-mailing a document
- Archive & history
- Auto-numbering (invoice numbers that never repeat)
- Watermark & PDF protection
- Canvas layout — free placement in millimetres
- Page Break & QR codes
- Your logo & images — upload, pick, and how they reach the PDF
- PDF quality: fonts, sizes, running header, copies (Original / Duplicate)
- Date & time stamp — English or Nepali (BS), header or footer
- Tokens & filters — {{field|bs}}, {{amount|words}}, {{now_bs}}…
- Signature block, Barcode & Nepali numerals
- Recipes — step by step
- For developers: pp_doc_* helpers, numbering and QR in Events
- Example — an Invoice
- Example — a Ledger / Statement of account
- Laying out the sheet: Cell Grid, Divider & friends
- Security
- Every property
- Notes & gotchas
- What’s next
How it works
- You create a Document page. The Designer canvas becomes a real paper sheet at the chosen size — no navbar, no sidebar — and you drop components onto it exactly like any other page.
- You bind it to a table (Properties → Document → About one record of). The built page then opens as
…/<page>.php?id=<record>, loads that record (under login + Row-Level Security) and pins it as:masterfor every component. - The built page has a toolbar with Print (browser) and Download PDF (server, mPDF), and every bound record’s View page gets a Documents button that opens it.
The paper canvas
Properties → Paper: Size (A4, Letter, Legal, A5, A3), Orientation
(portrait / landscape) and Margin. The canvas shows the sheet at true proportions; the build emits the matching
@page rule so print and PDF use the same box. Everything inside the margins is yours.
Binding a document to a record
Properties → Document → About one record of: pick the table. Record parameter is the URL
key (default id). Leave it unbound for a static document (a price list, a notice).
invoices table, a Statement to customers,
a Delivery note to orders. One table can have several documents.Reading the record: :master.<field>
On a bound document the current record is available to every data component through SQL Variables as
:master.<column> — in a Table Card’s SQL or WHERE, a
Live Value, a chart, a Master-Detail grid. Values are safely quoted for you.
-- The line items of THIS invoice (Table Card → Custom SQL)
SELECT description AS Description, qty AS Qty, rate AS Rate, qty * rate AS Amount
FROM invoice_items
WHERE invoice_id = :master.id
-- The customer block for THIS invoice
SELECT name, address, phone, pan FROM customers WHERE id = :master.customer_id
Opening it — the Documents button
Once a document is bound to a table, that table’s View page shows a Documents button per
document (labelled with the document’s name). It opens the sheet for the record being viewed in a new tab:
generated/<table>/<page>.php?id=<record>. You can also link to that URL from a Custom Button.
Print vs Download PDF
| Button | How | Best for |
|---|---|---|
The browser’s own print dialog, using the sheet’s @page size & margins (choose “Save as PDF” there too). | Pixel-perfect output of exactly what you see, including complex grid layouts. | |
| Download PDF | The server renders the same sheet with mPDF (pure PHP, bundled — works on shared hosting) and streams a file. Same URL with &format=pdf. | A real, selectable-text PDF that is identical on every device, ideal for emailing, archiving and automation. Full Unicode — Nepali / Devanagari renders as real text. |
Ready-made layouts
You rarely need to start from a blank sheet. In + New custom page choose Page kind Document and pick a Start from layout — the sheet is pre-built with a Letterhead, title, meta block, Line Items and the usual footer so you only fill in table names and columns:
| Start from | What you get |
|---|---|
| Invoice | Letterhead, INVOICE title, Bill-to / Invoice-meta cells, Line Items with Subtotal & Grand total, amount in words, terms + signature. |
| Tax Invoice | As Invoice, with Tax / VAT 13 % on, the buyer’s PAN/VAT line and the seller’s Tax ID in the letterhead. |
| Receipt | A compact “Received with thanks” sheet — payer, amount, amount in words, mode of payment, signature. |
| Delivery Note | Line Items with Rate and Amount switched off (quantities only) and a received-by block. |
| Ledger | Party ledger: Date / Particulars / Debit / Credit / Balance with a running balance and closing figures. |
| Statement | Statement of account for a period — opening balance, transactions, closing balance, ageing note. |
| Report | A titled report sheet — letterhead, title, intro text, a data Table Card with totals and page numbers (switch Paper → Orientation to landscape for wide tables). |
Every starter is ordinary components on an ordinary sheet — move, restyle or delete anything afterwards.
The Letterhead component
Components → Documents → Letterhead. One drop gives you the company header, pre-filled from your app’s Style → Brand (name and logo) so every document matches. Fill or override:
| Property | What it does |
|---|---|
| Layout | Logo left (classic), Logo right, Centered, Stacked (logo above text). |
| Logo / Logo width | Blank = the Style brand logo. Click Upload to add a PNG / JPG / SVG / WebP (stored in Custom Files → img/, shipped with the app), Pick to choose one already uploaded, or paste a URL. A logo file that is missing is simply left out — never a broken-image box, never an empty column. Width in px (a 300–600 px source prints razor-sharp). |
| Without a logo | Show the app’s initials badge (new letterheads) — when there is no logo image, the same letter mark as your app’s header (Task Tracker → TT, Northwind → NO) in your theme colour (or the Accent colour), on screen, in print and in the PDF. Nothing — text only keeps just the name; letterheads made before this option keep that look. |
| Company name / Tagline / Name size | Blank name = the app name. Tagline sits under it; size Small / Medium / Large. |
| Address, Phone, Email, Website | The contact lines (address keeps its line breaks). |
| Tax ID label / Tax ID | e.g. PAN No. / VAT Reg. No. and the number — printed as its own line. |
| Accent colour | Colour of the company name (and the rule, unless set separately). |
| Rule under the letterhead / colour / thickness | The horizontal rule that closes the header. |
Because the letterhead is a component you can also drop it on Print pages and reports — and style it like anything else (fonts, borders, background). The logo is embedded into the server PDF from your app files; no external URL is ever fetched.
The Line Items + Totals component
Components → Documents → Line Items. The items table every commercial document needs, with all the arithmetic done on the server. Pick the rows, map the columns, switch on what you need:
| Group | Properties |
|---|---|
| Source | Table — a detail table + Filter (WHERE) such as invoice_id = :master.id + Order by. Row-Level Security and your table WHERE events are applied, exactly as on list pages. SQL — your own SELECT (read-only; all SQL Variables available). |
| Columns | Description / Qty / Rate / Amount / Unit column names. Leave Amount column blank to compute qty × rate. |
| Show | Serial #, Unit, Rate, Amount column & totals (off = a delivery note), plus every column label. |
| Numbers | Currency prefix (Rs. , $), decimals, qty decimals. |
| Totals | Subtotal → Discount (None / Percent % / Fixed amount) → Tax / VAT (Percent % of the discounted subtotal) → Round off (the grand total is rounded to the nearest whole unit) → Grand total. Every label is editable. |
| Amount in words | Prints the grand total in words in English (lakh / crore), English (million / billion) or Nepali (नेपाली), with your currency word (Rupees / रुपैयाँ / Dollars) and sub-unit. |
Worked example — Tax Invoice at VAT 13 %: items 2 × 1,000 and 1 × 1,100 → Subtotal 3,100.00 → Discount 5 % −155.00 → VAT 13 % +382.85 → Grand total 3,327.85. In words (lakh style): Three Thousand Three Hundred Twenty Seven Rupees and Eighty Five Paisa Only; in Nepali: तीन हजार तीन सय सत्ताइस रुपैयाँ पचासी पैसा मात्र.
Delivery note: switch off Rate column and Amount column & totals — you get Serial / Description / Qty / Unit only. Ledger-style: use SQL source with Debit/Credit columns mapped to Qty/Rate and totals off, or simply a Table Card (see the Ledger example below).
Footer text & page numbers
In Page → Paper set a Footer text and tick Page numbers. The footer repeats on
every printed and PDF page; in the text you may use {PAGENO} (current page) and {nbpg} (total pages), e.g.
Page {PAGENO} of {nbpg} · Generated by Sunrise Traders. Leave the text blank with Page numbers on for a plain
“Page 1 of 3”.
Documents from the List
Every table that has a bound Document page gets it in two more places, automatically:
- Row actions — the row’s action menu (⋯) shows one button per document (Invoice, Statement…) that opens the sheet for that record. The Designer’s grid action Documents controls its icon/label like any other action.
- Selection bar → Documents ▾ — tick rows (or Select all matching) and choose, per document:
Choice What you get One merged PDF A single PDF with every selected record, each starting on a new page; page numbers restart per document (“Page 1 of 2” on every invoice). ZIP — one PDF per record Invoice-42.pdf,Invoice-43.pdf… in one ZIP (falls back to a merged PDF on hosts without the zip extension).E-mail to each record Sends each record its own PDF to the document’s Recipient column (see below). Max 20 per click, 30 per user per hour.
E-mailing a document
When the app has an e-mail server configured (Misc → Email), the document toolbar shows E-mail. It opens a small
form with To, Subject and Message — pre-filled from the page’s E-mail properties —
and sends the PDF as an attachment (Invoice-INV-2026-00042.pdf).
| Property (Page → E-mail) | What it does |
|---|---|
| Recipient column | The bound table’s e-mail column. Pre-fills To and enables E-mail to each record in bulk. Blank = the user types the address. |
| Subject / Message | Defaults with tokens: {{invoice_no}}, :master.customer_name, {{today}}. Blank subject = “Invoice #42”. |
| Keep a copy of every sent PDF | Stores the exact PDF that was sent in the archive (see below) — an audit-grade record of what the customer received. |
Sends fire the usual global.email.beforeSendEmail / afterSendEmail / onEmailFailed events and are logged
with recipient, user and time. Failed sends never silently succeed.
Archive & history
Archive saves a PDF copy of the document as it is right now in the app's private document store (access-denied to the web; served only through the app after re-checking the record’s Row-Level Security). History ▾ lists every archive and e-mail of this record’s document — who, when, to whom, with a download link for archived copies. Selection bar → Documents ▾ can archive many records at once (via the API, see developers).
Auto-numbering
Page → Numbering: pick the bound table’s number column (e.g. invoice_no). The first time the
document is opened for a record whose column is empty, the next number is allocated and written to the record — every
Letterhead, Line Items, QR and :master.invoice_no on the sheet sees it immediately. Numbers are allocated inside a
database transaction, so two users generating at the same instant get two different numbers, with no gaps.
| Property | Example |
|---|---|
| Prefix / Suffix | INV-{Y}- → INV-2026-00042 · tokens {Y} {y} {m} {d} {period} |
| Digits (pad) | 5 → 00042 |
| Start at | 1 (or continue from your old system: 1001) |
| Restart | Never · Every year · Every month · Every day — each period keeps its own counter. |
Prefer to number when the record is saved rather than when the document is opened? Use pp_next_number() in a
beforeAddSave event — it joins the save's own transaction, so if the save is cancelled or fails, the number is given back and
your sequence stays gap-free. Nepali fiscal years: pass your own period (e.g. 2083/84).
// Events → invoices → Page Events → Before Add Save
$data['invoice_no'] = pp_next_number('invoice', ['prefix' => 'INV-{Y}-', 'pad' => 5, 'reset' => 'yearly']);
// → INV-2026-00042; works the same on MySQL, PostgreSQL, SQL Server and SQLite
Watermark & PDF protection
- Watermark (Page → Watermark): text such as PAID, DRAFT, COPY drawn diagonally across every page of the PDF — and on screen/print when Also show on screen is on. Tokens work, so
:master.statusprints the record’s own status. Opacity and colour are yours. - PDF protection (Page → PDF protection): encrypts the PDF and limits what readers may do — print, print high-res, copy text, modify, annotate, fill forms, extract, assemble. Optionally require a password to open the file. Everything not ticked is blocked in Acrobat, Preview, browsers and phones.
Canvas layout — free placement
Page → Layout → Layout mode: Canvas turns the sheet into a free canvas: every top-level component sits at an exact X / Y / Width / Height in millimetres (Properties → Position & size). Drag a component anywhere, drag its corner to resize, use the arrow keys to nudge by 1 mm (Shift = 5 mm). A dotted 5 mm grid helps alignment.
- Made for pre-printed stationery, certificates, cheques, labels and pixel-exact invoices where a block must land on a given spot.
- The printed page, the browser PDF and the server PDF use the same millimetre positions. A component placed below the page height simply continues on the next page.
- Height 0 = automatic (grows with content); set a height to clip a block to a fixed box.
- Components inside a Cell Grid or Section keep their normal flow — only the top-level blocks are free. Switch back to Flow any time; positions are remembered.
Page Break & QR codes
- Page Break (Components → Documents) forces the next component onto a new page — invisible on paper, a dashed marker in the Designer and on screen.
- QR Code is generated on your server (nothing is sent to any QR service) and embedded as a crisp SVG/PNG data URI, so it prints and renders in PDFs offline. Its value accepts tokens:
https://pay.example/inv/:master.id,{{invoice_no}}. Same generator as the passkey/2FA screens; up to ~210 characters.
Your logo & images
Every image property in the Designer (Letterhead → Logo, the Image component → Source) has the same three buttons:
| Button | What happens |
|---|---|
| Upload | Sends the file to Custom Files → img/ of this project (max 4 MB; PNG, JPG, GIF, WebP, SVG). The property is set to custom/img/<file> and the file ships inside every build. |
| Pick | Shows the images already in Custom Files — one click selects. |
| × | Clears the property; a Letterhead then falls back to the app brand logo from Style. |
custom/img/logo.png, uploads) are embedded straight from the file on disk at full resolution — logos come out as crisp as the source. Remote URLs are fetched; a missing file is skipped silently. For the sharpest print use a PNG/SVG at least 300 px wide, or an SVG.PDF quality: fonts, sizes, running header, copies
Text in the PDF is real vector type (embedded fonts) — it stays sharp at any zoom and is selectable/searchable. Tables, rules and the Cell Grid are drawn as vector lines. The Paper group gives you the remaining knobs:
| Property | Use it for |
|---|---|
| Document font | DejaVu Sans (clean default) · DejaVu Serif (classic ledgers) · Condensed (wide tables) · Mono (statements) · Free Sans / Free Serif (most natural Devanagari). All embed fully and cover Nepali / Hindi. |
| Base font size | 8–12 pt. 9 pt fits ~35 item rows per A4 page; 11 pt for letters and certificates. |
| Header text | Repeated top-right on every PDF page — e.g. Invoice {{invoice_no}} · continued. Tokens resolve per record; {PAGENO} works too. |
| Footer text / Page numbers | Bottom of every page (print and PDF). |
| Copies | Original, Duplicate, Triplicate → the PDF repeats the document once per label with the label printed at the top — the usual VAT-invoice set in one download (also in bulk merged PDFs and e-mails). Blank = single copy. |
Negative amounts (discounts, credits) print as – Rs. 137.58; totals are right-aligned in their own column; rows never split across pages and the totals block stays together.
Date & time stamp
Page → Paper → Date & time stamp prints the moment the document was generated — on screen, in print and on every PDF page (running header or footer). Pick the calendar and whether the time is shown:
| Calendar | Prints |
|---|---|
| English | Wednesday, 2 September 2026 · 6:45 PM |
| Nepali (BS) | बुधबार, १७ भदौ २०८३ · साँझ ६:४५ — Devanagari digits, Nepali month and weekday, part of day (बिहान / दिउँसो / साँझ / राति) |
| Nepali in Latin script | Wednesday, 17 Bhadra 2083 · 6:45 PM |
| English + Nepali | Both, separated by a bar — the usual choice for official Nepali documents |
- Stamp label — words before the date, e.g. Printed on or मुद्रण मिति:.
- Time zone — defaults to Nepal (Asia/Kathmandu) regardless of the server clock; also drives the
{{now}}/{{today}}tokens. - Position Header prints top-left, Footer bottom-right; a running header/footer text you also set shares the line.
- The Bikram Sambat conversion is the same table the Nepali date picker uses (BS 1970–2100), computed on the server — documents, e-mails and PDFs always agree with what users see on screen.
Tokens & filters
Anywhere a document takes text — Text, Heading, Letterhead lines, QR / Barcode values, e-mail subject, watermark, header/footer, stamp label — you can merge record and clock values. A filter after | formats the value:
| Token | Result |
|---|---|
{{invoice_no}} · :master.invoice_no | The bound record’s column |
{{invoice_date|bs}} | Nepali date: मङ्गलबार, १ जेठ २०४७ (add the time when the column has one) |
{{invoice_date|bs-en}} | Tuesday, 1 Jestha 2047 |
{{invoice_date|ad}} | Tuesday, 15 May 1990 · |date → 1990-05-15 · |time → 6:45 PM |
{{total|words}} · {{total|words-ne}} | Three Thousand … Rupees … Only · तीन हजार … रुपैयाँ … मात्र |
{{total|ne}} | Devanagari digits: ३,३२७.८५ |
{{customer|upper}} · |lower | Case change |
{{today}} · {{now}} | 2026-09-02 · 2026-09-02 18:45 (document time zone) |
{{today_ad}} · {{now_ad}} | Wednesday, 2 September 2026 · with time |
{{today_bs}} · {{now_bs}} · {{today_bs_en}} | बुधबार, १७ भदौ २०८३ · with time · Latin script |
:userid · :username | The signed-in user |
Example Text block on an invoice: Date: {{invoice_date|bs}} ({{invoice_date|ad}}) · Amount: {{total|ne}} — {{total|words-ne}}.
Signature block, Barcode & Nepali numerals
- Signature (Components → Documents): a signature image (Upload / Pick — a transparent PNG prints best), an optional stamp/seal image laid over it, the signature line, then name, title and label (Authorised Signatory); optional date in English or Nepali. Tokens work in name/title, so
{{approved_by}}signs each record with its approver. Leave the image empty for a hand-signed line. - Barcode: Code 128 (letters, digits, symbols), generated on your server as a crisp SVG —
INV-{{invoice_no}}scans with any phone or handheld reader. Set bar width 3 for low-quality printers. - Nepali numerals: Line Items → Numbers → Numerals: ०–९ prints serial numbers, quantities, rates and totals in Devanagari (रु. २,२६०.००); combine with Amount in words: Nepali and the Nepali date stamp for a fully Nepali invoice.
Recipes — step by step
A VAT tax invoice with three copies
- + New custom page → Document → bind
invoices→ Start from Tax Invoice (VAT) → name Tax Invoice. - Select the Letterhead → Logo → Upload your logo; fill address, phone, VAT No..
- Select Line Items → Source Table
invoice_items, Filterinvoice_id = :master.id; map Description / Qty / Rate; VAT 13 %; Amount in words Nepali or English (lakh). - Page → Numbering: column
invoice_no, prefixINV-{Y}-, digits 5, restart yearly. - Page → Paper: Copies
Original, Duplicate, Triplicate; Page numbers on; Date & time stamp in the footer, calendar English + Nepali. Page → Watermark::master.status(prints PAID / DRAFT from the record). - Optional, fully Nepali: Line Items → Numerals ०–९, Amount in words Nepali; a Text block
मिति: {{invoice_date|bs}}; a Signature block with your seal image at the bottom-right; a Barcode{{invoice_no}}for the file copy. - Page → E-mail: Recipient column
customer_email, SubjectTax Invoice {{invoice_no}}. Build. - Use it: Invoices list → tick rows → Documents ▾ → Tax Invoice → One merged PDF, or open one invoice → E-mail.
A fee receipt (school / clinic)
- Document bound to
payments→ Start from Payment Receipt. - Text:
Received with thanks from {{student_name}} the sum of {{amount}}; Line Items off (or a single row); Amount in words on. - Numbering column
receipt_no, prefixRCPT-; CopiesOffice copy, Customer copy; QR valuehttps://your-app/verify/{{receipt_no}}.
A certificate on pre-printed paper (Canvas)
- Document bound to
students, Paper A4 landscape, Layout mode Canvas. - Drop a Heading (
{{full_name}}) and drag it to X 40 / Y 95 mm, width 217; a Text block for the citation; a QR at bottom-right (X 250, Y 160, W 30). - Set Margin 10mm so positions match the pre-printed frame; print a test page and nudge with the arrow keys (1 mm; Shift = 5 mm).
A monthly statement of account
- Document bound to
customers→ Start from Statement of Account; Table Card with the running-balance SQL from the Ledger example; Footer totals for Debit/Credit. - Document font DejaVu Mono (aligned figures), Header text
{{name}} · Statement · continued, Copies blank. - From the customers List: select all matching → Documents ▾ → Statement → E-mail to each record (Recipient column
email). Each customer receives only their own statement.
For developers
Everything above is also available to your Events, Custom Buttons and scheduled tasks through the generated app’s helpers:
// A document's PDF bytes (null when the record is hidden by RLS / missing)
$pdf = pp_doc_pdf('custom_invoice', $id);
// Many records → one merged PDF
$pdf = pp_doc_pdf_merged('custom_invoice', [12, 13, 14]);
// E-mail it (recipient defaults to the document's Recipient column)
$r = pp_doc_email('custom_invoice', $id, 'buyer@example.com', 'Your invoice', 'Thanks for your order.');
if (!$r['success']) error_log($r['message']);
// Keep a copy in the archive (returns the archive row id)
pp_doc_archive('custom_invoice', $id);
// Numbering — e.g. in tables.invoices.page.beforeAddSave:
$data['invoice_no'] = pp_next_number('invoice', ['prefix' => 'INV-{Y}-', 'pad' => 5, 'reset' => 'yearly']);
$preview = pp_peek_number('invoice', ['prefix' => 'INV-{Y}-', 'pad' => 5, 'reset' => 'yearly']); // no allocation
// A QR code anywhere (Custom HTML, e-mails, PDFs)
echo '<img src="' . pp_qr('https://example.com/pay/42', ['size' => 120]) . '">';
// Expand document tokens yourself
echo pp_doc_text('Invoice {{invoice_no}} for :master.customer_name');
The HTTP endpoint behind the buttons is api/documents.php (POST JSON or form; actions merged, zip,
email, archive, history; GET action=download&archive=ID). It requires the session,
the CSRF token, view permission on the table and re-applies Row-Level Security to every record — the client never chooses the
table, paper, watermark or recipient column; those come from the build-time registry app/documents.php.
Example — an Invoice
- + New custom page → Page kind Document → table
invoices→ name Invoice. - Letterhead: drop the Letterhead component (Components → Documents). It is already filled with your app’s brand name and logo; add the address, phone, e-mail and PAN/VAT No. in its properties.
- A Heading “TAX INVOICE” and a Divider under it.
- Bill to & meta: a Table Card (Custom SQL) reading the customer via
:master.customer_id, and a Text block for Invoice No / Date / Due date (or Live Values bound to the invoice). - Line items: drop Line Items, Source Table →
invoice_items, Filterinvoice_id = :master.id, map the Description / Qty / Rate columns, set Tax / VAT to 13 % and switch on Show amount in words. - A Divider, then a Text block for terms and an authorised-signature line.
- Build. Open any invoice’s View page → Documents → Invoice → Print or Download PDF.
Example — a Ledger / Statement of account
Bind a document to customers. Use a Table Card (Custom SQL) with a running balance — the totals row gives
the closing figures:
SELECT t.txn_date AS Date, t.particulars AS Particulars,
t.debit AS Debit, t.credit AS Credit,
SUM(t.debit - t.credit) OVER (ORDER BY t.txn_date, t.id) AS Balance
FROM ledger t
WHERE t.customer_id = :master.id
ORDER BY t.txn_date, t.id
(On MySQL 5.7 use a correlated sub-select for the balance.) Add Footer totals for Debit and Credit.
Laying out the sheet
- Letterhead and Line Items — the two document components above; the fastest route to a finished sheet.
- Cell Grid — rows × columns with merge/split, fixed column widths and row heights, per-cell padding/alignment. The precision tool for letterheads, meta blocks and signature rows.
- Divider — horizontal rules (plain or labelled). Heading / Text / Image — titles, notes, logos.
- Table Card — any list of rows with a totals footer. Master-Detail — child rows of the bound record.
- Live Value — a single computed figure (outstanding due, credit remaining).
- Every component keeps its Size & Layout spans and Style (fonts, colours, borders), so the sheet can match your company theme.
Security
- A bound document loads its record behind login + the table’s page permission and applies Row-Level Security — a user can only open documents for rows they are allowed to see. Unknown ids return 404.
- Encrypted fields are decrypted only for permitted users; the record passes through the same view events as the View page.
- The server PDF is rendered from the exact same guarded page — there is no separate, less-protected export path.
Every property
| Property | What it does |
|---|---|
| Page kind → Document | Makes the page a chromeless paper sheet (set when you create it). |
| Paper: Size / Orientation / Margin | The sheet box used by the canvas, print and PDF. |
| Document: About one record of | The table this document is about; opens as ?id=… and exposes :master.*. |
| Document: Record parameter | The URL key carrying the record id (default id). |
| Paper: Footer text / Page numbers | A running footer on every page; {PAGENO} / {nbpg} tokens. |
| Paper: Header text / Document font / Base font size / Copies | Running header, PDF typeface and size, and copy labels (Original, Duplicate…). |
| Paper: Date & time stamp / Calendar / Include time / Stamp label / Time zone | Generation stamp in the header or footer — English, Nepali (BS), Latin-script Nepali or both. |
| Start from (on create) | A ready-made layout — Invoice, Tax Invoice, Receipt, Delivery Note, Ledger, Statement, Report. |
| Layout: Layout mode | Flow (12-column grid) or Canvas (free placement in mm). |
| Numbering: Column / Prefix / Suffix / Digits / Start / Restart | Gap-free auto-numbering written to the record on first open. |
| Watermark: Text / Opacity / Colour / Also on screen | Diagonal watermark on PDF (and screen/print). Tokens allowed. |
| PDF protection: Encrypt / Readers may / Open password | Encrypted PDF with reader permissions. |
| E-mail: Recipient column / Subject / Message / Keep copies | Defaults for the E-mail button and bulk e-mail; archive of sent PDFs. |
| Output | Print (browser) and Download PDF (server mPDF) — always both. |
| Advanced: Custom CSS / JS | Per-document styling and behaviour, like any page. |
Notes & gotchas
- Use the column name in
:master.customer_id— the database column, not the label. - A document opened without
?idrenders its static parts only (no record). - Keep an invoice to one page where you can; long tables break across pages automatically, and rows avoid splitting.
- Documents don’t get a menu entry — they are reached per record from View → Documents (link them anywhere you like).
- Languages and scripts: the bundled fonts cover Latin, Cyrillic and Greek, Devanagari (so Nepali and Hindi just work), Arabic, Hebrew, Thai and most Indic scripts — with the right shaping, so Arabic joins and Devanagari forms conjuncts. Chinese, Japanese and Korean print through the fonts every PDF reader already has. You never pick a font for a language: each run of text is matched automatically.
What’s next
Shipped: the paper + record-binding foundation, mPDF output, Letterhead and Line Items, ready-made layouts, running footers and
page numbers, PDF-faithful Cell Grids, Documents on the List (row + bulk merged/ZIP/e-mail), e-mail with PDF attachment, archive &
history, gap-free auto-numbering, watermark & PDF protection, the Canvas layout, Page Break and offline QR codes. Coming next:
scheduled generation (e.g. monthly statements e-mailed by cron.php), signature/stamp images and a template gallery.
See also Print & PDF pages, SQL Variables,
Email, Live Value and the Component Guide.