model-print-form

Adds PDF print forms to models via SQL data commands, JSON templates, and core print runtime.

1|Updated Jun 25, 2026
One-click install
npx skills add https://github.com/IgorAIvanov/altera03 --skill model-print-form-igoraivanov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: model-print-form
Source: https://github.com/IgorAIvanov/altera03/tree/main/skills/src/model-print-form
Command: npx skills add https://github.com/IgorAIvanov/altera03 --skill model-print-form-igoraivanov

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding a printed form (invoice, act, receipt) to a model normally tempts developers to write PDF generation, template parsing, or client-side rendering code. This Skill shows how to supply only data and a template while the core @altera/server print runtime owns all rendering, eliminating duplicated rendering logic and formatting drift. ## Core Features & Use Cases - Four-artifact workflow: Create the SQL data command (<model>_print_data), the schemaVersion: 2 template file, the manifest prints block, and the print button on the edit form. - Template authoring guidance: Absolute vs flow placement, page breaks, repeat blocks for per-record blanks, char-cells and rotated text for regulated Ukrainian forms, conditional visibleWhen blocks, and amount-in-words formatting. - Layout verification: Probe templates with renderPrintPdfWithLayout and text measurers to catch overflow before printing. - Use Case: Add a printable invoice (накладна) to an existing model — write the SQL projection returning formatted strings, declare the template with header coordinates and flow tables, register via deno task sql:registry && sql:assemble && sql:publish, and wire the print button that opens the PDF in a new tab. ## Quick Start Ask the agent to add a printed invoice form to the invoice model with header fields, a lines table, totals, and signature blocks using the core print runtime.

Frequently Asked Questions about model-print-form

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a PDF print form to a model?

Create four artifacts: a SQL function `<model>_print_data(user_id, payload)` returning the print projection, a `prints/<model>_<code>.template.json` template file, a `prints` block plus `commands.sql.printData` in the manifest, and a print button on the edit form. Then run `deno task sql:registry && sql:assemble && sql:publish`.

Should I write my own PDF rendering or template parsing code?

No. The `@altera/server` package owns the template format, render plan, and PDF renderer. The application supplies only data and a template; writing PDF generation, HTML-to-PDF, or client-side rendering is explicitly forbidden.

Do I need to declare commands.ts.printPdf in the manifest?

No. `deno task sql:registry` derives `printPdf` automatically from a non-empty `prints` block and binds the core handler `runtime.printPdf`. The manual slot exists only as an override for models needing a custom print handler.

Why does my template fail with 'Cannot read properties of undefined'?

A template read directly from disk has not been normalized. Pass it through `normalizePrintTemplateSchema` before rendering or planning, since both the printPdf command and editor preview do this automatically but manual scripts do not.

How do I handle conditional sections like VAT lines in a print template?

Use `visibleWhen` with a boolean flag computed in the SQL data command, such as `hasVat`. It works on any block, table column, row, or field-list item. Never ship one template per combination, since user-edited copies diverge.

Why does the print button popup get blocked by the browser?

The preview window must be opened before the `await` call, otherwise the browser treats it as not user-initiated and blocks it. Also refuse printing on unsaved records, since printing reads from the database.