How to convert PDF to ZPL

Sounds simple, right?

*clears throat*

Attention, class. My name is Rob, and I’ll be your label professor today 📏

Printing PDFs with a Zebra printer is not as straightforward as it one might expect. Zebra printers speak a proprietary language called “ZPL”, and converting your documents to ZPL is a complex process that requires either specialized print drivers or an online conversion service, like LabelZoom.

There are two ways one could approach converting a PDF file to ZPL. In this article, we’ll compare and contrast the two main methods, and offer our perspective on why you may choose one over the other.

The “old” way: rasterization

When converting a PDF to ZPL, most solutions in the market will render each page of the PDF to a raster image (i.e., bitmap), then convert the resulting pixels to ZPL. This is an effective “shortcut” to producing ZPL and it does a good job of preserving the original aesthetic of the PDF. However, in the context of label printing, it also comes with some major drawbacks.

  1. The conversion process is slow (relatively). When converting documents manually, the delay is generally unnoticeable. Using raster conversion, LabelZoom can usually convert a 3-page PDF page to ZPL in around 300 milliseconds. However, LabelZoom has customers that convert thousands of labels per day via our REST API, and those delays can add up. ⌚
  2. It uses a lot of energy (relatively). Rasterizing a PDF uses a lot more computing power (CPU) than native conversion. More CPU cycles means more energy used. In the age of AI and electric cars, energy demand is at an all-time high, and inefficient data processing only exacerbates the problem. 🏭
  3. Fine details may be lost. When text is scaled down to a small size, then rasterized, the hard edges of the text may be lost due to image resizing techniques like anti-aliasing and dithering. This causes small text to appear “blurry”. In some cases, it can even render the text unreadable. 🙈
  4. It reduces the print speed, significantly. Rasterizing a PDF significantly increases the size of the ZPL payload, which increases the amount of time it takes to transfer the ZPL to the printer. Additionally, it limits the printer’s ability to optimize the movement of the print head because rather than telling the printer what to do, you’re telling it how to do it. Shouldn’t we let the printer decide for itself? 🐢

The “new” way: native conversion

The talented engineers at LabelZoom developed a new algorithm for converting PDFs to ZPL. This proprietary technology allows us to map native PDF elements to their ZPL counterparts without any intermediary translation. This significantly reduces conversion time and CPU usage while simultaneously boosting print speed and image fidelity. That same 3-page PDF document that used to take 300 milliseconds can now be processed in 50 milliseconds. That’s a 6x speed improvement. 🤯

Additionally, this innovation allows us to use less compute (CPU) to process requests. Not only does this reduce our energy usage and helps us keep the planet clean, but it also leads to cost savings that we pass on to our customers. Talk about a win-win-win!

There are some trade-offs, however. For one, the original fonts will be lost. In order to maximize print speed, we rely on the font data that is already programmed into the printer. We are generally able to preserve the font family (e.g., monospace fonts remain monospace, while other fonts remain variable-width), but you shouldn’t expect a 1:1 reproduction of the original fonts, sizing, and spacing.

Which method should I choose?

That depends on what you value most and what trade-offs you’re willing to accept. I generally summarize it like this:

  • Print speed: Choose native conversion
  • Label aesthetics: Choose image conversion (rasterization)

The good news is that LabelZoom allows you to try both. You can tell our parser which method to use by setting the appropriate request header. Test a few label formats with each method and then decide based on the results.

How to convert via the LabelZoom Web App

The easiest way to convert a PDF document to ZPL is to use the LabelZoom Web App.

On the welcome page, click on the “upload” button or drop your PDF into the region:

After your file is uploaded, you will be teleported to the app, where you can perform various adjustments to the document before converting to ZPL. If you uploaded a PDF, you will have an option called “Render Mode” which allows you to switch between image and native rendering:

Click the “Generate ZPL” button to convert your PDF to ZPL, which allows you to print your PDF on your Zebra printer.

How to convert via the LabelZoom REST API

There is a request parameter named pdf.conversionMode that accepts two different values: image or native. At the time of writing, the default value is image. To try the new native parsing, you must manually set the value to native.

Here are the steps to create a request in Postman:

  1. Create a new POST request
  2. Set the URL to https://api.labelzoom.net/api/v2/convert/pdf/to/zpl?pdf.conversionMode=native
  3. Select the “Body” tab
  4. Select the “binary” radio
  5. Select the PDF you’d like to convert
  6. Click “Send”