# Document Rendering & Print Automation v52

## Purpose
v52 separates three concerns:

1. Business source document (Sale / KDS ticket)
2. Immutable printable document snapshot
3. Hardware print job

This prevents printer state from mutating business truth.

## Structured document contract
The backend produces a device-neutral JSON contract:

- text
- key_value
- divider
- item
- kitchen_item
- json fallback

Paper profiles:
- thermal_58
- thermal_80
- a4
- digital
- label

The Local Agent will translate this neutral contract into ESC/POS, Windows Print,
ZPL/TSPL, raster, or another supported driver.

## Immutable PrintDocument
A PrintDocument contains:
- source snapshot
- rendered structured document
- revision
- SHA-256 content hash
- source identity
- optional template/version reference

PrintDocuments are immutable at the database level.

## Sale receipt
Sale receipt generation snapshots:
- sale number/date
- totals
- payment status
- customer snapshot
- immutable sale lines

Queueing a receipt creates a PrintJob through the existing routing engine.

## KDS ticket
KDS print generation snapshots the KDS delta ticket and modifiers.
It does not change KDS business state.

## Reprint
A reprint never rewrites the original PrintDocument.
It creates:
- immutable ReprintRequest
- new PrintJob referencing the original immutable document

This provides explicit auditability.

## Important invariants
- Sale success is independent of printing success.
- Send Kitchen success is independent of printer success.
- No business database is stored in the Local Agent.
- Print payload is reproducible from immutable PrintDocument snapshots.
- Reprint uses the original content hash and revision.

## Deferred to v53+
- C# Windows Local Agent
- ESC/POS Arabic rendering implementation
- Windows spooler adapter
- PNG/raster fallback rendering
- printer discovery/test print
- QR/barcode render operators
- receipt template UI/designer
- automatic event/outbox subscribers
