bus-pdf — render PDFs from JSON render models

bus-pdf — render PDFs from JSON render models

Synopsis

bus pdf --data <file> --out <path> [--overwrite] [-C <dir>] [--color <mode>] [-v] [-q] [-h] [-V]

Description

Command names follow CLI command naming.

bus pdf renders deterministic PDFs from structured JSON input. It does not read BusDK datasets directly. It accepts a render model via --data <file> or --data @- (stdin).

Callers such as bus-invoices load workspace data and pass a single JSON payload to this module. Output PDFs can then be registered as attachments.

Template selection is inside the render model via the template field (template id or repository-relative template path). There is no separate CLI template flag. Built-in templates are fi-invoice-a4 and plain-a4.

For Finnish regulated TASE/tuloslaskelma PDFs, use bus-reports with --format pdf (see Regulated report PDFs (TASE and tuloslaskelma)).

Render model

The JSON render model must include top-level template. The value can be a template identifier or repository-relative template path. The module uses this value to select the template for rendering.

For invoice PDFs, payload must conform to invoice render-model schema (header, lines, totals/VAT as applicable). Full schema details are in Module SDD: bus-pdf.

Options

--data <file> (or --data @-) supplies the JSON render model. --out <path> sets output PDF path. --overwrite allows replacing an existing file.

If output file exists and --overwrite is not set, command fails with a clear diagnostic.

Global flags are defined in Standard global flags. For help, run bus pdf --help.

Files

Reads a JSON render model from a file or stdin. Writes only the specified PDF output. Does not read or write workspace datasets.

Examples

bus pdf --data ./render/invoice-1001.json --out ./out/invoice-1001.pdf --overwrite
cat ./render/invoice-1002.json | bus pdf --data @- --out ./out/invoice-1002.pdf --overwrite

Exit status

0 on success. Non-zero on invalid usage or rendering failure.

Using from .bus files

Inside a .bus file, write this module target without the bus prefix.

# same as: bus pdf --data ./render/invoice-2001.json --out ./out/invoice-2001.pdf --overwrite
pdf --data ./render/invoice-2001.json --out ./out/invoice-2001.pdf --overwrite

# same as: bus pdf --data ./render/invoice-2002.json --out ./out/invoice-2002.pdf
pdf --data ./render/invoice-2002.json --out ./out/invoice-2002.pdf

Development state

Value promise: Render deterministic PDFs from JSON (e.g. invoice data) so bus-invoices can produce bus invoices pdf and other modules can emit documents from workspace data.

Use cases: Accounting workflow (step Generate invoice PDF and register attachment), Sale invoicing.

Completeness: 70% — Render step test-verified; user can produce PDF from file or stdin; bus invoices pdf not yet in bus-invoices.

Use case readiness: Generate invoice PDF and register attachment: 70% — render verified; bus invoices pdf not in bus-invoices. Sale invoicing (sending invoices to customers): 70% — PDF step verified; bus invoices pdf not in bus-invoices.

Current: Rendering from file/stdin, template resolution, overwrite behavior, determinism, and global-flag handling are test-verified. Detailed test matrix and implementation notes are maintained in Module SDD: bus-pdf.

Planned next: None in PLAN.md; all documented requirements satisfied by current implementation.

Blockers: None known.

Depends on: None.

Used by: bus-invoices (for bus invoices pdf).

See Development status.