# Thermal vs Standard Print Layouts

## Overview

The CG Mobile print layout engine supports two printer targets. The choice is made at layout
design time and is reflected in the `pageMargins` / `pageSize` attributes and which layout
features are used.

---

## Comparison Table

| Feature                 | Standard (PDF)             | Thermal (3-inch receipt)                              |
| ----------------------- | -------------------------- | ----------------------------------------------------- |
| `pageSize`              | `[595, 842]` (A4 portrait) | `[216, auto]` (continuous roll)                       |
| `pageMargins`           | `[40,40,40,40]` (required) | **Omit** — `pageMargins` is not supported on thermal  |
| `<header>` / `<footer>` | Supported                  | Not supported                                         |
| `<pageNumber/>`         | Supported                  | Not supported                                         |
| Image in tables         | Yes (via `rowSpan`)        | No                                                    |
| `<lineFeed/>`           | Not used                   | Used for vertical spacing                             |
| `<rule/>`               | Not used                   | Single horizontal rule (no consecutive `<rule>` rows) |
| Column alignment        | left, center, right        | left and right only                                   |
| Min column width        | None enforced              | 20% minimum recommended                               |
| Protocol                | PDF rendering              | ESC/POS @ 203 DPI                                     |
| Table borders           | Any `tableLayout`          | `noBorders` preferred                                 |

---

## Standard PDF

Standard layouts target A4 paper and produce a PDF file.

All 11 layouts in `src/Order/PL/` use the standard format:

```xml
<ReportLayout pageMargins="[40,40,40,40]">
```

No `pageSize` attribute is set in any real file in the codebase — the default page size is
applied by the renderer. The wiki documents `[595, 842]` as the A4 default.

**Detection heuristic:** `pageMargins` is present → standard PDF layout.

---

## Thermal Receipt

Thermal layouts target ESC/POS 3-inch (80 mm) receipt printers. The effective printable width
is approximately 216 points.

**No thermal print layout exists in `src/Order/PL/` or anywhere else in
`src/`.** The thermal template in this skill is derived
from `ai-wiki/wiki/print-layouts.md` patterns and the framework's documented validation rules.

Key constraints for thermal:

1. Do not include `pageMargins` — the validator rejects it
2. Do not use `<header>`, `<footer>`, or `<pageNumber/>`
3. Keep tables narrow — all column widths must be percentage-based totaling 100%
4. Use `<lineFeed/>` for vertical spacing between sections
5. Use `<rule/>` for separator lines; do not place two consecutive `<rule>` elements
6. No images inside or spanning `<td>` cells
7. Use `tableLayout="noBorders"` for receipt-style tables

---

## When to Choose Each Format

| Use case                               | Format       |
| -------------------------------------- | ------------ |
| Contract, order confirmation, invoice  | Standard PDF |
| Sales receipt for van sales / POS      | Thermal      |
| Detailed multi-page report             | Standard PDF |
| Quick acknowledgment (field-printable) | Thermal      |

---

## PRINTV2 Action — Selecting the Layout at Runtime

The process action passes a `printId` that selects which `<PrintLayout name="...">` to render.
Business logic determines the correct layout name based on the order type or context:

```xml
<Action name="PrintDoc" actionType="PRINTV2"
        printId="ProcessContext::PrintLayoutId"
        locale="ApplicationContext::user.languageSpoken">
  <Parameters>
    <Input name="order" value="ProcessContext::MainBO" />
  </Parameters>
</Action>
```

The BL method that sets `ProcessContext::PrintLayoutId` decides whether to use, for example,
`"VanSalesCashInvoicePDF"` (standard) or a thermal receipt layout based on the printer
capability or order category.
