Zebra ZPL II Programming Guide

0 (0)
Zebra ZPL II Programming Guide

ZPL II®

Programming Guide

Volume 2

© 2005 ZIH Corp.

The copyrights in this manual and the label print engine described therein are owned by Zebra Technologies Corporation. Unauthorized reproduction of this manual or the software in the label print engine may result in imprisonment of up to one year and fines of up to $10,000 (17 U.S.C.506). Copyright violators may be subject to civil liability.

This product may contain ZPL®, ZPL II®, and ZebraLink™ programs; Element Energy Equalizer® Circuit; E3®; and AGFA fonts. Software © ZIH Corp. All rights reserved worldwide.

ZebraLink and all product names and numbers are trademarks, and Zebra, the Zebra logo, ZPL, ZPL II, Element Energy Equalizer Circuit, and E3 Circuit are registered trademarks of ZIH Corp. All rights reserved worldwide.

CG Triumvirate is a trademark of AGFA Monotype Corporation. All rights reserved worldwide. CG Triumvirate™ font © AGFA Monotype Corporation. Intellifont® portion © AGFA Monotype Corporation. All rights reserved worldwide. UFST is a registered trademark of AGFA Monotype Corporation. All rights reserved worldwide.

All other brand names, product names, or trademarks belong to their respective holders.

Part Number: 45542L-002 Rev. A

Contents

About This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Who Should Use This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

How This Document Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Document Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1 • ZPL II Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5

How ZPL II Differs from ZPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 ZPL II Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Format and Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Format Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Control Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Command Parameters and Default Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Example of a Basic Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Shortcuts for Writing ZPL II Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Writing Code on One Line and Using Parameter Defaults . . . . . . . . . . . . . . . . . . . . . 13 Eliminating Unnecessary Field Separators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Font Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Using Device and Object Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Device Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Object Names and Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Name Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2 • Programming Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Introduction to Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Computer and Software Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Performing the Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

iv Contents

Exercise 1: Saving Label Formats as Graphic Images . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Exercise 2: Downloading and Printing Graphic Images . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Exercise 3: Setting Print Rate, Printing Quantities of Labels in an Inverted Orientation,

and Suppressing Backfeed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Exercise 4: Slew Command, Form Feed, and Printing Entire Formats in Reverse . . . . . 29 Exercise 5: Using Serialized Fields. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Exercise 6: Stored Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3 • Advanced Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Special Effects for Print Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Serialized Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Variable Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Stored Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Initialize/Erase Stored Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Download Format Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Field Number Command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Field Allocate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Recall Stored Format Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Test and Setup Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Calibration and Media Feed Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Cancel/Clear Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Printer Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Set Dots/Millimeter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Host Status Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Changing Delimiters and Command Prefixes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Communication Diagnostics Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Assigning Network IDs/Chaining Multiple Printers . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Connecting Printers into the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Graphic Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Boxes and Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Working with Hex Graphic Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Alternative Data Compression Scheme for ~DG and ~DB Commands . . . . . . . . . . . 52 Recalling a Hexadecimal Graphic Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Image Move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Reducing Download Time of Graphic Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Transferring Object Between Storage Devices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Deleting Graphics from Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Defining and Using the AUTOEXEC.ZPL Function . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Memory, Flash Cards, and Font Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

Contents v

4 • Fonts and Bar Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Standard Printer Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

Proportional and Fixed Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Scalable Versus Bitmapped Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Scalable Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Bitmapped Fonts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Font Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

6 dot/mm printhead. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

8 dot/mm (203 dpi) printhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

12 dot/mm (300 dpi) printhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

24 dot/mm (600 dpi) printhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Bar Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

Basic Format for Bar Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Bar Code Field Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Bar Code Command Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

5 • Printer Configuration Using ZPL II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

Printer Configuration Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Print Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Media Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Media Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

Media Darkness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

Label Top Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

Set Media Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

Mode Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Reprint After Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Configuration Update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Set ZPL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Setting Up Customized Label Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

6 • XML—Super Host Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

77

Introduction to XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 XML Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Printer Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Saved Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Format Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Status Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

7 • Real Time Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 8 • Mod 10 and Mod 43 Check Digits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Mod 10 Check Digit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

Mod 43 Check Digit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

vi Contents

