XML Format-Based Typesetting and Mass Printing Guide (1.4)

Update: March 20, 2025
By Han
Table of Contents

1. Description

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).

2. Labels (XML Object and Attribute Description)

Note: The description includes default value items, and the attributes may not contain the package.

ObjectAttributeDescription
labelPrint object typeCorresponding XML tag
WidthLabel width, Unit: mm
HeightLabel height, Unit: mm
dpiPrint head resolution, Default value: 203
textText type objectContent is UTF-8 encoded text
xStarting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
yStarting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
alignText alignment, possible values (choose one): left, center, right
boldFont boldness, default is not bold:
0: not bold,
1: bold
fontFont size, numerical range: 8 - 100 (larger value, larger font)
widthText width, automatically wraps if it exceeds the set width; unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
dirText layout direction:
rtl: right to left,
ltr: left to right
barcodeBarcode type object
xStarting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
yStarting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
heightBarcode height, unit: dots (dot)
typeBarcode type, options:
BC128
PDF47
hrtWhether to display the text content:
1: Display barcode text content
0: Do not display barcode text content
size
qrcodeQR code type object
xStarting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
yStarting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
sizeSize range: 1 - 10, default value: 2
eccError correction level:
1: L 7% error correction
2: M 15% error correction (default value)
3: Q 25% error correction
4: H 30% error correction
lineLine type object
xStarting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
yStarting position of the object (top-left corner), vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
end_xEnding position of the object, horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
end_yEnding position of the object, vertical coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
widthLine width
imgImage type objectSupports PNG, BMP raster graphics
Content is an image download link or base64-encoded image data.
xStarting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
yStarting 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>

3.Invoices (XML Object and Attribute Description)

ObjectAttributeDescription
receiptprint object typeCorresponding XML tag is "receipt" (thermal small ticket)
widthSmall ticket width, unit: dots (dot), typical 58mm ticket is 384 dots, 80mm printer is 576 dots
fontGlobal font size, numerical range: 8 - 100 (larger values, larger font)
dirGlobal text direction:
rtl: right to left
ltr: left to right
texttext type objectContent is UTF-8 encoded text, automatically wraps
alignText alignment, possible values (choose one): left, center, right
boldFont boldness, default is not bold:
0: Not bold
1: Bold
fontFont size, numerical range: 8 - 100 (larger value, larger font)
dirText layout direction:
rtl: Right to left
ltr: Left to right
tableMulti-columnit 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)
borderWhether the table has a border:
0: No border
>0: With border, the border value is the width of the border line, unit: dot
div_lineDashed line separator, default width is 2
dirText layout direction:
rtl: Right to left
ltr: Left to right
fontFont size, default size is 16
trA row in the tabletr is used to embed td and other elements (each row must contain a tr)
tdInline object in trcolumn unit object; td can embed barcode, QR code, or img
alignText alignment, possible values (choose one): left, center, right
boldFont boldness, default is not bold:
0: Not bold
1: Bold
fontFont size, numerical range: 8 - 100 (larger value, larger font)
widthColumn 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.
barcodebarcode object
heightBarcode height, unit: dots (dot)
typeBarcode type, options:
BC128
PDF47
hrtWhether to display text content:
1: Display barcode text content
0: Do not display barcode text content
alignAlignment, possible values (choose one): left, center, right
qrcodeQR code object
alignAlignment, possible values (choose one): left, center, right
eccError correction level:
1: L 7% error correction
2: M 15% error correction (default value)
3: Q 25% error correction
4: H 30% error correction
size1-10
imgImage objectsupports PNG or BMP raster graphics
Content is an image download link (URL) or base64-encoded image data.
alignAlignment, possible values (choose one): left, center, right
spaceblank spaceheight of empty blank lines, unit: dots (dot)
lineline type object
xStarting position of the object (top-left corner), horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
end_xEnding position of the object, horizontal coordinate, unit: dots (dot), for a 203 DPI printer, 1mm = 8 dots
widthLine width
dashDashed line width
cutcutterautomatic 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>

Please Share:

Found this blog helpful? Share it with your friends! Your support means the world to us. Thank you!
meme-425x425
Article by
Han
Han is a Operations and Marketing Specialist at LOYALTY-SECU. 
With extensive expertise in wireless printing technology, cloud solutions, innovative product development, and Bluetooth module integration, I am dedicated to sharing company insights and industry knowledge to deliver unmatched value to our audience.

LOYALTY-SECU Is Dedicated to Delivering Top-quality, Efficient Printing Solutions to Customers Worldwide.

R&D Oriented Cloud Printing Solution Manufacturer
logo
+86-159-8684-8905
sales@loyalty-secu.com
Rm 216, Tian Hui Bldg., A Tower, No 29 Yeqin 1st Road, Longcheng Street, Longgang District 518172, Shenzhen, China.
Follow us on:
Copyright 2024 LOYALTY-SECU Electronics Co., LTD All Rights Reserved.
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram