New line in Zebra ZPL

2020-07-03 07:34发布

  1. 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
  1. If the "text" in my label is too long, how would I put another line to it?

8条回答
疯言疯语
2楼-- · 2020-07-03 07:43

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:

^XA
^LL0406
^CI28
^CWZ,E:TT0003M_.FNT
^PA0,1,1,0

^FO609,50,2
^AZN,40,35
^TBN,559,300
^FH
^FD
_D8_B4_D8_B4_D8_B4_0A <-- new line
_D8_B4_D8_B4_D8_B4_0A <-- new line
_D8_B4_D8_B4_D8_B4
^FS


^PQ1
^XZ

... would output a ticket like this:

ششش
ششش
ششش
查看更多
等我变得足够好
3楼-- · 2020-07-03 07:46

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.

查看更多
爷、活的狠高调
4楼-- · 2020-07-03 07:47

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:

^FT78,78^A0N,28,28^FH\Hello^FS
^FT78,110^A0N,28,28^FH\World^FS

As an alternative, the ZPL manual details the ^TB (textbox) command, which includes automatic word wrapping.

查看更多
等我变得足够好
5楼-- · 2020-07-03 07:48

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

^FT78,76^A0N,28,28^FH_^FDHello_0AWorld^FS

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.

查看更多
倾城 Initia
6楼-- · 2020-07-03 07:51

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:

^A0R,54,54^FO505,3424^FB630,2,0,L,0^FDThis is a pretty long line of text^FS

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.

查看更多
小情绪 Triste *
7楼-- · 2020-07-03 07:51

For those using Android Studio or any IDE that pre-parses string literals, use:

 stringWithLineBreaks.replace(Regex("\n"), "\\\\&")
查看更多
登录 后发表回答