Overview
APM allows you to remotely create or update print templates via WebSocket. This enables dynamic template management from your web application without manually editing configuration files.Update Template Request
Send a template update to APM.Message Format
Request Fields
Must be
UpdateTemplate to update or create a template.The complete template configuration.
Template Update Result
After processing a template update, APM sends a result message back to the requesting client.Message Format
Success
Error
Response Fields
Always
TemplateUpdateResult for template update responses.The document type that was updated.
true if the template was saved successfully, false otherwise.Descriptive message about the result.
Example: Complete Template Update Flow
Section Types
Static
Prints fixed content or single values from the document.Table
Iterates over a collection and prints rows.Repeated
Repeats a block of elements for each item in a collection.Element Types
| Type | Description | Common Properties |
|---|---|---|
Text | Text content | Source, StaticValue, Label, Format, Align |
Barcode | 1D barcode | Source, BarWidth, Height |
QR | QR code | Source, Size, Align |
Image | Image (from document data) | Source, Height |
Line | Separator line | Format |
Format Options
Multiple format options can be combined with commas:Bold- Bold textLarge- Large font sizeItalic- Italic textCurrency- Format as currencyUnderline- Underlined text
"Format": "Bold,Large"
Best Practices
- Test Templates Locally First: Create and test templates in the APM configuration before deploying remotely
- Use Descriptive Names: Give templates and sections clear, descriptive names
- Order Matters: Use the
Orderproperty to control the sequence of sections and elements - Width Percentages: For table columns, ensure width percentages add up to approximately 100%
- Data Source Paths: Use dot notation for nested properties (e.g.,
"Customer.Name")
Troubleshooting
Template Not Found When Printing
Ensure theDocumentType in your template exactly matches the DocumentType in your print requests.
Template Update Failed
- Verify JSON structure is valid
- Check that required fields are present
- Ensure element types are valid
- Review error message in the result
Template Renders Incorrectly
- Verify data source paths match your document structure
- Check width percentages for table columns
- Ensure format and align values are valid
Source Reference
- Template model:
source/Core/Models/PrintTemplate.cs:8 - Update request model:
source/Core/Models/UpdateTemplateRequest.cs:8 - Update result model:
source/Core/Models/TemplateUpdateResult.cs:6 - WebSocket handler:
source/Infraestructure/Services/WebSocketServerService.cs:463 - Event handler:
source/WorkerService/Worker.cs:37