BlueGit

timfa posprint

Files

posprint / docs / HELP.md

HELP.md

HELP.md 8.1 KiB Download Raw

posprint Help

Built-in reference for the template editor and POS markup language.

---

Application tabs

TabPurpose
DesignSide-by-side template editor and live preview
HelpThis documentation
SettingsDefault page width for new documents; trusted sites for noconfirm

Toolbar actions

ActionDescription
NewEmpty template with defaults
OpenLoad a .pos file
Save / Save AsWrite .pos file (metadata + body)
InsertImages, barcodes, QR, date/time, parameters, @feed, @cut
PrintEnter parameters, pick a printer, send ESC/POS bytes

While the Print dialog is open, the rest of the UI (including editor autocomplete) is disabled so parameter fields keep focus.

Print-only mode (posprint --print, Explorer Print, or a posprint:// link) shows a live preview on the left and parameters / printer controls on the right. The preview updates as you type parameter values.

Editor assistance

  • Type @ at the start of a line for directive autocomplete (feed, cut, image, barcode, qr, date, time).
  • Use Insert → Barcode / QR code to pick native or raster type before inserting a snippet.

Page settings

SettingDescription
Page width (mm)Paper width — match your physical roll (e.g. 53, 58, 80)
Preview zoomScreen zoom; 100% is calibrated to typical receipt width on screen

Preview width and text use the same calibrated screen scale. Preview font size is bumped to match printed Font A. Blank lines / @feed use the same line spacing as printed text. Heading # uses double width/height like GS ! on the printer; ## uses bold only.

If the document does not end with @cut (ignoring blank lines after it), a red warning appears next to Help.

---

Template language

A template is plain text: paragraphs, headings, lists, checkboxes, ${text} / $[bool] parameters, and directives. There is no inline bold/italic/code markup — asterisks and backticks print literally.

Paragraphs

Consecutive non-empty lines form one paragraph. Multiple spaces in a row are kept (useful for manual column layout), including spaces at the start of a line. Trailing spaces on a line are ignored.

Headings

# Large heading
## Bold heading

Alignment

:left:, :center:, or :right: before a paragraph.

Bullet lists

- Groceries
  - Milk
  - Eggs
- Wash car

Indent with two spaces (or a tab) per nesting level. Top-level items print as * ; nested items print as - with the same hanging wrap.

* Groceries
  - Milk
  - Eggs
* Wash car

Long items wrap with a hanging indent:

* this is a
  long line
  - nested item that
    wraps too

Parameters

SyntaxEffect
${Name}Text parameter (filled at print time)
$[Name]Checkbox parameter → [ ] or [x]

${Name} and $[Name] must not share the same name.

Checkboxes

Inline checkboxes print as ASCII so they stay in the printer’s CP437 font (Unicode ☐ / √ often become CJK garbage):

SyntaxResult
[] or [ ][ ]
[x] or [X][x]
[] Unchecked
[ ] Also unchecked
[x] Done
$[Paid]

$[Paid] is a parameter: in the Print dialog it is a true/false checkbox; on the receipt it becomes [ ] or [x]. CLI: --set Paid=true.

Horizontal rule

---

Comments

<!-- not printed -->

---

Directives

Directives start with @ at the beginning of a line.

Paper feed / cut

@feed 3
@cut

Blank lines in the editor also feed one line (same as @feed 1).

Date / time

@date
@date DD-MM-YYYY
@time
@time 12h
@time 24h
  • @date with no pattern uses the system regional short date.
  • Custom patterns use tokens such as YYYY, MM, DD.
  • @time defaults to 24-hour; use 12h or 24h.

Image

@image logo.png
@image https://example.com/logo.png width=50%
@image ${LogoPath} width=50% align=center

Local paths resolve relative to the .pos file. http:// and https:// URLs are downloaded when preview or print needs the image.

Barcode

Native (printer draws barcode via ESC/POS):

@barcode CODE128 ${OrderId}
@barcode UPC-A 012345678905
@barcode ITF 12345678 height=80

Raster (bitmap). Raster barcodes stretch horizontally to full paper width; height follows height.

@barcode RASTER CODE128 ${OrderId}
@barcode RASTER CODE93 ABC-1234
Native symbologyNotes
CODE128Alphanumeric
EAN13, EAN8Numeric
CODE39Alphanumeric
UPC-A, UPC-ENumeric
ITFInterleaved 2 of 5; even digit count
CODABARNumeric + A-D start/stop
Raster-onlyUse RASTER prefix
CODE93, CODE11No native ESC/POS in firmware
AttributeDescription
heightHeight in dots (default 64)
alignleft, center, right
show_textNative only: human-readable text under barcode

QR code

Native (ESC/POS QR, model 2):

@qr https://example.com/${Id}
@qr ${Url} size=6 ecc=H align=center

Raster (bitmap; QR versions 1–40):

@qr RASTER https://example.com/${Id}
@qr RASTER ${Url} version=5 scale=4 ecc=M
AttributeNativeRaster
sizeModule dot size 1–16—
scale—Pixels per module (default 4)
version—QR version 1–40 (optional)
eccL, M, Q, HSame
alignleft, center, rightSame

---

Parameters

FormTypePrint dialogCLI
${Name}texttext field--set Name=Value
$[Name]boolcheckbox--set Name=true / false (also 1/0, yes/no)
  • Same name must not appear as both ${…} and $[…].
  • GUI and CLI require every parameter; bools default to unchecked (false) in the dialog.
  • Usable in text; ${…} also in barcode/QR/image paths ($[…] is text-inline only).
# ${StoreName}

$[Paid] Paid in full
[] Pending review

Receipt: ${DocumentNumber}

---

Example receipt

# ${StoreName}
:center:

Receipt: ${DocumentNumber}
@date
@time

@barcode CODE128 ${DocumentNumber}
@qr RASTER https://shop.example.com/r/${DocumentNumber} scale=4

@feed 4
@cut

---

GUI printing

1. Print → enter parameters → choose a printer → Print (next to Refresh). Close with the window ✕.

Printers may appear as:

  • USB printer-class devices (direct bulk OUT)
  • Windows spooler queues (Windows)
  • USB-serial ports with a device attached (COMx, /dev/ttyUSB0, /dev/ttyACM0, …)

Empty motherboard serial ports (common on Linux as /dev/ttyS*) are hidden. Use Enter port or queue manually if you need one of those.

Linux serial: join the dialout group.

---

CLI

posprint print receipt.pos -p COM3 --set StoreName=Shop
posprint link receipt.pos
posprint cli-help

-p accepts a serial port name, USB device label from discovery, or (on Windows) a spooler queue name. See platform CLI help via posprint cli-help.

posprint link prints a posprint:// deep link for the file (see POSPRINT-URL.md).

---

posprint:// links

Websites can open the print dialog with an embedded template:

posprint://print?v=1&d=…

Add &noconfirm=1&referrer=<percent-encoded verify URL> to print after the site’s verify endpoint returns HTTP 200 and (on first use) the user trusts that domain (Settings → Trusted sites). Auto-print uses the last printer that printed successfully when that device is still available. Encoding helpers live in lib/. Full guide: POSPRINT-URL.md.

@image may use https://… or http://… (downloaded when preview/print needs the image).

---

.pos file format

JSON with version, metadata, and body (template source). See FILE-FORMAT.md.

Source
1# posprint Help
2
3Built-in reference for the template editor and POS markup language.
4
5---
6
7## Application tabs
8
9| Tab | Purpose |
10|-----|---------|
11| **Design** | Side-by-side template editor and live preview |
12| **Help** | This documentation |
13| **Settings** | Default page width for new documents; trusted sites for `noconfirm` |
14
15## Toolbar actions
16
17| Action | Description |
18|--------|-------------|
19| **New** | Empty template with defaults |
20| **Open** | Load a `.pos` file |
21| **Save / Save As** | Write `.pos` file (metadata + body) |
22| **Insert** | Images, barcodes, QR, date/time, parameters, `@feed`, `@cut` |
23| **Print** | Enter parameters, pick a printer, send ESC/POS bytes |
24
25While the Print dialog is open, the rest of the UI (including editor autocomplete) is disabled so parameter fields keep focus.
26
27**Print-only mode** (`posprint --print`, Explorer Print, or a `posprint://` link) shows a live preview on the left and parameters / printer controls on the right. The preview updates as you type parameter values.
28
29## Editor assistance
30
31- Type `@` at the start of a line for **directive autocomplete** (`feed`, `cut`, `image`, `barcode`, `qr`, `date`, `time`).
32- Use **Insert → Barcode / QR code** to pick native or raster type before inserting a snippet.
33
34## Page settings
35
36| Setting | Description |
37|---------|-------------|
38| **Page width (mm)** | Paper width — match your physical roll (e.g. `53`, `58`, `80`) |
39| **Preview zoom** | Screen zoom; `100%` is calibrated to typical receipt width on screen |
40
41Preview width and text use the same calibrated screen scale. Preview font size is bumped to match printed Font A. Blank lines / `@feed` use the same line spacing as printed text. Heading `#` uses double width/height like GS `!` on the printer; `##` uses bold only.
42
43If the document does not end with `@cut` (ignoring blank lines after it), a red warning appears next to **Help**.
44
45---
46
47## Template language
48
49A template is plain text: paragraphs, headings, lists, checkboxes, `${text}` / `$[bool]` parameters, and directives. There is **no** inline bold/italic/code markup — asterisks and backticks print literally.
50
51### Paragraphs
52
53Consecutive non-empty lines form one paragraph. Multiple spaces in a row are kept (useful for manual column layout), including spaces at the start of a line. Trailing spaces on a line are ignored.
54
55### Headings
56
57```markdown
58# Large heading
59## Bold heading
60```
61
62### Alignment
63
64`:left:`, `:center:`, or `:right:` before a paragraph.
65
66### Bullet lists
67
68```markdown
69- Groceries
70 - Milk
71 - Eggs
72- Wash car
73```
74
75Indent with two spaces (or a tab) per nesting level. Top-level items print as `* `; nested items print as `- ` with the same hanging wrap.
76
77```text
78* Groceries
79 - Milk
80 - Eggs
81* Wash car
82```
83
84Long items wrap with a hanging indent:
85
86```text
87* this is a
88 long line
89 - nested item that
90 wraps too
91```
92
93### Parameters
94
95| Syntax | Effect |
96|--------|--------|
97| `${Name}` | Text parameter (filled at print time) |
98| `$[Name]` | Checkbox parameter → `[ ]` or `[x]` |
99
100`${Name}` and `$[Name]` must not share the same name.
101
102### Checkboxes
103
104Inline checkboxes print as ASCII so they stay in the printer’s CP437 font (Unicode ☐ / √ often become CJK garbage):
105
106| Syntax | Result |
107|--------|--------|
108| `[]` or `[ ]` | `[ ]` |
109| `[x]` or `[X]` | `[x]` |
110
111```markdown
112[] Unchecked
113[ ] Also unchecked
114[x] Done
115$[Paid]
116```
117
118`$[Paid]` is a **parameter**: in the Print dialog it is a true/false checkbox; on the receipt it becomes `[ ]` or `[x]`. CLI: `--set Paid=true`.
119
120### Horizontal rule
121
122```markdown
123---
124```
125
126### Comments
127
128```markdown
129<!-- not printed -->
130```
131
132---
133
134## Directives
135
136Directives start with `@` at the beginning of a line.
137
138### Paper feed / cut
139
140```markdown
141@feed 3
142@cut
143```
144
145Blank lines in the editor also feed one line (same as `@feed 1`).
146
147### Date / time
148
149```markdown
150@date
151@date DD-MM-YYYY
152@time
153@time 12h
154@time 24h
155```
156
157- `@date` with no pattern uses the system regional short date.
158- Custom patterns use tokens such as `YYYY`, `MM`, `DD`.
159- `@time` defaults to 24-hour; use `12h` or `24h`.
160
161### Image
162
163```markdown
164@image logo.png
165@image https://example.com/logo.png width=50%
166@image ${LogoPath} width=50% align=center
167```
168
169Local paths resolve relative to the `.pos` file. `http://` and `https://` URLs are downloaded when preview or print needs the image.
170
171### Barcode
172
173**Native** (printer draws barcode via ESC/POS):
174
175```markdown
176@barcode CODE128 ${OrderId}
177@barcode UPC-A 012345678905
178@barcode ITF 12345678 height=80
179```
180
181**Raster** (bitmap). Raster barcodes stretch horizontally to full paper width; height follows `height`.
182
183```markdown
184@barcode RASTER CODE128 ${OrderId}
185@barcode RASTER CODE93 ABC-1234
186```
187
188| Native symbology | Notes |
189|----------------|-------|
190| `CODE128` | Alphanumeric |
191| `EAN13`, `EAN8` | Numeric |
192| `CODE39` | Alphanumeric |
193| `UPC-A`, `UPC-E` | Numeric |
194| `ITF` | Interleaved 2 of 5; even digit count |
195| `CODABAR` | Numeric + A-D start/stop |
196
197| Raster-only | Use `RASTER` prefix |
198|-------------|---------------------|
199| `CODE93`, `CODE11` | No native ESC/POS in firmware |
200
201| Attribute | Description |
202|-----------|-------------|
203| `height` | Height in dots (default `64`) |
204| `align` | `left`, `center`, `right` |
205| `show_text` | Native only: human-readable text under barcode |
206
207### QR code
208
209**Native** (ESC/POS QR, model 2):
210
211```markdown
212@qr https://example.com/${Id}
213@qr ${Url} size=6 ecc=H align=center
214```
215
216**Raster** (bitmap; QR versions 1–40):
217
218```markdown
219@qr RASTER https://example.com/${Id}
220@qr RASTER ${Url} version=5 scale=4 ecc=M
221```
222
223| Attribute | Native | Raster |
224|-----------|--------|--------|
225| `size` | Module dot size 1–16 | — |
226| `scale` | — | Pixels per module (default `4`) |
227| `version` | — | QR version 1–40 (optional) |
228| `ecc` | `L`, `M`, `Q`, `H` | Same |
229| `align` | `left`, `center`, `right` | Same |
230
231---
232
233## Parameters
234
235| Form | Type | Print dialog | CLI |
236|------|------|--------------|-----|
237| `${Name}` | text | text field | `--set Name=Value` |
238| `$[Name]` | bool | checkbox | `--set Name=true` / `false` (also `1`/`0`, `yes`/`no`) |
239
240- Same name must not appear as both `${…}` and `$[…]`.
241- GUI and CLI require **every** parameter; bools default to unchecked (`false`) in the dialog.
242- Usable in text; `${…}` also in barcode/QR/image paths (`$[…]` is text-inline only).
243
244```markdown
245# ${StoreName}
246
247$[Paid] Paid in full
248[] Pending review
249
250Receipt: ${DocumentNumber}
251```
252
253---
254
255## Example receipt
256
257```markdown
258# ${StoreName}
259:center:
260
261Receipt: ${DocumentNumber}
262@date
263@time
264
265@barcode CODE128 ${DocumentNumber}
266@qr RASTER https://shop.example.com/r/${DocumentNumber} scale=4
267
268@feed 4
269@cut
270```
271
272---
273
274## GUI printing
275
2761. **Print** → enter parameters → choose a printer → **Print** (next to Refresh). Close with the window ✕.
277
278Printers may appear as:
279
280- **USB printer-class** devices (direct bulk OUT)
281- **Windows spooler** queues (Windows)
282- **USB-serial** ports with a device attached (`COMx`, `/dev/ttyUSB0`, `/dev/ttyACM0`, …)
283
284Empty motherboard serial ports (common on Linux as `/dev/ttyS*`) are hidden. Use **Enter port or queue manually** if you need one of those.
285
286**Linux serial:** join the `dialout` group.
287
288---
289
290## CLI
291
292```bash
293posprint print receipt.pos -p COM3 --set StoreName=Shop
294posprint link receipt.pos
295posprint cli-help
296```
297
298`-p` accepts a serial port name, USB device label from discovery, or (on Windows) a spooler queue name. See platform CLI help via `posprint cli-help`.
299
300`posprint link` prints a `posprint://` deep link for the file (see [POSPRINT-URL.md](POSPRINT-URL.md)).
301
302---
303
304## posprint:// links
305
306Websites can open the print dialog with an embedded template:
307
308```
309posprint://print?v=1&d=…
310```
311
312Add `&noconfirm=1&referrer=<percent-encoded verify URL>` to print after the site’s verify endpoint returns HTTP 200 and (on first use) the user trusts that domain (**Settings → Trusted sites**). Auto-print uses the last printer that printed successfully when that device is still available. Encoding helpers live in [`lib/`](../lib/). Full guide: [POSPRINT-URL.md](POSPRINT-URL.md).
313
314`@image` may use `https://…` or `http://…` (downloaded when preview/print needs the image).
315
316---
317
318## `.pos` file format
319
320JSON with `version`, `metadata`, and `body` (template source). See [FILE-FORMAT.md](FILE-FORMAT.md).