9 • Error Detection Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 What is a Protocol?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 How Protocols Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Request Packet Formats from the Host Computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Header Block Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 Data Block Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Response From the Zebra Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Zebra Packet Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Header Block Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Data Block Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Disguising Control Code Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Error Detection Protocol Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Error Conditions and System Faults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 How the Zebra Printer Processes a Request Packet . . . . . . . . . . . . . . . . . . . . . . . . 107 How the Zebra Printer Responds to Host Status . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

10 • ZB64 Encoding and Compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Introduction to B64 and Z64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110 B64 and Z64 Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112

A • Code Page 850 Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 B • ASCII Code Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 C • AIM Contact Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Proprietary Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

About This Document

This section provides you with contact information, document structure and organization, and typographical conventions used in this document.

Contents

Who Should Use This Document. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

How This Document Is Organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Document Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

2About This Document

Who Should Use This Document

Who Should Use This Document

This Programming Guide is intended for use by any person who needs to perform routine maintenance, upgrade, or troubleshoot problems with the printer.

How This Document Is Organized

The Programming Guide is set up as follows:

Section

Description

 

 

About This Document on page 1

This section provides you with contact information, document

 

structure and organization, and typographical conventions used

 

in this document.

 

 

ZPL II Basics on page 5

This section provides basic information about Zebra

 

Programming Language II (ZPL II).

 

 

Programming Exercises on page 19

This section provides exercises that show you how to use

 

ZPL II.

 

 

Advanced Techniques on page 39

This section presents information and commands for using

 

advanced techniques, such as special effects, serialized data

 

fields, control commands, program delimiters, communications,

 

and memory cards.

 

 

Fonts and Bar Codes on page 59

This section provides information about different fonts (type

 

faces) and bar codes that can be used with the printer.

 

 

Printer Configuration Using ZPL II

This section discusses how to use the ZPL II printer

on page 71

configuration commands.

 

 

XML—Super Host Status on page 77

This section provides information about XML—Super Host

 

Status.

 

 

Real Time Clock on page 93

This section discusses the ZPL II commands related to the Real-

 

Time Clock (RTC).

 

 

Mod 10 and Mod 43 Check Digits

This section provides information about Mod 10 and Mod 43

on page 95

check digits.

 

 

Error Detection Protocol on page 99

This section explains the Zebra protocol that has been

 

supplanted in TCP/IP based applications because of the error

 

detection compatibility inherent in the TCP/IP protocol.

 

 

ZB64 Encoding and Compression

This section describes the Base 64 MIME (ZB64) encoding and

on page 109

compression. This is the same type of MIME encoding that is

 

used in e-mail.

 

 

Code Page 850 Chart on page 115

This section shows the Code Page 850 character set used by

 

Zebra printers.

 

 

ASCII Code Chart on page 119

This section shows the American Standard Code for Information

 

Interchange (ASCII) code used by Zebra printers.

 

 

AIM Contact Information on page 121

This section provides contact information for AIM (Association

 

for Automatic Identification and Mobility).

 

 

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

About This Document 3

Contacts

Contacts

You can contact Zebra Technologies Corporation at the following:

Visit us at: www.zebra.com

Our Mailing Addresses:

Zebra Technologies Corporation

333 Corporate Woods Parkway

Vernon Hills, Illinois 60061.3109 U.S.A

Telephone: +1 847.634.6700

Fax: +1 847.913.8766

Zebra Technologies Europe Limited

Zebra House

The Valley Centre, Gordon Road

High Wycombe

Buckinghamshire HP13 6EQ, UK

Telephone: +44 (0)1494 472872

Fax: +44 (0)1494 450103

Support

You can contact Zebra support at:

Web Address: www.zebra.com/SS/service_support.htm

Note • The web address is case-sensitive.

US Phone Number +1 847.913.2259

UK/International Phone Number +44 (0) 1494 768289

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

4About This Document

Document Conventions

Document Conventions

The following conventions are used throughout this document to convey certain information.

Alternate Color (online only) Cross-references contain hot links to other sections in this guide. If you are viewing this guide online in .pdf format, you can click the cross-reference (blue text) to jump directly to its location.

LCD Display Examples Text from a printer’s Liquid Crystal Display (LCD) appears in

Bubbledot ICG font.

Command Line Examples Command line examples appear in Courier New font. For example, type ZTools to get to the Post-Install scripts in the bin directory.

