5

I'm using the following command to print a justified text:

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

The command ^FB1800,3,0,J prints a field block in a width of 1800 dots, maximum 3 lines, justified.

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

How can I avoid that? Does anybody know if is there a way to cut the exceeding text?

The documentation says exactly that this happens:

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'm using printer Zebra 220Xi4.

Any help would be appreciated. Thank you!

Rodrigo Pires
  • 574
  • 2
  • 11
  • 23

3 Answers3

7

Take a look at the ^TB command. It is preferred over the ^FB command and truncates if the text exceeds the size defined in the TB params

Ovi Tisler
  • 6,425
  • 3
  • 38
  • 63
  • Hi, thanks for the reply. I found the ZPL Guide with the ^TB command. It says this command is available only for printers with firmware version V60.14.x, V50.14.x, or later. My printer has the firmware version V53.17.9Z. Therefore, the command didn't work, was not interpreted... Any tip? – Rodrigo Pires Dec 05 '11 at 16:47
  • V53 is a later version of V50, so the TB command would work. I just tried it on my ZM400, V53.17.11. Just remember, the params are different than the ^FB command, so you have to modify them, you might also need to move your ^FT command, or you might not need it anymore – Ovi Tisler Dec 06 '11 at 03:46
  • I've managed to print using the TB command, I believe the problem was in the first parameter. Now, the main reason I was trying to use the FB command was because of the possibility to use the TEXT JUSTIFICATION = J (Justified). I want the Text block to be printed as "justified" (i.e. just like MS Word does). Do you know how can I achieve that using the TB command? – Rodrigo Pires Dec 06 '11 at 12:13
  • 1
    I guess I'm looking for a way to use both FB and TB commands combined. FB for JUSTIFIED alignment, and TB to truncate the text without overwriting the last line. I'm trying to combine them here, but.... so far, got nothing... =/ – Rodrigo Pires Dec 06 '11 at 12:37
  • 1
    Note that for it to work, the `^TB` command must be set *after* the font selection command (`^Ax`). This is documented in the notes here: https://support.zebra.com/cpws/docs/zpl/TB_Command.pdf - Also make sure there's a comma before the first numerical param, like so: `^TBN,100,300` – gregschlom Feb 22 '17 at 04:55
1

I had just about the same problem, what fixed it in my case - although not the most elegant way - is to specify a higher number of maximum lines, and then formatting it in a way that only the first 3 are in the visible area.

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

This at least fixed it for me right away, because I print this text at the bottom of the label. If you need to have it somewhere in the middle or top, there might be some tricks with putting a (white) box on top of the overflow-area, since the Zebra printers seem to render before printing. Hope it helps.

Levite
  • 17,263
  • 8
  • 50
  • 50
0

Depending on the higher-level programming language you're using (assuming that you are), you could accomplish the same thing (truncate the text to be printed to a specified number of characters) with code like this (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'm using; is there any reason to prefer the "raw" ^TB command over this?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862