BlueGit

timfa posprint

Files

posprint / docs / HELP.md

HELP.md

HELP.md 7.3 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

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.

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.

Printers may appear as:

  • USB printer-class devices (direct bulk OUT)
  • Windows spooler queues (Windows)
  • Serial / USB-serial ports (COMx, /dev/ttyUSB0, …)

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=…

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