Introduction

Simple commands for handling esc-pos statements

<EscPos>
  <Init/>
  <QrCode>QR Test Text</QrCode>
  <Feed lines="1"/>

  <BarCode>1234567890</BarCode>
  <Feed lines="1"/>

  <PDF417>PDF417</PDF417>
  <Feed lines="1"/>

  <Text fontWidth="3" fontHeight="3">Large Text</Text>
  <Text fontWidth="2" fontHeight="2">Medium Text</Text>
  <Text fontWidth="1" fontHeight="1">Small Text</Text>
  <Feed lines="1"/>

  <Text justification="left">Left</Text>
  <Text justification="center">Center</Text>
  <Text justification="right">Right</Text>
  <Feed lines="1"/>

  <Text underline="one-dot-thick">Underline</Text>
  <Text bold="true">Bold</Text>
  <Text inverse="true">Invested</Text>
  <Feed lines="1"/>

  <Text fontWidth="2" fontHeight="2" justification="left" bold="true" underline="one-dot-thick">
    Large Text/Bold/Underline
  </Text>
  <Feed lines="3" />
  
  <Cut mode="full" />
</EscPos>

Init

Initialize printer. Clears the data in the print buffer and resets the printer.

Format

<Init/>

Parameter Value Description
width number Ticket width in millimeters
marginLeft number Left margin in millimeters
dpi "203", "300", "600" DPI to calculate the width and margin of the ticket

Example

<EscPos>
  <Init/>
</EscPos>

Text

This command is used to print text.

Format

<Text>Content</Text>

Parameter Value Description
font "A", "B", "C" font name
fontWidth [1-8] char width
fontHeight [1-8] char height
justification "left", "center" or "right" Set horizontal justification
underline "one-dot-thick", "two-dot-thick", "none" Underline
lineSpacing [0-255] Set line spacing
doubleStrike true or false Double Strike
bold true or false Bold
inverse true or false Reversed
lf true or false Activate or deactivate the line break at the end of the text

Example

<EscPos>
    <Text
        font="A"
        fontWidth="1" 
        fontHeight="1" 
        justification="left"
        underline="none"
        lineSpacing="0"
        doubleStrike="true" 
        bold="true" 
        inverse="true" 
        lf="true"
    >
        Hola Mundo
    </Text>
</EscPos>

QRCode

This command prints a QR code.

Format

<QrCode>Content</QrCode>

Attributes Value Description
model "1" or "2" QRCode model
errorCorrectionLevel "L", "Q", "H" or "M" QR Error Correction Level
size [1-16] Set the size of module in dots
justification "left", "center" or "right" Set horizontal justification

Example

<EscPos>
    <QrCode 
        model="1" 
        errorCorrectionLevel="M" 
        size="3" 
        justification="left"
    >
        1234567890
    </QrCode>
</EscPos>

RESULT

BarCode

This command prints a Barcode code.

Format

<BarCode>Content</BarCode>

Parameter Value Description
type "upca", "upca_b", "upce_a", "upce_b", "jan13_a", "jan13_b", "jan8_a", "jan8_b", "code39_a", "code39_b", "itf_a", "itf_b", "codabar_a", "codabar_b", "code93_default", "code128" Provide bar-code system
width [2-6] Code width
height [1-255] Code height
hriPosition "above-bar-code", "below-bar-code", "above-and-below-bar-code", "not-printed" Human Readable Interpretation (HRI) position
hriFont "A", "B", "C" Human Readable Interpretation (HRI) font
justification "left", "center" or "right" Set horizontal justification

Example

<EscPos>
    <BarCode 
        type="code128" 
        width="2" 
        height="40" 
        hriPosition="below-bar-code" 
        hriFont="A" 
        justification="left"
    >
        1234567890
    </BarCode>
</EscPos>

RESULT

PDF417

This command is used to print a PDF code.

Format

<PDF417>Content</PDF417>

Parameter Value Description
option "truncated", "standard" PDF417 Option
errorCorrectionLevel [0-8] PDF417 Correction Level
width [3-5] Code width
height [2-8] Code height
numberOfColumns number Set the number of columns in the data region
numberOfRows number Set the number of rows
justification "left", "center" or "right" Set horizontal justification

Example

<EscPos>
  <PDF417
      option="standard"
      errorCorrectionLevel="1" 
      width="3"
      height="4"
      numberOfColumns="0"
      numberOfRows="0"
      justification="left"
  >
      1234567890
  </PDF417>
</EscPos>

RESULT

Image

This command prints a QR code.

Format

<Image/>

Attributes Value Description
uri "http", "https", "file" Identificador Uniforme de Recursos
base64 "string" Image content in base64 format
width number Image width
height number Image height
justification "left", "center" or "right" Set horizontal justification
filter "dither" or "monochrome" default:"dither" Filter for the image
threshold [0-255] default:127 Threshold for gray scale

Example

<EscPos>
    <Image 
        uri="https://labeldictate.com/text2barcode/docs/static/img/t2b.png" 
        width="500" 
    />
</EscPos>

RESULT

Feed

Prints the data in the print buffer and feeds n lines.

Format

