ZPL - Zebra: print a legitimate text block without overwriting the last line

I use the following command to print informed text:

^FB1800,3,0,J^FT100,200^A0B,26,26^FH\^FDLONG TEXT TO BE PRINTED, WHICH DOESNT FIT IN ONLY 3 LINES...^FS 

Command ^ FB1800,3,0, J prints a field block with a width of 1800 points, a maximum of 3 lines, justified.

The problem is that if the text exceeds the maximum number of lines, it overwrites the last line! :( This, of course, makes the text of the last line unreadable.

How can i avoid this? Does anyone know if there is a way to shorten the text?

The documentation states that this is happening:

Text exceeding the maximum number of lines overwrites the last line. Changing the font size automatically increases or decreases the size of the block.

For reference: I am using a Zebra 220Xi4 printer.

Any help would be greatly appreciated. Thanks!

+4
source share
3 answers

Take a look at the ^TB command. The ^FB command is preferable and truncates if the text exceeds the size specified in the TB parameters

+5
source

I had about the same problem that was fixed in my case - although not the most elegant way - to specify a larger number of maximum lines and then format it so that only the first 3 are in the visible area.

In your case, it will be, for example, ^FB1800,7,0,J instead of ^FB1800,3,0,J

This at least fixed it for me right away because I am typing this text at the bottom of the label. If you need to have it somewhere in the middle or top, some tricks may occur with placing a (white) window on top of the overflow area, since Zebra printers seem to display before printing. Hope this helps.

+1
source

Depending on the higher-level programming language that you use (assuming you are), you can do the same thing (truncate the text to be printed to a certain number of characters) with this code (C #, shown here ):

 public void PrintLabel(string price, string description, string barcode) { const int MAX_CAPS_DESC_LEN = 21; const int MAX_LOWERCASE_DESC_LEN = 32; try { bool descAllUpper = HHSUtils.IsAllUpper(description); if (descAllUpper) { if (description.Length > MAX_CAPS_DESC_LEN) { description = description.Substring(0, MAX_CAPS_DESC_LEN); } } else // not all upper { if (description.Length > MAX_LOWERCASE_DESC_LEN) { description = description.Substring(0, MAX_LOWERCASE_DESC_LEN); } } . . . 

This is what I use; is there any reason to prefer the command "raw" ^ TB over this?

0
source

Source: https://habr.com/ru/post/1384707/


All Articles