Files and Directories File names and directories appear in Courier New font. For example, the Zebra<version number>.tar file and the /root directory.

Icons Used

Caution • Warns you of the potential for electrostatic discharge.

Caution • Warns you of a potential electric shock situation.

Caution • Warns you of a situation where excessive heat could cause a burn.

Caution • Advises you that failure to take or avoid a specific action could result in physical harm to you.

Caution • (No icon) Advises you that failure to take or avoid a specific action could result in physical harm to the hardware.

Important • Advises you of information that is essential to complete a task.

Note • Indicates neutral or positive information that emphasizes or supplements important points of the main text.

Example • Provides an example, often a scenario, to better clarify a section of text.

Tools • Tells you what tools you need to complete a given task.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

1

ZPL II Basics

This section provides basic information about Zebra Programming Language II (ZPL II).

ZPL II is a powerful label-definition and printer-control language. Labels may be defined in ZPL II and generated by a host computer system. A commercial label preparation system or a software package that automatically generates ZPL II code also may be used. For information about label preparation systems, consult your distributor, systems integrator, or computer software vendor.

Contents

How ZPL II Differs from ZPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 ZPL II Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Format and Control Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Format Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Control Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Command Parameters and Default Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Example of a Basic Label. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Shortcuts for Writing ZPL II Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Writing Code on One Line and Using Parameter Defaults. . . . . . . . . . . . . . . . . . . . . . 13 Eliminating Unnecessary Field Separators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Font Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Using Device and Object Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Device Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Object Names and Extensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Name Parameter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

6ZPL II Basics

How ZPL II Differs from ZPL

How ZPL II Differs from ZPL

ZPL II substantially reduces the time between when a printer begins receiving label format data and when the first label begins to print. This was accomplished primarily by changing the way ZPL scripts are written.

ZPL II scripts are not 100 percent compatible with standard ZPL scripts. However, the differences between ZPL II and standard ZPL scripts are minor. Most existing standard ZPL scripts can be modified easily to take advantage of ZPL II. You can also write ZPL II scripts that are compatible with standard ZPL printers.

These are the major differences between ZPL and ZPL II:

With ZPL II, all data fields are formatted as they are received. In standard ZPL, the data fields are not processed until after the ^XZ (End Format) command is received.

Many new commands and significant enhancements to existing commands were added into the ZPL II language.

To take advantage of ZPL II, the following ZPL II commands, if used, must come before the first ^FD (Field Data) command in a label format. If these commands are not placed before the first ^FD command, the label may not print correctly.

^JM ^LH ^LL ^LR ^LS ^PM ^PR ^PF

ZPL II commands can be entered in either uppercase characters, lowercase characters, or a combination of both.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

ZPL II Basics 7

ZPL II Overview

ZPL II Overview

ZPL II is Zebra Technologies Corporation’s registered trademark for its Zebra Programming Language II. ZPL II commands sent to a Zebra printer give you the ability to create a wide variety of labels from the simple to the very complex. The labels can include any combination of text, bar codes, and graphics.

ZPL II contains a variety of printable character font styles and bar codes. Various ZPL II commands let you position print fields anywhere on a label horizontally or rotated 90, 180, or 270 degrees clockwise. Graphic images can be read and interpreted, provided that they are in a binary or hexadecimal format. Therefore, if you can convert a scanned or computer-generated image (an image created using a draw or paint software program) into hexadecimal format, you can print it on a label. You can use the ZTools™ for Windows program (available from Zebra) to convert the bitmap graphic into the pure hexadecimal graphic format.

ZPL II commands consist of a prefix character, a two-character mnemonic code, and where applicable, a parameter string. The entire language is programmable in printable ASCII characters, which allows easy passage of formats and data through computer networks and protocol converters. ZPL II commands do not use escape sequences or control codes. A few commands do have ASCII control code equivalents, which are noted as they apply.

ZPL II is both powerful and flexible, providing all of the following features:

compatibility with PCs, minicomputers, mainframe computers and networks

serialized label fields, with user-selected starting value and increment/decrement value

programmable label replicate count, batch quantity control, and printer pauses that enable batching of labels into usable groups

simple line graphics to eliminate label preprinting

scalable fonts

bitmap image graphics, with library function capability (to store more than one graphic and recall as needed), for freeform graphic designs

