- How do I put new line characters for my "Text"? Say for example:
Hello World
will become Hello World
is there anyway that I can put a new line character for my code like this?
^FT78,76^A0N,28,28^FH\^FDHello\nWorld^FS
- If the "text" in my label is too long, how would I put another line to it?
Doesn't answer the original question but for anyone using ZPL for unicode this may be of help.
I am using
^TB
for Arabic text and found\&
didn't work to create a new line.What did work was to convert new line to hex (
_0A
) and use that.For example:
... would output a ticket like this:
Unfortunately, You can't really do that. You have probably found that text which is too long it wraps around back onto the same line. You have to create a new line to accommodate the text. I forget which of the numbers in that string are the positions (probably the 28,28) try adding a line, changing those to 34,28 and see if it moves to a new line below.... Just play with those 4 numbers at the front of that line. One is a font size (which might help you) and 2 of the others are position from top and right. an easy way to play with those is just to edit the file with a text editor and do a copy command from the command line to the printer UNC path and see what you get. (i.e. copy "C:\test.txt \127.0.0.1\zebra). Hope this helps.
While this question is a little older, it does serve to mention that the ZPL command ^FT is the command that dictates where the text element appears. The 78 and 76 correspond to the label's X-axis and Y-axis, respectively, and the unit of measure is dots. With this in mind, the previous answer is correct in principle. You can call another ^FT command with the y parameter being changed, such as this:
As an alternative, the ZPL manual details the ^TB (textbox) command, which includes automatic word wrapping.
The ^FX doens't understand \n, you will need to pass it \0A (the hex equivalent of \n) ASCII wiki page
So your ZPL should look like
I changed the hex char to be _ vs \ so as others that look at this when you are done don't get confused.
Jason's idea about using the ^FB command is an excellent idea. It has some odd properties to it (with text rotation), but in general is a for text wrap.
I know this question is pretty old, but I found out that the
^FB
command (Field Block) is actually pretty good at wrapping text:I used a line like this:
and it got wrapped into two lines nicely. The only thing you need to mind is that wrapping seems to take place at spaces only, not at commas or any other punctuation marks.
For those using Android Studio or any IDE that pre-parses string literals, use: