Which should not be included in this ZPL Code?

2019-07-23 06:58发布

问题:

I am developing a Windows Mobile App that requires printing into a Zebra printer. Problem is, I do not have the printer with me here in my country since the client did not provide any.

My approach was to design a label first in ZebraDesigner2, then print out the label into a text file. Printing the label to a text file instead of a printer sends out the ZPL Code to produce the label I was trying to print. Hence, I can generate ZPL codes faster by designing a label first then seeing the ZPL code. Kinda like having a drag and drop GUI with a background XML.

Say that I have this simple label that contains this text: Hello World! If I print this in ZebraDesigner2 it would be written to my text file as:

CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR5,5~SD15^JUS^LRN^CI0^XZ
^XA
^MMT
^PW609
^LL0406
^LS0
^FT1,29^A0N,28,28^FH\^FDHello World!^FS
^PQ1,0,1,Y^XZ

My main question is, which one do I include in my C# Code if im going to send this code to the printer via my Windows Mobile C# app? Do I include the part with ^XA until ^XZ? I believe that CT~~CD,~CC^~CT~ should not be included in my code If im not mistaken.

回答1:

you have to look at the programmers guid before you remove anything of the code. The CT~ command for example changes the control prefix.

Search the internet or zebra.com site for "ZPL Programming guide".

So, leave the text file as is and then include that into your windows mobile application.

PS: zebra offers SDKs for label/receipt printers: http://www.zebra.com/gb/en/products-services/software/adapt-software.html

PS2: without a test printer you may get bad final results.

~josef



回答2:

Late answer, but since this is getting viewed...

The CT line and first set of XA..XZ sequence sets up the modes, label length, printable area, etc.

If you remove those, it will take those settings from the label/printer settings, which is usually what you want. The printers can sense the length and width of the label.

Leaving them in can cause big problems, because if you define the printable area in your label, and then the next label type submitted does not, it will use the settings you have defined -- which can cause blank areas in the label, eg. cutoff USPS Label barcodes that are printed after your Zebra Designer custom labels.

Found this out the hard way - leave those out, and you should leave out of the remaining XA..XZ sequence the MMT, PW609, LL0406, and LS0 as well - your Hello World will not be affected.

If you really want to limit the area printed to, set up margins inside the printable area, etc, refer to the manual.