问题
- 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?
回答1:
Use \&
for new line
^FT78,76^A0N,28,28^FH\^FDHello\&World^FS
回答2:
I suggest you combine the answers from Thorsten and Dharmesh for maximum effect:
^FB400,2,0,C^FO0,50
^FDHello\&World^FS
Doing so will yield a label that looks like this:
The nice things about this approach are two: First, the text block will position and align the new line appropriately. And second, you have complete control over where the line break actually takes place.
回答3:
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.
回答4:
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.
回答5:
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.
回答6:
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:
ششش
ششش
ششش
回答7:
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.
来源:https://stackoverflow.com/questions/13416299/new-line-in-zebra-zpl