New line command for ^FD in zpl?

// Expert user has replied.
V Vince Quach 2 years 9 months ago
3315 3 0

I have a program where my user can input anywhere from 1 word to 5 words for a Zebra GK420t to print. However, if the user inputs more than 1 word, each word has to be on its own line. So if they input "Hello", the printer outputs a label saying "Hello". But if they input "Hello,World,Hi" then the printer outputs a label with "Hello", "World", and "Hi" on separate lines.

Because of the dynamic nature of this program, I figured having a single ^FD snippet would work, and that the new lines would be triggered by replacing the commas with the "\\&" command, so that if they input "Hello,World,Hi" then the variable that gets passed into the ZPL string would be "Hello\&World\&Hi". I looked up the new-line command and found multiple StackOverFlow posts saying that "\&" creates a new line. However, when I tried printing "^...FDHello\\&World\\&Hi^FS^PQ1,0,1,Y^XZ", the printer outputted "Hello&World&Hi" with all 3 words on the same line, separated by an ampersand. Is there a reason this is happening? Is there a better way to go about instructing the printer to print the words on multiple lines?

Stackoverflow post I found: https://stackoverflow.com/questions/13416299/new-line-in-zebra-zpl (

Please Register or Login to post a reply

3 Replies

S Steven Si

To make the \& work as a carriage return and new line feed in the ^FD statement, you would need to have a preceding ^FB statement to define a box, so that the printer knows where the next line should start. Without the ^FB, everything in the ^FD will be in one line.

N Neha Saggam

It did not really work for me, even after adding FB. Would you be able to show an example including FH, FB, and FD

S Steven Si

See the examples of multi lines in a text block in the ^FB section in the ZPL User Guide.

CONTACT
Can’t find what you’re looking for?