Text2 Barcode Docs

ESC/POS Commands

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/img/logo.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>

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>
Docs