You can create and use ZPL II scripts (label formats) one at a time from any word processor capable of generating an ASCII text file. You can integrate your Zebra printer into your operations by using database programs and other languages to generate ZPL II programs. The ZPL II program is then sent to the Zebra printer through an appropriate interface (combination of proper cabling, printer configuration, and software settings). The examples in this guide use printable ASCII characters in all commands, unless otherwise noted.

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

8ZPL II Basics

Format and Control Commands

Format and Control Commands

There are two different types of ZPL II commands:

Format commands use the caret (^) prefix. The caret (^) is a single printable ASCII character having the code 5E HEX or 94 decimal. An “RS” (HEX 1E) can be substituted for the caret (^).

In ZPL II commands, the caret (^) is treated as an ordinary ASCII character. In this manual, when you see the caret (^), it indicates that you are to type the caret (^) character. The caret (^) character is not to be confused with pressing the Control (Ctrl) key on the keyboard.

Control commands use the tilde (~) prefix. The tilde (~) is a single printable ASCII character having the code 7E HEX or 126 decimal. A “DLE” (HEX 10) can be substituted for the tilde (~).

A few ZPL II commands can be sent to the printer as either a format command or a control command. The action performed by the printer will be the same in either case. These commands must be preceded by the appropriate prefix (^ or ~) for the context in which they are used. For example, the prefix characters for format (~) and control (^) commands can be changed using ZPL II the following commands:

^CT or ~CT (change tilde)

^CC or ~CC (change caret)

Format Commands

Format commands are the blueprint of a label. These commands define label length, field origin, type of field, field data, and other information. Format commands are always preceded by the caret (^) character.

All format commands are processed in the order received, and most format commands are “order-independent.” For example, commands to print text at the bottom of a label can come before the command to print a bar code at the top of the same label. However, some format commands must be placed before others within the label format. These are:

^LH (label home)

^LL (label length)

^LR (label reverse)

^LS (label shift)

^JM (set dots/millimeter)

^PM (mirror image)

^PO (print orientation)

^PF (slew dot rows)

Proper usage of these commands is explained in ZPL II Programming Guide Volume One.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

ZPL II Basics 9

Format and Control Commands

Multiple label formats are processed in the order the printer receives them. Format commands fall into several categories:

format bracket commands

label definition commands

field definition commands

field default commands

format default commands

format rotation commands

printer control commands

alphanumeric field commands

bar code field commands

graphic image commands

Control Commands

Control commands are usually preceded by a tilde (~) character. In most cases, these commands cause the printer to take a specific action immediately, such as clearing the memory or feeding a blank label. Control commands may interrupt and preempt any format commands waiting in the printer’s received data buffer.

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

10ZPL II Basics

Command Parameters and Default Values

Command Parameters and Default Values

Many ZPL II commands have parameter strings associated with them. Changing the value of one or more of these parameters affects the outcome of the printed label.

If the default value for a command parameter works well for the code you are writing, you do not need to specify that parameter. However, parameters are “position-specific.” For example, if you want to change only the third parameter, you must indicate which parameter to change. To do so, use a comma (the ZPL II delimiter character) to mark each parameter’s place. The code below sets the third parameter:

^AA,,60

If you enter a parameter, all further parameters to the right are defaulted; no further commas are required.

Some commands include the following abbreviation: {I.V.P. =} This signifies the Initial Value at Power-up, regardless of the value when the printer was turned off.

To permanently save configuration settings in the printer’s configuration memory; send a ^JUS command at the end of the ZPL II script. For more information on using the ^JU command, refer to ZPL II Programming Guide Volume One.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

ZPL II Basics 11

Example of a Basic Label

Example of a Basic Label

This example shows the basic steps to create a common label that contains text and a bar code. Type the programming commands (shown in bold) in the order given. An explanation of what each command does is in brackets [ ]. Figure 1 shows a printed example of the label and shows the ZPL II commands that generated each feature.

^XA

[^XA indicates start of label format.]

^LH30,30

[^LH sets label home position 30 dots to the right and 30 dots down from the top edge of the label.]

^FO20,10^AD^FDZEBRA^FS

[^FO20,10 sets the field origin 20 dots to the right and 10 dots down from the home position defined by the ^LH command.]

