Barcode InfoPCL FontsHome


JetCAPS BarDIMM Barcode Module Programming Information
Home > Barcode Basics > Application Notes > AppNote027

Escape Sequences
The BarSIMM Escape Sequence
Parameters for the BarSIMM Escape Sequence
        table with available barcode types as of Software Revision 1.8E
Default Parameters
        table of default settings for BarSIMM escape parameters
Code 128 Control Codes
Barcode Rotation
Microsoft Windows
HEWLETT-PACKARD Barcodes & More Font Cartridge
U.S. Postal Service 'ZEBRA STRIPES'
Error Messages
UPS Maxicode


Hewlett-Packard LaserJet printers understand a printer command language called PCL. This language is simply a set of commands that can be sent to the printer along with the rest of the data that is to be printed. When the printer recognizes a PCL command embedded in the incoming data stream, it will act on it. The PCL language allows the programmer to control virtually all of the printer's functions: typeface, point size, font selection, page orientation, print position on the page, and graphics to name just a few. For complete information about PCL, contact Hewlett-Packard and order their book PCL-5 Printer Language Technical Reference Manual (Manual Part No. 5961-0509). An updated version of the book for PCL-6 may also be available.



PCL commands are often called Escape Sequences because they always begin with an escape character (ESC, ASCII character value 27). If your computer system will not send non-printable characters such as ESC to a printer, often true of mainframe systems, the BarSIMM's FreeScape feature allows you to designate a printable character as an alternate escape character (AEC). The default AEC is the tilde (~); to change to another character, send either of the following commands to the printer:


Replace the # with the ASCII decimal value of the new AEC which may be any of the following: 34 ("), 35 (#), 36 ($), 47 (/), 92 (\), 63 (?), 123 ({), 124 (|), 125 (}), 126 (~), or 27 (esc). Using the value 27 (escape) effectively disables FreeScape. For example, to change the AEC to a dollar sign ($), send the following command to the printer:


