ZPL - Zebra Concatenate 2 values - zebra-printers

I would like to concatenate 2 values in the Zebra Programming Language (ZPL)
Var FN3 contains: 123456
This line currently prints the value 123456
^FO260,90^A0N,70,50^FN3^FS
^FO: field orientation, with coordinates.
^AON: font type and size
^FN3: variable
^FS: field stop
I tried this:
^FO260,90^A0N,70,50^FDP^FN3^FS
So we want to have printed: P123456
I cannot find any concatenate function or how to do this in the label.
Any tips or tricks or functions I do not know about?

The usual way to achieve that result is to use ^FT rather than ^FO, for example:
^FT260,160^A0N,70,50^FDP^FS^FT^A0N,70,50^FN3^FS
Note the second ^FT with empty parameters. That indicates to continue formatting the text where the last ^FT left off.
Unfortunately, using ^FT means you have to change your coordinates, specifically, your y values. ^FO positions from the upper left corner. ^FT positions from the baseline of the text.

Related

ZPL data printing at label

I have to print data from DATA_FIELD that can contain between 5 to 50 characters
and label can fit just 20 letters
due i have right to left spelling words i have to print always top 20 letters from right other wise ill loose 1st words of customer name and its usually most important because contains name of the customer
for example i have a code
^FO40,240^A#N,40,40,E:DAVIDBD.FNT
^FD%%Depositor%%
^FS
thats depositor name is:
i dont know why its so long name -- can be variable
and i have to print always last 20 letters as:
its so long name --can be variable
will be happy to get any tips or help
Regards
There really isn't much ZPL can do to help. ZPL is really a page description language, not a programming language.
You will need to process the string to the correct length before adding it to your label code. If you are not using a mono spaced font, then you will have to accommodate for the variable character width.
If you are using a monospaced font you simply have to know how many characters will fit in the area you are trying to print.
If you can wrap text, you might make use of the Use the ^FB – Field Block command in the manual

ZPL to print strike through

Is there a way to use ZPL to print text with a strikethrough (a line through the text)?
I need to be able to print something and indicate that it was there. I have looked through the ZPL programming guide and I have not found any way to alter the font....
An alternative approach would be to draw a line through your text. Here is a sample. You would need to calculate the points of the line based on the coordinates of the text:
^XA
^FT62,93^A0N,42,40^FH\^FDstrikethrough^FS
^FO41,76^GB268,0,5^FS
^PQ1
^XZ
AFAIAA, No.
Could you simply draw a line over the required text? Perhaps you could use or manufacture a downloaded bitmap font which is "struck through?"
OTOH...
To underline - use a monospaced font like AA,AC,AD,AF or AG
Use
^FO350,50^AGR^FDwhatever,milk,butter,salt^FS
^FO340,50^AGR^FD ____ ______^FS
where the underline here is under milk and butter, you can adjust the offset by trimming the FO's X and Y positions by a few dots (10 X here). Naturally, that can be raised for strikethrough, too...

ZPL Center text vertically

Is there a way in ZPL to center text vertically?
I know I can use ^FO0,0^ASN,50^FB200,3,0,C,0^FD TEXT ^FS. But how can I make that print on the 2nd line if it's short enough?
There isn't a vertical centering feature, but you can fake it, if you know in advance that your string is short enough to fit on the middle line.
Your ^FB defines a field block that is three lines. So your best option is to determine if your string fits on one line... and if it does, insert a "\&" before your string.
^FO0,0^ASN,50^FB200,3,0,C,0^FD\&TEXT^FS

ZPL - how to right justify a bar code?

I am trying to right justify a bar code I am printing using ZPL from a .Net program. Here is my current code:
^FO10,50^FB500,1,0,R,0^AO,40,40^BY3^BCN,100,Y,N,N^FD1234567^FS^XZ
The Field Block seems to be ignored when working with a bar code, but for text it justifies it correctly. Any ideas?
Newer Zebra firmware supports a third parameter on ^FO and ^FT. If you want to right justify something, specify the right edge as the x parameter, and include a 1 as the third parameter.
^XA
^BY3
^FO85,30^GB500,450,3^FS
^FO100,50^BCN,30,Y,N,N
^FD>;12345678^FS
^FO100,120N^BCN,30,Y,N,N
^FD>;123456^FS
^FO100,190^BCN,30,Y,N,N
^FD>;1234^FS
^FO570,260,1^BCN,30,Y,N,N
^FD>;12345678^FS
^FO570,330,1^BCN,30,Y,N,N
^FD>;123456^FS
^FO570,400,1^BY3^BCN,30,Y,N,N
^FD>;1234^FS
^XZ
We had the same issue at our company. The barcode doesn't respond to the Field Block. Based on your example since you are using ZPL commands directly to generate your barcode (as opposed to an image of a barcode), you could do something similar to how we did. We know roughly how wide the barcode is going to be based on the data we write to it. So we created a method to determine the x-axis location of the barcode based on our also known label widths.
For example: We use the s4M printers and estimate the full label width to be about 780 dots wide. So in order to left/center/right justify, we take the rough barcode (estimated) width and calculate accordingly (left is set to xaxis = 0, center is set to xaxis = ((780 - barcodeWidth) / 2), and right justified would be xaxis = (780 - barcodeWidth). It isn't a perfect solution but is very close at least for our needs. You could certainly be more precise in your algorithm by looking at more barcode setting information like the data square size, columns, rows, etc... depending on your needs.
If you were to come up with a solution of generating an image of a barcode (which is what we are also trying to come up with now) then you should be able to easily get the width of the barcode image using build in .net graphics functionality.

Position of Text in a TextBox

Hi I have a textbox containing some text. I am looking to replicate the red spelling mistake squiggle type behaviour.
Using WinAPI I can
draw the squiggle between 2 points.
find out the height and width of
the word to be "squiggled".
What is the api call (or perhaps the methodology if it is more than a single api call) to find the position of that word in the text box so that I can position the sqiggle undeneath it.
Also, what are the messages I need to trap to ensure that the squiggle is redrawn. I'm currently only using WM_PAINT, which obviously isn't good enough.
EDIT (3 Sept 2012):
FYI, Here's where I got to so far. Needs a lot of refining but shows basic principles
https://gist.github.com/3607272
Many thx
S
What might work is using an auto-sized label. Make sure the fonts in the label and textbox are identical.
Detect the number of rows that are before the sentence containing the misspelled word.
Fill the label caption with the number linefeeds (vbcrlf) you got from question 1.
Append the words from the misspelled line (up to the misspelled word) to the labels caption.
The label size should now be identical with the beginning of the misspelled word.
Example text:
This is my first line.
And my second line.
And over here i have my mispeled word.
Label caption output should be (ignore the dots, they are empty lines):
.
.
And over here i have my
The labels height and width should match the position in the textbox, unless you have scrollbars. If the textbox has borders then you should add a fixed value to the height and width to get an exact match.

Resources