[^AD – Select font “D.”] [^FD – Start of field data.] [ZEBRA – Actual field data.] [^FS – End of field data.]

^FO20,60^B3^FDAAA001^FS

[^FO20,60 – Set field origin 20 dots to the right and 60 dots down from the home position defined by the ^LH command.]

[^B3 – Select Code 39 bar code.]

[^FD – Start of field data for the bar code.] [AAA001 – Actual field data.]

[^FS – End of field data.]

^XZ

[^XZ – Indicates end of label format.]

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

12ZPL II Basics

Example of a Basic Label

Figure 1 • Basic Label

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

ZPL II Basics 13

Shortcuts for Writing ZPL II Scripts

Shortcuts for Writing ZPL II Scripts

ZPL II programming scripts can be written in a variety of ways. There are, however, more efficient ways to write a ZPL II script depending on the application and the commands used. The following are different ways to write the same ZPL II scripts, each yielding the same results.

Writing Code on One Line and Using Parameter Defaults

A Code 39 bar code (^B3) example can have the ZPL II script written as:

^XA^FO100,75^BY3

^B3N,N,100,Y,N

^FD123ABC^XZ

However, because it contains only one field, the entire command can be written as a one-line entry:

^XA^FO100,75^BY3^B3N,N,100,Y,N^FD123ABC^XZ

This script can be further simplified by using just the comma (,) delimiter to indicate default parameters in the ^B3 command. Leaving off the last two values indicates that default parameters are to be used at the end of the ^B3 command:

^XA^FO100,75^BY3^B3,,100^FD123ABC^XZ

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

14ZPL II Basics

Shortcuts for Writing ZPL II Scripts

Eliminating Unnecessary Field Separators

You can write your ZPL II scripts in any way that makes sense to you. Some programmers prefer to write out each format command and field on a separate line like this:

^XA

^PR2^FS

^LL935^FS

^LH30,30^FS

^FO20,10^AF^FDZEBRA^FS

^FO20,60^B3,,40^FDAA001^FS ^FO20,180^AF^SNSERIAL NUMBER 00000000111,1,Y^FS ^PQ10^FS

^XZ

Although this script will print with no problems, it contains unnecessary ^FS (Field Separator) commands after the format commands. Some programmers feel that it is required to place a ^FS command at the end of each line, but the ^FS command is only needed to separate specific fields. Therefore, the script would transmit more quickly written this way:

^XA

^PR2

^LL935

^LH30,30

^FO20,10^AF^FDZEBRA^FS

^FO20,60^B3,,40^FDAA001^FS ^FO20,180^AF^SNSERIAL NUMBER 00000000111,1,Y^FS ^PQ10

^XZ

Other programmers prefer to keep the format commands on one line as an organizational preference, like this:

^XA^PR2^LL935^LH30,30

^FO20,10^AF^FDZEBRA^FS

^FO20,60^B3,,40^FDAA001^FS ^FO20,180^AF^SNSERIAL NUMBER 00000000111,1,Y^FS ^PQ10^XZ

The label will print out the same, so you should develop a scripting pattern that suits your own organizational style but one that is efficient and keeps transmission times to a minimum.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

ZPL II Basics 15

Shortcuts for Writing ZPL II Scripts

Font Shortcuts

There are times when you might include a specific font into your script and use it repeatedly within different fields. The following is an example of one way to write this script:

^XA

^FO120,108^A0N,89^FDA Guide to^FS ^FO120,207^A0N,89^FDZPL II^FS ^FO120,306^A0N,89^FDProgramming^FS ^FO120,405^A0N,89^FDLanguage^FS ^XZ

Notice that the ^FS command is used on the second to last line to close the field. Actually, it is unnecessary because the ^XZ will accomplish the same thing, so we can remove it from our script. Also, because the font and font size are not changing within the fields, this script can be simplified for quicker transmission by removing the unnecessary font entries and listing the font information once using the ^CF command:

^XA

^CF0,89

^FO120,108^FDA Guide to^FS ^FO120,207^FDZPL II^FS ^FO120,306^FDProgramming^FS ^FO120,405^FDLanguage

^XZ

This script can be made even more efficient by including the ^FB command to identify the left origin of the text, which occurs at the same place each time:

^XA

^CF0,89