Escape sequences begin with an escape character followed by two characters which identify the particular sequence. These may be followed by one or more variable parameters. Each parameter includes a value (represented by a # in this document) followed by a letter which identifies the type of parameter. For example, the Horizontal Cursor Positioning (Columns) Command moves the cursor to the designated column position on the current line:


The <esc>&a identifies this as one of a group of page formatting commands. The # represents the position where the desired column position will be inserted. The C specifically identifies the parameter as a horizontal cursor position. Here is a command that will move the cursor (current print position to column 35 on the current line:


The final character in an escape sequence should always be upper case; if a sequence contains several parameters, all of the letters except for the last should be lower case. Here is the same escape sequence with some sample text; the part number will print at the left-hand margin and the description will print at column 35:

Part #30948<esc>&a35CLittle Red Wagons



A particular type of escape sequence can be used to change fonts; this command is generally in the form <esc>(s#T, where # is the identification number of the desired font. Requests for fonts in the range 24580 to 24800 are automatically intercepted by the BarSIMM which prints a barcode according to the parameters in the escape. The complete format of the escape sequence is:


The escape sequence is followed by the data that is to be printed as a barcode. The end of the data is determined depending on the type of barcode being printed:

Numeric Only (UPC, EAN, 2 of 5, etc.) space, CR, LF, FF, or another escape sequence
Alphanumeric (Code 39, Code 93, Code 128, etc.) CR, LF, FF, or another escape sequence
UPS Maxicode EOT followed by font escape sequence

Here is a sample escape sequence that will print the word HELLO as a Code 39 barcode (24670T); readable text below the bars with the start/stop characters (*) not shown (4p); text printed using Univers Regular font (102h); bar height of 40 points (40v); thin bars 10 dots wide and thick bars 30 dots wide (10,30b); thin spaces 10 dots wide, thick spaces 30 dots wide (10,30s):


You can click on this link to sdiskani.gif (6787 bytes)download sample files that demonstrate how to print various types of barcodes using the BarSIMM.

Some types of barcodes support the full ASCII character set from decimal value 0 to 127 (Extended 39, Extended 93, 128A, 128 autoswitch, EAN/UCC 128). If you want to include ASCII control codes (characters with a decimal value of less that 32) in your data, you must use a Transparent Print command to tell the BarSIMM that the control codes are part of the data and not a terminating character. The Transparent Print command must immediately follow the BarSIMM escape sequence:

<BarSIMM Escape Sequence><Transparent Print Command><Data><terminating character>

The Transparent Print Command is in the form <esc>&p#X where # is replaced with the number of following data characters (bytes) which are to be printed in the barcode. For example, if the data for a Code 128 barcode is 16 characters long, the Transparent Print Command would be <esc>&p16X.

After the barcode is printed, the cursor is positioned at the bottom right corner of the barcode. If you need to print another barcode of the same type, just reposition the cursor and send the data for the next barcode. There is no need to re-send the BarSIMM escape sequence. When you are done printing barcodes, select a normal font to resume printing text.



P Parameter: Controls if and where the human readable text is printed.   In the case of PDF-417 2-D barcodes this parameter defines the error correction level

0 = use default value
1 = do not print human readable text
2 = print text fully embedded at bottom of barcode
3 = print text half-embedded at bottom of barcode
4 = print text below the code
5 = print text above the code

Add 10 to print UPC/EAN/JAN checksum at middle rather than bottom of barcode
Add 10 to print asterisks (*) to represent the Code 39 start/stop character
Add 20 to format text for French and German postal barcodes
Add 100 to print the checksum character with the text

1-D Example: Text under the barcode: 4p
PDF-417 Example:  Use error correction level of 100:  100p

H Parameter: Controls what font is used for the human readable text. This is a string of 3 digits which control the Style, Size, and Typeface.

0 = default (bold)
1 = regular
2 = italic
3 = bold
4 = bold italic

0 = automatic font size
1 = reserved for future use

0 = Courier (default)
1 = Letter Gothic
2 = Univers
3 = Univers Condensed
4 = CG-Times
5 = OCR-B (excellent with UPC/EAN)

Example: Print text in Univers Bold Italic, automatic size: 402h

V Parameter: Height of bars measured in points (1/72 inch). In the case of barcodes like PostNet (USA postal code) which use bars of two different heights, this parameter specifies the height of the short bars.

Example: Print barcode with height of 64 points: 87v

B Parameter: Width of bars specified in 1/600 inch (1 dot @ 600dpi). There can be up to 4 width parameters separated by commas. The first parameter controls the width of a narrow bar, and the following parameters (if used) specify the second, third, and fourth widths. In some codes (Code 128, for example) the user can specify only the first (narrow) bar width; all other widths are fixed in relation to the first width. In Code 39, the user may specify both the narrow and wide bar widths (first and second parameter), but the ratio of wide:narrow must fall within the range of 2.0 to 3.0.   In the case of PDF-417 2-D barcodes the first number indicates the maximum number of columns and the second number indicates the maximum number of lines (rows).

1-D Example: Print narrow bars 0.01 inch (6 dots) wide bars 0.025 inch (15 dots), a ratio of 2.5: 6,16b
PDF-417 Example:  Constrain symbol to 40 columns, 20 rows:  40,20b

S Parameter: Width of spaces specified in 1/600 inch (1 dot @ 600dpi). The same rules apply as to the width of the bars.  In the case of PDF-417 2-D barcodes these numbers specify the X/Y size ratio of the symbol (the first number = X, the second number = Y).

1-D Example: Thin spaces at 4 dots and thick spaces at 8 dots: 4,8s
PDF-417 Example:  Symbol size ratio = 2/3:  2,3s

T Parameter: The typeface parameter controls the type of barcode to be printed. Here is a table with all of the available barcode types as of Software Revision 1.8E:

UPC-A 24600 Code 39 (3 of 9) 24670
UPC-A + 2-digit supplemental 24601 Code 39 + Mod47 check digit 24671
UPC-A + 5-digit supplemental 24602 Code 39 Extended 24680
UPC-E 24610 Code 39 Extended + Mod47 check digit 24681
UPC-E + 2-digit supplemental 24611 Code 93 24690
UPC-E + 5-digit supplemental 24612 Code 93 Extended 24691
EAN/JAN-13 24630 Code 128 autoswitch 24700
EAN/JAN-13 + 2-digit supplemental 24631 Code 128 Subset A 24701
EAN/JAN-13 + 5-digit supplemental 24632 Code 128 Subset B 24702
EAN/JAN-8 24620 Code 128 Subset C 24704
EAN/JAN-8 + 2-digit supplemental 24621 UCC-128 24710
EAN/JAN-8 + 5-digit supplemental 24622 EAN-128 24720
Industrial 2 of 5 (25) 24650 USA Postal 5-digit PostNet barcode 24770
Industrial 2 of 5 (25) + check digit 24651 USA Postal 9-digit PostNet barcode 24771
Matrix 2 of 5 24660 USA Postal 11-digit PostNet barcode 24772
Matrix 2 of 5 + check digit 24661 USA Postal 11-digit Tray Label barcode 24644
Interleaved 2 of 5 24640 USA Postal 8-digit Sack Label barcode 24645
Interleaved 2 of 5 + check digit 24641 German Postal 25 Leitcode 13 24642
Codabar 24751 German Postal 25 Leitcode 11 24643
Codabar + Mod16 check digit 24751 French Postal 39 A/R 24676
MSI Plessey 24760 Danish Postal PTT 39 barcode 24685
MSI Plessey + Mod10 check digit 24761 Maxicode (2-D) 24800
MSI Plessey + Mod10 + Mod10 check digit 24762 PDF-417 (2-D) 24850
MSI Plessey + Mod11 + Mod10 check digit 24763    



The following table provide the default settings for each of the BarSIMM escape parameters. The width of spaces defaults to the same value as the width of bars.

Type of Barcode Height Text Position Width 1 Width 2 Width 3 Width 4
UPC-A 62 3 8 16 24 32
UPC-E 24 3 8 16 24 32
EAN-8 42 3 8 16 24 32
EAN-13 62 3 8 16 24 32
Code 25 (2 of 5) 24 1 6 18    
Code 39 (3 of 9) 24 1 8 18    
Code 93 24 1 8 18    
Code 128 24 1 6 12 18 24
EAN 128 24 1 6 12 18 24
UCC 128 24 105 6 12 18 24
Codabar 24 1 6 12    
MSI Plessey 24 1 6 12    
USA Postal PostNet Code 9* 1*        
USA Postal Tray Label 50.4 4 9* 27*    
USA Postal Sack Label 50.4 1 9* 27*    
German Postal 25 50 124 10 30    
French Postal 39 36* 124* 7* 21*    

* value is fixed and cannot be overridden by the user.



Code 128 has five non-data special control codes, called Function Codes. These can be used in special applications; for example, UCC-128 codes are identified by the presence of a FNC-1 at the beginning of the barcode. There are also two special control codes which are used to switch between subsets. Note that when Code 128 Autoswitch is selected, the BarSIMM will automatically analyze the data string and select the Subset (or Subsets) that will produce the most efficient (compact) code. When the UCC-128 and EAN-128 codes are selected, the required FNC-1 code is inserted automatically by the BarSIMM and should not be included in your data string. To insert a control code, include the following decimal ASCII character values in your data string:

128 Shift
129 FNC 1
130 FNC 2
131 FNC 3
132 FNC 4
133 Subset A
134 Subset B
135 Subset C



Regular PCL commands can be used to rotate a barcode. It is recommended that you save the cursor position before printing the barcode and restore the position afterward. Here is a sample sequence of commands:

<esc>&fs (save cursor position)
<esc>&a3000h2000V (move cursor to a new position)
<esc>&a90P (rotate 90 degrees)
<esc>(s4p102h40v10,30b10,30s24670T (select barcode)
HELLO (data)
<esc>(10U<esc>(sp10hsb4099T (switch back to Courier 10 cpi font)
<esc>&aP (end rotation)
<esc>&lf1S (restore saved cursor position



Due to the very large number of possible parameter combinations, there is no standard Windows printer driver provided with the BarSIMM. Use of the BarSIMM with Windows applications is not generally recommended.

BarSIMM escape sequences may be embedded in word processor, spreadsheet or other applications. The tilde (~) may be used as the alternate escape character, or enter the escape character by holding down the ALT key and entering 027 on the numeric keypad. You must issue a PCL command immediately following the barcode command to switch back to a regular font.  The escape sequences must be formatted using an internal printer font; otherwise Windows will insert its own formatting commands, thus disrupting the command string.



The BarSIMM is supported as a standard by SAP R/3 software

  • OSS Note #5196 lists standard R/3 barcode names and supported device types for printing barcodes
  • PCL-5 commands for the BarSIMM are built into the HP device types by SAP
  • Modifications are required only for special barcode types and sizes
  • OSS Note #45643 lists PCL-5 command details for barcode attribute selection
  • PCL-5 commands are maintained as <Print Controls> in SPAD
  • SE73 translation lists barcode names and print controls for every device type
  • Barcode on: Print control SBPxx
  • Barcode off (regular font): SBSxx
  • A test is built into R/3: SO10, SAPSCRIPT-BARCODETEST (client 000)



For backward compatibility with existing applications, the BarSIMM includes all of the bitmap barcode fonts supported by the Barcodes & More Font Cartridge.



The U.S. Postal Service has defined a series of diagonal lines, called Zebra Stripes, that are used to mark mail trays and sacks that contain barcoded mail. The stripes do not carry any data; they are simply a visual indication and may not appear on any trays or sacks that contain non-barcoded mail. For simplicity, the Zebra Stripes are implemented on the BarSIMM as a font which contains a single character, a forward slash (/), ASCII decimal value 47. To print the Zebra Stripes, select the font and print a series of three slashes. Here is the required escape sequence:




If there is an error in the escape sequence or the data for a barcode, the BarSIMM will print an error message in place of the barcode. The intent is to avoid the possibility of producing barcodes that appear acceptable to the human eye but in fact contain errors that will make them unreadable or will transmit erroneous data.

!Err:Char = nn: All symbologies. An invalid character was included in the data that was to be printed as a barcode. nn is the ASCII decimal value of the offending character. For example, an alphabetic character may not printed using a numeric-only symbology like UPC-A.

!Err:Odd: Interleaved 2 of 5, with or without check digit. An Interleaved 2 of 5 barcode must contain an even number of digits. If it is to be printed without a check digit, the data string must contain an even number of digits. If the barcode is to be printed with a check digit, the data string must include an odd number of digits; the BarSIMM will automatically add a check digit, making an even number of digits.

!Err:Length: Fixed-length symbologies (UPC, EAN, USA PostNet). Some barcode symbologies require a specific number of data characters. This error will appear if too many or too few characters were included in the data string.

!Err: NonZero and !Err:InvVal: UPC-E. Compression of a normal UPC code into the smaller UPC-E requires that the number contain at least 4 zeroes, and some character positions must have very specific values. If the data violates any of the UPC-E rules one of these messages will appear.

!Err:R/A/B: French Postal 39 A/R. This barcode must start with either RA or RB. This error message will appear if the data violates this rule.



The Maxicode is a 2D barcode that consists of 884 hexagons surrounding a bullseye finder pattern.  Each hexagon encodes one bit of information.  Up to 100 characters can be encoded in one square inch.  The Maxicode includes built-in error correction capability, automatic data compression, and can encode the full ASCII character set.  Maxicode was created by United Parcel Service (UPS) and has been endorsed by AIM as a multi-purpose EDI-ready 2-dimensional barcode.  UPS uses Maxicode to encode delivery information on parcels for automated high-speed sorting.

Maxicode data is a string made up of a header, a primary message, a secondary message, and an End of Transmission (EOT, ASCII 04) code.  Always use upper case characters for the Maxicode data.  Other control codes used are the Group Separator (GS, ASCII 29) and the Record Separator (RS, ASCII 30).  Here is the structure of the data sent by the application software to the BarSIMM:

Primary Message:

label number <comma>
number of labels in shipment <comma>
Maxicode mode (2 = domestic USA, 3 = international) <comma>
postal code <comma>
country code <comma>
class of service <comma>

Secondary Message:

ANSI message header:                  [)> <RS>
Transportation Data Format Header:    01 <GS> 96
Tracking number:                      961Z00004951 <GS>
SCAC:                                 USPN <GS>
UPS Shipper Number:                   06X610 <GS>
Julian day of pickup:                 159 <GS>
Shipment ID#:                         1234567 <GS>
Package x of y:                       1/1 <GS>
Package weight:                       10 <GS>
Address validation:                   Y <GS>
Ship to address:                      634 ALPHA DRIVE <GS>
Ship to city:                         PITTSBURGH <GS>
Ship to state:                        PA
End of format:                        <RS>
End of transmission:                  <EOT>

The UPS Maxicode expects the secondary message to be padded with fill characters to a minimum of 84 total characters.  The BarSIMM does this automatically, so there is no need for application software to pad the data.  Blank fields must retain the <GS> separator code.  Immediately after the <EOT> code the application must send a PCL escape sequence to switch to a font other than Maxicode.   For example, to switch to Courier 10 cpi use this command:

<ESC> (0p10h12vbs4099T

Complete Example:

<ESC>(s24800T1,1,2,152382802,840,001,[)> <RS> 01 <GS> 961Z00004951 <GS> UPSN <GS> 06X610 <GS> 159 <GS> 1234567 <GS> 1/1 <GS>10 <GS> Y <GS> 634 ALPHA DR. <GS> PITTSBURGH <GS> PA <RS> <EOT> <ESC> (s0p10h12vbs4099T

For additional details, please consult Guide to Bar Coding with UPS OnLine for Customers Generating Bar Code Labels, published by UPS, pages 61-68.


(c) Copyright Measurement Equipment Corporation
All Rights Reserved