3

When receiving ZPL raw labels (text files) from a third party, I would like to run a regular expression on them to validate them.

Rather than a 100% strict validation, I am mostly looking to avoid sending to the printer obviously wrong files, such as completely unrelated text files, or binary files.

I am not familiar enough with ZPL/ZPL-II and I would prefer to use an existing resource for that. Would you know if one exists?

magma
  • 8,432
  • 1
  • 35
  • 33

1 Answers1

1

I've never heard of one. But it wouldn't be too hard to validate. ZPL is pretty straightforward, especially if there's a very defined set that you send to your printer...

The ZPL command characters are ~ for immediate commands an ^ for formatting commands.

Label formats must begin with a ^XA and end with a ^XZ.

Download commands typically begin with a ~D<something>, like ~DY, ~DG, ~DT, ~DC etc.

There are a couple status commands like ~HI and ~HS

There may be a couple other edge cases, but these are the most common commands.

Ovi Tisler
  • 6,425
  • 3
  • 38
  • 63
  • Wait a minute. The specs for ZPL are available https://files.tracerplus.com/public/docs/3rdparty/manuals/ZPL_Vol1.pdf, https://files.tracerplus.com/public/docs/3rdparty/manuals/ZPL_Vol2.pdf. Whilst ZPL may be simpler that C# and more structured than English would you try to write a compiler or NLP with a regular expression? – Jodrell Aug 07 '18 at 13:39