^FO120,108

^FB300,4

^FDA Guide to\&ZPL II\&Programming\&Language ^XZ

Note • The entries “\&” within the text indicate a carriage return/line feed as allowed by the ^FB command.

If you wanted to change the font type or size within the script, however, you would need to include the specific font parameters within the field where the change occurs. In this case, you would not want to use the ^FB command because the change in font size (in our example below) will affect the y-axis (up and down) position of the text. You can still use the ^CF command, but you will need to include the specific font information on the line where the change in the field occurs:

^XA

^CF0,89

^FO120,108^FDA Guide to^FS ^FO120,207^FDZPL II^FS ^FO120,306^A0N,110^FDProgramming^FS ^FO120,426^FDLanguage

^XZ

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

16ZPL II Basics

Using Device and Object Names

Using Device and Object Names

This section describes how device and object names can be used with commands that have a name parameter.

Device Names

Device names have been assigned to the various printer memory devices (such as the DRAM, RAM, EPROM) to allow for easy identification of the devices. Using device names allows for storage, recall, copy, and deletion of ZPL II objects (for example, graphic images, label formats, and downloaded fonts) to and from specific areas.

A device name is a single letter followed by a colon. The printer devices are:

R: Printer DRAM library (read/write)

B: Optional memory (a card or factory installed)

E: Flash memory (read/write)

Z: Internal ZPL II stored object library (read only)

When recalling objects, the following search priority is used: DRAM, RAM, extra EPROM, internal ZPL II (R:, B:, E:, Z:, * or ? (All)).

Several ZPL II commands use device names as an optional parameter. The default value may vary with the individual ZPL II commands. The default for the creation and deletion of objects is printer DRAM.

For more information about memory devices, see Memory, Flash Cards, and Font Cards on page 56.

Object Names and Extensions

Each ZPL II object (graphic image, label format, downloaded font) must have a name. This name consists of two parts: an Object Name and an Extension. Object names can be 1 to 8 alphanumeric characters in length. Extensions consist of a period followed by 3 predefined characters. Object name conventions and extensions are similar to MS-DOS file name conventions and extensions.

Several ZPL II commands use these object names. Object names have no default and must be supplied. Extensions have the defaults defined below. Depending on the ZPL II command, if an extension is missing, incomplete, or incorrect, a default will be used. Defined extensions for ZPL II Object names, along with their related ZPL II commands are:

.ZPL ZPL II label format (^DF or ^XF)

.FNT fonts in Zebra format (~DB or ~DS)

.GRF Zebra bitmap format (~DG, ^IS, ^IL, ^XG or ^IM)

Depending on the ZPL II command, the Object name and Extension may support the use of the asterisk (*) and question mark (?) as wild cards.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

ZPL II Basics 17

Using Device and Object Names

Name Parameter

The device names and object names just described can be used with ZPL II commands that support a name parameter. The commands are:

~DG Download Graphic Image ^XG Recall Graphic Image

^IS Store format as a graphic image ^IL Load Image

^IM Move Image

^DF Store ZPL II format as text ^XF Recall ZPL II format

^ID Image Delete

^HW Host Directory List ^WD Print Directory ~DB Download Bitmap

~DS Download Scalable Font

The name parameter can consist of an alphanumeric string of from 1 to 8 characters or of a string containing a Device Name followed by an Object Name with an Extension. Defaults and/or use of the asterisk (*) and question mark (?) as wild cards will be defined with the individual command.

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

18ZPL II Basics

Using Device and Object Names

Notes • ___________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

__________________________________________________________________________

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

2

Programming Exercises

This section provides exercises that show you how to use ZPL II.

Contents

Introduction to Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Computer and Software Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Performing the Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Exercise 1: Saving Label Formats as Graphic Images . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Exercise 2: Downloading and Printing Graphic Images. . . . . . . . . . . . . . . . . . . . . . . . . . 23

Exercise 3: Setting Print Rate, Printing Quantities of Labels in an Inverted Orientation, and Suppressing Backfeed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

Exercise 4: Slew Command, Form Feed, and Printing Entire Formats in Reverse . . . . . 29 Exercise 5: Using Serialized Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Exercise 6: Stored Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

20Programming Exercises

Introduction to Exercises

Introduction to Exercises

