Print Mobile

Print

Understanding ZPL: What It Is, Why It’s Useful, and How to Use It

Last Updated
November 23, 2024
Estimated Duration
12
min
Author
Ben Brumfield

What It Is

ZPL stands for "Zebra Printer Language". This is the language that Zebra printers use to know what to print. It's essentially an efficient and powerful way to tell the printer what, where, and how content should be printed.


Why It's Useful

Quick takeaway:
  • High-Speed Printing: Achieves the fastest execution-to-print time, often as low as sub-second.
  • Simplified Workflow: Eliminates the need for PDF generation in Salesforce, reducing logic complexity, dependency on external document generation tools, and pdf storage consideration in Salesforce.
Technical:

Let’s start with first principles: a printer’s job is to transfer dots or pixels onto a medium, row by row, to create a clear, readable representation of the intended content. The content or "instructions" for how to represent the content can be delivered is different ways. There are efficient and inefficient ways to do this.

For example, suppose you want to print "Hello". If you sent an A4 PDF of "Hello", the data sent to the printer would would look like this:

%PDF-1.41 0
obj<</Type /Catalog/Pages 2 
0 R>>endobj2 0 obj<</Type 
/Pages/Count 1/Kids [
3 0 R]>>endobj3 0 obj<</Type 
/Page/Parent 2 0 R/MediaBox 
[0 0 612 792]/Contents 4 0 R/Resources 
<</Font <</F1 5 0 R>>>>>>endobj4 
0 obj<</Length 44>>streamBT/F1 
24 Tf72 720 Td(Hello) 
TjETendstreamendobj5 0 
obj<</Type /Font/Subtype 
/Type1/BaseFont 
/Helvetica>>endobjxref0 60000000000 
65535 f0000000010 00000 n0000000079 
00000 n0000000178 00000 n0000000351 
00000 n0000000430 00000 
ntrailer<</Size 6/Root 
1 0 R>>startxref500%%EOF

If you send it via ZPL it would look like this:

^XA^FO50,50^A0,30,30^FDHello^FS^XZ



As you can see, because the Zebra printer has essentially pre-calculated what is represented within the ZPL language, it's an extremely efficient means of transmitting information, thereby enabling rapid printing. Additionally, as long as you don't require color printing or highly complex content that it outside of the capability of ZPL, you can entirely avoid the document generation logic required to output the PDF data as shown above.

How to Use It

To illustrate a practical example, lets walk through a hypothetical use case. This will focus exclusively on the creation of the label. Pretend you run a networking event that requires name tags to be printed. The name tag must include the name of the person and the company they are with. Let's create the label in ZPL.

Here is a name tag label we will create together:

Image of name tag label with name and company.

Before getting started,  let's introduce a very useful tool that label makers all over the world use to create their ZPL labels.

Labelary:

Picture of Labelary Tool

Labelary is a tool that makes is super easy to adjust content and see what it would look like when printed. This is the go-to tool for creating ZPL labels.

Let's start by opening Labelary and replacing the default ZPL with the ZPL code below:

^XA

^CF0,100
^FO100,130^FDElla Barlow^FS
^CF0,50
^FO100,220^FDFood Distribution LLC^FS

^XZ

You should now see the name tag pictured above but now in Labelary:

Picture of name tag rendered in Labelary

Now let's walk through a simple adjustment. Suppose you wanted to make the size of company name smaller and have it be a bit lower on the label. To do so, increase the y value from 220 to 270. This will push the company name line down an additional 50 dots from the top. For the font size adjust from 50 to 40 to reduce the font size.

Image showing ZPL code and what controls postion and font size.

Now click Redraw. It should look like this:

Image of adjusted name tag label rendered in Labelary.

Great. While this still scratches the surface of what ZPL can do, you now have the basics of ZPL down! Reach out to us if you need help making your labels.

Articles Coming Soon

  • How to Add a Barcode in ZPL
  • How to Wrap Text in ZPL
  • How to Use ZPL in Flow with Merge Fields and Text Templates