Search code examples
zebra-printerszpl

How to print price without specyfing location of every part of the text? (ZPL)


The effect he wants to get is:

  • The price is normally printed
  • Near the price I want to print the rest of the price in superscript
  • At the end I want to place currency in subscript.

price label

The problem is that I don't want to specify the location of every part of text.

^XA
^PW480
^FS
^JMA
^MMT
^LS0
^MTD
^CI28
^FO40,11
^FWN
^CF0,16.2,20.7
^FD2144
^FS
^CI28
^FO80,10
^FWN
^CF0,8,8
^FD00
^FS
^CI28
^FO100,10
^FWN^CF0,16.2,17.25
^FDEUR
^FS
^XZ

So the question is that possible to print text after text specifying location only once? Without specifying location to every part of the text?


Solution

  • Use ^FT instead of ^FO, and only specify the X coordinate for the first ^FT.

    By default, ^FT resumes at the point where the previous formatting operation finished, and you can provide a manual override to the X and Y components separately, so you would only provide the Y override for the subsequent ^FTs and let it calculate the X automatically:

    ^FT40,11^A0,16.2,20.7^FD2144^FS
    ^FT,6^A0,8,8^FD00^FS
    ^FT,11^A0,16.2,17.25^FDEUR^FS
    

    Note that you will need to adjust the Y coordinate down, because ^FO lines up with the top of the text line (letters hanging from it) and ^FT lines up with the bottom (letters standing on it).

    Also note that ^CF changes the printer-wide default font, and there is no point to use it before each command. Use ^A instead as shown. You don't need to set ^CI before each command either, it is again a global setting for encoding of the entire label text.