<Feed/>

Parameter Value Description
lines number number of lines

Example

<EscPos>
  <Feed lines="1" />
</EscPos>

Cut

This command is used to set the cut to the printer.

Format

<Cut/>

Parameter Value Description
mode "part", "full" paper cutting

Example

<EscPos>
  <Cut mode="full" />
</EscPos>

CharacterCodeTable

Selecciona la tabla de caracteres (code page) de la impresora.

Format

<CharacterCodeTable value="ENUM_NAME"/>

Value Description
CP437_USA_Standard_EuropeUSA / Standard Europe (Code Page 437)
KatakanaKatakana (Japanese)
CP850_MultilingualMultilingual Latin-1 (Code Page 850)
CP860_PortuguesePortuguese (Code Page 860)
CP863_Canadian_FrenchCanadian French (Code Page 863)
CP865_NordicNordic (Code Page 865)
CP851_GreekGreek (Code Page 851)
CP853_TurkishTurkish (Code Page 853)
CP857_TurkishTurkish (Code Page 857)
CP737_GreekGreek (Code Page 737)
ISO8859_7_GreekISO-8859-7 Greek
WPC1252Windows Latin-1 (Western Europe, CP1252)
CP866_Cyrillic_2Cyrillic #2 (Code Page 866)
CP852_Latin2Latin-2 (Central Europe, CP852)
CP858_EuroMultilingual + Euro symbol (CP858)
KU42_ThaiThai (KU42)
TIS11_ThaiThai (TIS11)
TIS18_ThaiThai (TIS18)
TCVN_3_1_VietnameseVietnamese (TCVN 3.1)
TCVN_3_2_VietnameseVietnamese (TCVN 3.2)
PC720_ArabicArabic (PC720)
WPC775_BalticRimBaltic Rim (Windows CP775)
CP855_CyrillicCyrillic (Code Page 855)
CP861_IcelandicIcelandic (Code Page 861)
CP862_HebrewHebrew (Code Page 862)
CP864_ArabicArabic (Code Page 864)
CP869_GreekGreek (Code Page 869)
ISO8859_2_Latin2ISO-8859-2 Latin-2
ISO8859_15_Latin9ISO-8859-15 Latin-9 (Euro update)
CP1098_FarsiFarsi / Persian (Code Page 1098)
CP1118_LithuanianLithuanian (Code Page 1118)
CP1119_LithuanianLithuanian (Code Page 1119)
CP1125_UkrainianUkrainian (Code Page 1125)
WCP1250_Latin2Windows Latin-2 (CP1250)
WCP1251_CyrillicWindows Cyrillic (CP1251)
WCP1253_GreekWindows Greek (CP1253)
WCP1254_TurkishWindows Turkish (CP1254)
WCP1255_HebrewWindows Hebrew (CP1255)
WCP1256_ArabicWindows Arabic (CP1256)
WCP1257_BalticRimWindows Baltic (CP1257)
WCP1258_VietnameseWindows Vietnamese (CP1258)
KZ_1048_KazakhstanKazakhstan (KZ-1048)
User_defined_pageUser defined character page
Tip: Para acentos y “€” en la mayoría de Epson/compatibles, usa WPC1252. En hardware que requiera “€” con PC858, usa CP858_Euro.

Example

<EscPos>
  <Init/>
  <CharacterCodeTable value="WPC1252"/>
  <Text>á é í ó ú ñ Ñ €</Text>
  <Feed lines="1"/>
  <Cut mode="part" />
</EscPos>

CharacterSetExtensionMode

Configura el modo de extensión del juego de caracteres mediante el comando FS 2E n internamente. Este nodo solo acepta nombres de enum definidos en EscPos.CharacterSetExtensionMode.

Format

<CharacterSetExtensionMode value="ENUM_NAME"/>

Value Description
NORMALModo estándar sin extensión especial.
COMPATIBLEModo de compatibilidad con juegos de caracteres ampliados.
WECHATModo especial utilizado en firmware chino (impresoras WeChat).
Nota: El significado exacto de cada modo puede variar según el fabricante/firmware de la impresora.

Example

<EscPos>
  <Init/>
  <CharacterCodeTable value="WPC1252"/>
  <CharacterSetExtensionMode value="NORMAL"/>
  <Text>á é í ó ú ñ Ñ €</Text>
  <Feed lines="1"/>
  <Cut mode="full" />
</EscPos>

Bytes

command to write bytes, each byte must be separated by a comma.

Format

String with hexadecimal pairs separated by spaces

Example

<EscPos>
    <!-- Initialize printer - ESC @ -->
    <Bytes>1B 40</Bytes> <!-- Hex -->

    <!-- Print "Hello World" - Text data -->
    <Bytes>48 65 6C 6C 6F 20 57 6F 72 6C 64</Bytes> <!-- Hex for "Hello World" -->

    <!-- Two Line Feeds - LF -->
    <Bytes>0A 0A</Bytes> <!-- Hex for two line feeds -->

    <!-- Cut Paper - GS V 49 -->
    <Bytes>1D 56 31</Bytes> <!-- Hex -->
</EscPos>
ESC/POS Documentation