Overview
APM uses a powerful JSON-based template system that separates document structure from data. Templates define the layout, formatting, and styling of printed documents, while business data is injected at print time.Template Architecture
Template Structure
Core Models
Core/Models/PrintTemplate.cs
Section Types
Static Sections
Sequential elements rendered in order.Table Sections
Columnar layout for repeating data.WidthPercentage values should sum to 100 for optimal column distribution.Repeated Sections
Loop over simple arrays or lists.Use
"Source": "." to reference the current item in a repeated section.Element Types
Text
Display static or dynamic text.Line
Horizontal separator.Barcode
Linear barcodes (CODE128, EAN13, etc.).QR Code
2D QR codes for URLs or data.Image
Embedded logos or graphics.Formatting Options
Format strings support multiple space-separated flags:Font Selection
| Format | Description | Characters (80mm) |
|---|---|---|
FontA | Standard font | 48 characters |
FontB | Compressed font | 64 characters |
Text Styles
| Format | Description |
|---|---|
Bold | Bold/emphasized text |
Underline | Underlined text |
Size Modifiers
| Format | Description |
|---|---|
Large | Double height |
DoubleWidth | Double width |
Size2 - Size8 | Proportional scaling (2x-8x) |
Combining Formats
Alignment
| Value | Description |
|---|---|
Left | Left-aligned (default) |
Center | Centered |
Right | Right-aligned |
Alignment can be set at section, element, or header level. Element-level alignment overrides section-level.
Data Binding
Property Paths
Use dot notation to access nested properties:Current Item Reference
InRepeated sections, use "." to reference the current item:
Table Data Binding
InTable sections, Source references properties of each item:
Complete Example Template
Corresponding Data Structure
Template Management via WebSocket
Templates can be updated remotely via WebSocket:Template Storage
Templates are stored as JSON files in the application data directory:Best Practices
Use section ordering
Use section ordering
Always set
Order property on sections to ensure consistent rendering sequence, even if sections are defined in different order in JSON.Optimize column widths
Optimize column widths
For tables, ensure
WidthPercentage values sum to 100. Test with longest expected content to avoid truncation.Combine formats efficiently
Combine formats efficiently
Use space-separated format strings (
"Bold Large Center") instead of nested styling to reduce complexity.Test with real data
Test with real data
Always test templates with production-like data volumes to ensure proper line wrapping and page breaks.
Use FontB for details
Use FontB for details
Use
FontB for secondary information (footer messages, disclaimers) to fit more content while keeping headers bold and large.Supported Document Types
APM includes pre-configured templates for:ticket_venta- Sales receiptscomanda- Kitchen/bar order ticketsfactura_electronica- Electronic invoicessticker_codigo_barras- Barcode labelscomprobante_egreso- Expense vouchers
Advanced Features
Conditional Rendering
While not directly supported in the template JSON, the renderer can conditionally include sections based on data presence:Custom Properties
Use theProperties dictionary for element-specific configuration:
Global Styles
Define template-wide defaults:Next Steps
Printer Management
Configure printers to use your templates
WebSocket Server
Send print jobs with your template data