These programming exercises are included to assist and instruct both the new and more experienced user in the proper use of ZPL II commands. The exercises are simple by design, so they can be completed quickly. New users may find it helpful to complete all of the exercises. More experienced users may want to refer only to exercises detailing the use of specific commands or features. Most exercises are “stand-alone” and can be completed individually. However, some exercises assume that you have completed a previous exercise (such as exercises that erase a previously saved graphic image).

Note • Note the following as you do the exercises

• Factory default printer settings were used for the examples in this guide, and the printer is set up for tear-off operation.

The actual size of your printed examples may be different than those shown in this guide. The important thing is that the information displayed is the same.

Computer and Software Requirements

The exercises are designed for a Zebra printer controlled by a “stand-alone” (not part of a network) IBM®-compatible personal computer because of its relative familiarity among users. However, a Zebra printer also may be controlled by mainframes or minicomputers.

The ZPL II language uses only printable ASCII characters. Any word processor or text editor capable of creating ASCII-only files (files without formatting codes and other extraneous information) can be used to create the scripts in these examples. For instance, if you are using Microsoft Word®, save your scripts as text files (.txt).

Performing the Exercises

Before beginning the exercises, load the printer with media and ribbon (if used) and make sure that the printer is properly adjusted for the media. If you are unfamiliar with these procedures, refer to the printer’s User Guide for assistance.

The examples shown in this guide assume a media size of at least 80 mm wide and 60 mm long. Media of different sizes can be used; however, parameters affecting size or location of printed data may need to be modified. If you use continuous media for the examples, set the label length by adding the command sequence ^LL480^FS after the ^XA command line. Both of these commands are covered in detail in ZPL II Programming Guide Volume One.

Each exercise has two parts: the actual commands sent to the printer and the results (usually in the form of a printed label) of those commands. Type the commands exactly as you see them. When you finish typing a line, press the RETURN or ENTER key, and then type the next line. Continue this process for all of the lines in the example.

If a script is in two or more portions, save the two parts as separate .txt files. Send the first portion to the printer, and wait to see the results. Then send the next potion, and wait again to see the results. Depending on the exercise, a result may be data uploading to the printer indicated by a flashing LED (if available on your printer) or a sample label printing.

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

Programming Exercises 21

Introduction to Exercises

Exercise 1 • Saving Label Formats as Graphic Images

This exercise illustrates how to save a label format as a graphic image in printer RAM and then recall (load) for printing a label format that has been previously saved. The exercise consists of two scripts. The first contains a label format and the commands necessary to save the format as a graphic image. The second recalls and prints the label format that was saved as the graphic image.

While this exercise utilizes the ^IL command to load a graphic image, the ^IM command may also be used. These two commands differ in that images loaded using the ^IL command are always positioned relative to the ^FO0,0 (Field Origin) command. The ^IM command places the image anywhere on the label as specified by an ^FO command preceding it.

The ZPL II commands sent to the printer are:

^XA

^LH30,30

^FO20,10^AFN,56,30^FDZEBRA^FS

^FO20,80^B3N,Y,20,N,N^FDAAA001^FS

^FO10,160^GB150,100,4^FS

^ISR:EXERPROG.GRF,N

^XZ

^XA^ILR:EXERPROG.GRF^XZ

Programming Commands

Type the commands (shown in bold) in the order given. An explanation of what each command does is in brackets ( [ ] ).

^XA

[^XA - Indicates start of label format.]

^LH30,30

[^LH - Sets label home position 30 dots to right and 30 dots down from top edge of label.]

^FO20,10^AFN,56,30^FDZEBRA^FS

[^FO - Set field origin relative to label home.]

[^AF - Select font “F” and sets character size to 56 dots high and 30 dots wide.] [^FD - Start of field data.]

[ZEBRA- Actual field data.] [^FS - End of field data.]

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

22Programming Exercises

Introduction to Exercises

^FO20,80,^B3N,Y,20,N,N^FDAAA001^FS

[^FO - Set field origin relative to label home.]

[^B3N,Y,20,N,N - Select Code 39 bar code. Calculate check digit, do not print interpretation line.]

[^FD - Start of field data for bar code.] [AAA001 - Actual field data.]

[^FS - End of field data.]

^ISR:EXERPROG.GRF,N

