This document defines a system based on the printer's built-in TTF font library, which achieves intelligent typesetting, text font scaling, multilingual language support (including Uygur, Mongolian, etc.), and does not require code page switching (the same invoice or label can print multiple languages simultaneously). Compared to traditional graphical printing, this system offers simpler application development, smaller communication data volume (mainly text), and meets the efficient printing needs primarily for Bluetooth and mobile networks.
The XML format-based typesetting supports two types: labels and invoices. The label format has fixed width and height, with each content element having a fixed position (including starting x and y coordinates).
Note: The description includes default value items, and the attributes may not contain the package.
Object | Attribute | Description |
---|---|---|
label | Print object type | Corresponding XML tag |
Width | Label width, Unit: mm | |
Height | Label height, Unit: mm | |
dpi | Print head resolution, Default value: 203 | |
text | Text type object | Content is UTF-8 encoded text |
x | Starting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
y | Starting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
align | Text alignment, possible values (choose one): left, center, right | |
bold | Font boldness, default is not bold: 0: not bold, 1: bold | |
font | Font size, numerical range: 8 - 100 (larger value, larger font) | |
width | Text width, automatically wraps if it exceeds the set width; unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
dir | Text layout direction: rtl: right to left, ltr: left to right | |
barcode | Barcode type object | |
x | Starting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
y | Starting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
height | Barcode height, unit: dots (dot) | |
type | Barcode type, options: BC128 PDF47 | |
hrt | Whether to display the text content: 1: Display barcode text content 0: Do not display barcode text content | |
size | ||
qrcode | QR code type object | |
x | Starting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
y | Starting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
size | Size range: 1 - 10, default value: 2 | |
ecc | Error correction level: 1: L 7% error correction 2: M 15% error correction (default value) 3: Q 25% error correction 4: H 30% error correction | |
line | Line type object | |
x | Starting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
y | Starting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
end_x | Ending position of the object, horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
end_y | Ending position of the object, vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
width | Line width | |
img | Image type object | Supports PNG, BMP raster graphics Content is an image download link or base64-encoded image data. |
x | Starting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
y | Starting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots |
Example (Label with a width of 50mm and height of 40mm):
<label width="50mm" height="40mm" copy="1" dpi="203">
<text x="10" y="20" font="24" bold="0" dir="rtl"> 拉⾯ لەغمەن</text>
<text x="10" y="60" font="16" bold="0" dir="rtl">تۇخۇ 菜 چۆپ</text>
<text x="10" y="90" font="8" bold="0" dir="rtl">8 号⼩字体 </text>
<barcode x="10" y="160" hrt="1" height="30"type="BC128">1234567890</barcode>
<qrcode x="240" y="160" size="2">123456789</qrcode>
<qrcode x="240" y="20" size="1">123456789</qrcode>
<line x="10" y="300" width="3" end_x="200\" end_y="300"></line>
<img x="10" y="200"></img>
</label>
Object | Attribute | Description |
---|---|---|
receipt | print object type | Corresponding XML tag is "receipt" (thermal small ticket) |
width | Small ticket width, unit: dots (dot), typical 58mm ticket is 384 dots, 80mm printer is 576 dots | |
font | Global font size, numerical range: 8 - 100 (larger values, larger font) | |
dir | Global text direction: rtl: right to left ltr: left to right | |
text | text type object | Content is UTF-8 encoded text, automatically wraps |
align | Text alignment, possible values (choose one): left, center, right | |
bold | Font boldness, default is not bold: 0: Not bold 1: Bold | |
font | Font size, numerical range: 8 - 100 (larger value, larger font) | |
dir | Text layout direction: rtl: Right to left ltr: Left to right | |
table | Multi-column | it can be nested to achieve various layout effects: 1.Supports two columns aligned left-right (left side aligned left, right side aligned right) 2.Supports multiple columns, automatically wraps based on column width ratio 3.Supports row element combinations: such as text and QR code / barcode, multiple QR codes / barcodes, graphics and text, graphics and QR code / barcode 4.Multi-column table with borders (under development) |
border | Whether the table has a border: 0: No border >0: With border, the border value is the width of the border line, unit: dot | |
div_line | Dashed line separator, default width is 2 | |
dir | Text layout direction: rtl: Right to left ltr: Left to right | |
font | Font size, default size is 16 | |
tr | A row in the table | tr is used to embed td and other elements (each row must contain a tr) |
td | Inline object in tr | column unit object; td can embed barcode, QR code, or img |
align | Text alignment, possible values (choose one): left, center, right | |
bold | Font boldness, default is not bold: 0: Not bold 1: Bold | |
font | Font size, numerical range: 8 - 100 (larger value, larger font) | |
width | Column width, two units: 1. Column percentage with a percentage sign 2. Absolute column width in dots Note: A single table can only use one unit. If percentage is used, all columns must use percentage. | |
barcode | barcode object | |
height | Barcode height, unit: dots (dot) | |
type | Barcode type, options: BC128 PDF47 | |
hrt | Whether to display text content: 1: Display barcode text content 0: Do not display barcode text content | |
align | Alignment, possible values (choose one): left, center, right | |
qrcode | QR code object | |
align | Alignment, possible values (choose one): left, center, right | |
ecc | Error correction level: 1: L 7% error correction 2: M 15% error correction (default value) 3: Q 25% error correction 4: H 30% error correction | |
size | 1-10 | |
img | Image object | supports PNG or BMP raster graphics Content is an image download link (URL) or base64-encoded image data. |
align | Alignment, possible values (choose one): left, center, right | |
space | blank space | height of empty blank lines, unit: dots (dot) |
line | line type object | |
x | Starting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
end_x | Ending position of the object, horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots | |
width | Line width | |
dash | Dashed line width | |
cut | cutter | automatic cut command |
Sample:
<receipt width="576" font="18">
<text font="16" align="center" bold="1"> Text Line </text>
<text font="48" align="center" bold="1"> Title Line </text>
<table>
<tr>
<td align="left"> First Column </td>
<td align="right" font="36" bold="1"> Second Column </td>
</tr>
</table>
<table>
<tr>
<td width="%30"> Title Column 1</td> <td width="%40"> Title Column 2</td>
<td width="%30"> Title Column 3</td>
</tr>
<tr><td> Content 1-1</td> <td> Content 1-2</td> <td> Content 1-3</td></tr>
<tr><td> Content 2-1</td> <td> Content 2-2</td> <td> Content 2-3</td></tr>
<tr><td> Content 3-1</td> <td> Content 3-2, Column content automatically wraps </td>
<td> Content 3-3, Column content automatically wraps </td>
</tr>
</table>
<table>
<tr>
<td width="%50"> Text and Image or Barcode side by side </td>
<td width="%50"><qrcode size="3">123456789</qrcode></td>
</tr>
</table>
<barcode type="BC128" height="30" readable="1">1234567888</barcode>
<space>20</space>
<qrcode align="left">11222222222222</qrcode>
<img></img>
<cut></cut>
</receipt>