Print Documents
Portable receipt primitives, limits, rendering, and Unicode strategy.
A print job contains a structured document rather than a remote script or local file path.
const document = {
width: 80,
sections: [
{
type: 'text',
value: 'Test Receipt',
align: 'center',
bold: true,
},
{
type: 'row',
left: 'Total',
right: 'NPR 1,250.00',
},
{ type: 'divider' },
{ type: 'qr', value: 'https://example.com/receipt/123' },
{ type: 'feed', lines: 3 },
{ type: 'cut' },
],
} as const;Version 1 defines text, row, divider, image, QR code, barcode, feed, and cut sections. Documents use a 58 mm or 80 mm target width.
Validation
The protocol bounds total message size, section count, text length, decoded image bytes, feed lines, and barcode or QR values. A printer ID must refer to a locally registered enabled printer.
Rendering
oppa-renderer owns layout, wrapping, alignment, and conversion into
an output representation:
- ESC/POS bytes for compatible receipt printers
- structured virtual output for development inspection
oppa-spooler owns submission. Keeping the two boundaries separate
makes it possible to test layout without printer hardware and to
reject an output format unsupported by a target transport. PDF
documents use the same boundary: the renderer validates and rasterizes
them, and the spooler chooses the submission route.
PDF documents
PDF jobs require an agent that negotiated protocol version 2. Agents that only speak the base protocol still receive receipts. See Protocol.
A job can reference a PDF instead of a receipt. The job's document
member is a PDF when it has a format value of "pdf"; receipts keep
their original shape.
const document = {
format: 'pdf',
source: {
type: 'url',
url: 'https://documents.example.com/v1/documents/label-123',
sha256: '9f2c7e1a…', // lowercase hex digest of the exact bytes
byteLength: 48213,
},
settings: {
copies: 2,
paper: { widthMm: 50, heightMm: 30 }, // or 'a4', 'a5', 'letter', 'legal'
orientation: 'landscape',
scaling: 'fit', // or 'actual', or { percent: 80 }
pageRanges: '1-2,4',
duplex: 'simplex', // or 'long-edge', 'short-edge'
},
} as const;PDF bytes never travel inside a protocol message. The agent retrieves them over HTTPS with its own signed request, verifies the declared length and digest, and only then renders them. Plain HTTP is accepted only for loopback development hosts. See Protocol for the retrieval and signature contract.
Routes
| Printer route | How the PDF is submitted | Duplex |
|---|---|---|
| CUPS queue (macOS and Linux) | Native lp submission. CUPS filters the PDF and applies copies, media, orientation, sides, page ranges, and scaling. | Only when the queue offers it |
| Windows queue | OPPA rasterizes the selected pages and sends them through the existing GDI path. | Not supported; the job fails with document.option_unsupported |
| Virtual office printer | OPPA rasterizes pages for the inspector. | Not applicable |
Receipt-only printers, including raw ESC/POS network printers, reject
PDF jobs with document.format_unsupported. Route a PDF to a
driver-mode printer instead.
Settings and defaults
copies: 1 to 99. Defaults to 1.paper: a standard size or custom millimetres from 10 to 1000, for label stock. Defaults to each page's own size.orientation:portraitorlandscape. Defaults to the document's own orientation.scaling:actual(default),fit(shrink to fit, never enlarge), or{ percent }from 10 to 400.pageRanges: for example1-3,5. Ranges must ascend and start at 1. Defaults to every page.duplex: defaults tosimplex.
Limits
PDFs are capped at 20 MB, 2,000 pages in the source document, 200 output pages after copies, and 42 million pixels per rendered page. Rasterized output is capped at 64 MiB. Encrypted files are rejected because OPPA cannot ask for a password. The renderer parses files with a pure-Rust engine, so no native PDF library has to be installed for rasterization.
Platform requirements
- macOS: CUPS is part of the operating system.
- Linux: install CUPS with its PDF filters (
cups-filters). Without them,lpcannot convert PDFs and the job fails with the CUPS error. - Windows: no additional runtime is required; pages are rasterized inside OPPA.
Unicode
ESC/POS code pages are not a reliable universal Unicode solution. In particular, Nepali text needs proper shaping and glyph coverage. The current ESC/POS renderer returns an explicit unsupported error for non-ASCII text rather than pretending arbitrary UTF-8 bytes will print correctly. A future raster text renderer can add reliable shaping without changing the structured wire document; the virtual renderer already preserves Unicode for local inspection.