[^IS - Save format as a graphic image named “EXERPROG.GRF,” do not print after saving.]

^XZ

[^XZ - Indicates end of label format.] (Data is uploaded to printer RAM.)

^XA^ILR:EXERPROG.GRF,N^XZ

[^XA - Start of label format.]

[^ILR:EXERPROG.GRF - Load and print the graphic image saved as EXERPROG.GRF] [^XZ - End of label format.]

Review

Save the file on your computer’s hard drive, and name it EXER1.ZPL. Copy the file to the printer. Compare your results with those shown below. If your label does not look like the one shown, confirm that the file you created is identical to the listing at the beginning of this exercise and repeat the printing procedure.

Figure 2 • Exercise 1 Results

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

Programming Exercises 23

Introduction to Exercises

Exercise 2 • Downloading and Printing Graphic Images

This exercise illustrates how to create a hexadecimal graphic image and print it as part of your label.

To store graphic images, sufficient memory must be allocated (reserved) for them. Memory for storing graphic images is allocated as needed. The graphic images can then be recalled and integrated with additional label data without downloading the entire image each time a label is printed. Graphic images are downloaded using the ~DG (Download Graphic) command along with appropriate parameters to indicate the size of the graphic being downloaded.

Graphic images may be created using a drawing or painting program that creates files in the

.PCX format, such as PC Paintbrush. These files must then be converted to ZPL II graphic format .GRF (pure hexadecimal data without headers or other extraneous information) for use as part of a label format. You can use the ZTools™ for Windows program (available from Zebra) to convert the .PCX graphic format into the pure hexadecimal .GRF graphic format. Hexadecimal data may also be directly input as part of a ZPL II program.

The ~DG command requires parameters indicating the size of the graphic image.

Format dds~DGd,o,x,t,w,data

This table identifies the parameters for this format:

 

 

Table 1 • ~DG Format Parameters

 

 

Parameters

Details

 

 

 

d

= destination device to

Accepted Values: a non-volatile RAM device

 

store image

Default Value: R:(DRAM)

o

= name of image

Accepted Value: 1 to 8 alphanumeric characters

 

 

Default Value: UNKNOWN.GRF

 

 

 

x

= filename extension

Fixed: .GRF

t

= total number of bytes

Accepted Values: a non-volatile RAM device

 

in graphic

Default Value: R:(DRAM)

w

= number of bytes per

Accepted Values: any integer

 

row

Default Value: None

 

 

data = ASCII

The data string defines the image and is an ASCII hexadecimal representation

 

hexadecimal sting

of the image. Each character represents a horizontal nibble of four dots.

 

defining image

 

 

 

 

Refer to the ~DG command in ZPL II Programming Guide Volume One for complete information on calculating the total number of bytes and the number of bytes per row.

07/27/2005

ZPL II Programming Guide

45542L-002 Rev. A

24Programming Exercises

Introduction to Exercises

For this exercise, create a “smile” graphic (such as the one shown below) in a drawing or paint program so that the graphic is 1.5 inches by 1.5 inches at 200 dpi.

Save the graphic in .PCX format and name it: SMILE.PCX. Convert this file to the .GRF format using ZTools™ for Windows.

The ZPL II commands you will use in this exercise are: ^XA and ^XZ: label format start/stop commands ^FO and ^FS: label field definition commands ^XG: recall graphic command

The ZPL II commands sent to the printer are:

~DGR:SMILE.GRF,12012,39

Depending on the image size and how the graphic was created, there will be many lines of ASCII hexadecimal data describing your image following the ~DG command line.

^XA

^FO50,50^XGR:SMILE.GRF,1,1^FS

^XZ

Programming Commands

Type the commands shown in bold in the order they are presented. Command explanations are provided in brackets ([explanation]).

^XA

[^XA - Indicates start of label format.]

^FO50,50^XGR:SMILE.GRF,1,1^FS

[^FO - Set field origin relative to label home.]

[^XG - Recall graphic named “SMILE” from memory with a magnification of 1:1 along X and Y axis.]

[^FS - End of field data.]

^XZ

[^XZ - Indicates end of label format.]

45542L-002 Rev. A

ZPL II Programming Guide

07/27/2005

Loading...
+ 102 hidden pages