Text is printed incorrectly using ZPL - zpl

I print a text using ZPL but they are printed incorrectly. It has gaps in the middle. They are printed correctly to the real printer via the ZebraDesigner. But they are wrong when printing via ZPL:
^FT246,70^A0R,16,16
^FB900,2,,
^FDMaisstaerke, Austernuce, Cashewnuss,Pilz, Mais, Lattich, Pack Choi,Sojasprossen^FS
It is printed as 'Maisstaerke, Austernuce, Cashewnuss,Pilz, Mais, Lattich, Pack Choi, Sojasprossen'
(there is a big gap after 'Mais,').
http://screencast.com/t/sTiaxC3cMg
http://screencast.com/t/0QkypnsPyF89
Please help.
Thanks

I'm unable to reproduce the issue, but the field block width seems rather large; you didn't specify any label dimensions in the original post. If you use the following code--a combination from the original post and your comments:
^XA
^PW560
^LL560
^LS0
^FO246,70^GB28,300,,^FS
^FT246,70^A0R,16,16 ^FB300,2,, ^FDMaisstaerke, Austernuce, Cashewnuss,Pilz, Mais, Lattich, Pack Choi,Sojasprossen^FS
^PQ1,0,1,Y
^XZ
I can reproduce what is possibly the issue--the field block automatic word wrapping--by reducing the field block width to 300 dots.
I also drew a box around the block for visualization. You can test in on the Labelary Viewer.
Finally, if you're somehow composing the data make sure there are no special (non printable, such as tab, non-UTF-8 or accented) characters in it, and if so, you will have to pre-escape them.

Related

ZebraDesigner - Saving zpl code does not actually save code as zpl

title might be a bit weirdly formulated, so let me try to explain:
I use ZebraDesigner 3 Essentials in order to make a label. I then "print to file", which leaves me with a .prn containing code. I also tried the answer from this question:
How to get ZPL code from a ZebraDesigner label?
, leaving me with a .zpl file, which has the same content as the .prn file.
That content is similiar to zpl, but it seemingly is not the same. This is the result of a simple label, where "Text" is in the middle of it:
CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD20^JUS^LRN^CI0^XZ
^XA
^MMT
^PW1046
^LL0267
^LS0
^FO448,96^GFA,00768,00768,00012,:Z64:
eJzl0TEOQiEMBuASho69gb2I4V3rDcRg3sHEm3CEjh2M6PMV0Lg4GBc7fUMD/w8AfzBUq7zZpWF8NfgMnxhlmC+Y8SQPT1dfyBzZCU+bZ0oSbF8w6b7Zpxg3u+Jz0GEWc62ZyzDlYWwu93pP7vur2zniIEi/N0cdGdQywIzHnvPAruzMay9G6X1pUXsHSnjWL/7Yz+YGfRNqLw==:7BBD
^PQ1,0,1,Y^XZ
The second line from the button upwards is the problem, I believe. Around there is where, normally, "Text" would be standing, however, now there's just gibberish.
I absolutly need this to be saved correctly, as I later need to access it via python. Please help me by explaining why this happens, and / or how I can fix this.
You need to use a font that is built into the printer. If you set the font to Zebra 0 you get something like:
CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR4,4~SD22^JUS^LRN^CI0^XZ
^XA
^MMT
^PW812
^LL1218
^LS0
^FT160,391^A0N,135,134^FH\^FDhello^FS
^PQ1,0,1,Y^XZ

Prevent ugly kerning when using DrawText

I use simple GDI DrawText to output blocks of text to a printer.
The font used in the sample is Segoe UI. But you can use Arial or others too. It doesn't matter.
The algorithm for large text blocks is simple. DrawText is called with DT_CALCRECT with a kind of binary search for the length to get the largest possible text to print. Than DrawText is called without DT_CALCRECT to print the block.
Simple one line text column text is written with one call to DrawText with the given coordinates of the rectangle.
The result is real strange and can be seen in this sample PDF.
Just look on the first line after the header. You can see the text "Test, Test" and you can see the strange kerning here perfectly. The kerning os sometimes so bad, that you can't even read the words.
How to get around this? Is it a problem with the used printer? Is it a problem with DrawText?
The distance between some chars in a word seem to be random in some case. Some spacing are wide other to narrow. The letter combination looks strange unreadable and ugly.
I tried different fonts and printers but the problem just varies but it is always present.
I know about ExTextOut and the capabilities to define the distance/kerning between all chars, but frankly I don't want to care about this. I just want that DrawText behaves on the printer like on the screen. The stuff works on the screen perfectly.
Added 2018-08-23 08:49 GMT+2*
To the code (it is a complex printing engine).
1.Fonts to print are created simply with CFont::CreatePointFont, so the LOGFONT structure is cleared to zero and no additional flags are used except point and face.
2.The mapping mode is MM_ANISOTROPIC. To scale what is seen on the screen and what is to be printed I just use the size of a komparable object (textblock) on the printer and the same size on the screen. The real values for the sample printout to the Microsoft PDF Printer are as follows, the real way I calculate them is not of interest:
m_pDC->SetMapMode(MM_ANISOTROPIC);
m_pDC->SetViewportExt(2363,100);
m_pDC->SetWindowExt(355,13);
This has the effect that the height of a line in LPs is 13, the average character width in LPs is 6...

ZPL command how to reduce a barcode's size of the same ratio?

I would like to reduce my barcode's size but still be the same ratio like picture below.
From
Original Size
To be
Reduced Size
Here is my ZPL code.
^XA
^FO50,20
^BY2,2,20
^BCN,,N,N,N,D
^FDZWW011601512345^FS
^XZ
Please help me how do I deal with it?
Thank you.
This website is great for testing against: http://labelary.com/viewer.html.
Assuming you don't want the position to move it should just be changing
^BY2,2,20
to
^BY1,1,10
The API Reference guide can be found https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-pm-en.pdf
Don't forget to take into consideration the print density, i.e. at 152 DPI you probably want something like
^FO150,20
^BY1,1,10
But at 600 DPI
^FO550,80
^BY4,1,40
EAN-13 Text Modifications
If you are using the the inbuilt EAN-13 text function i.e. ^BEN,40,Y,N you can't modify the text. It is to a standard. You can however add your own text e.g.
^XA
^FO100,20
^BEN,40,N,N
^FD011601512345^FS
^CF0,48
^FO90,80^FD011601512345^FS
^XZ
^BEN,40,N,N The first N tells the printer to not generate the number underneath.
^CF0,48 Is the select font function of the printer, its first parameter is a default printer font (can be found in the Standard Printer Fonts section of the link above). The second parameter is the font height. If needed there can be a 3rd parameter which alters the font width, though isn't needed.
^FO90,80^FD011601512345^FS Sets the field origin of the string starting at the location defined by ^FO. ^FDXXXXXXXX^FS draws the string.

Matlab Text mode subscripts too big in axis label (LaTeX interpreter)

If I have the axis label $x_\textrm{ABC}$, the ABC is way too big. I tried $x_\textrm{\scriptsize ABC}$ and $x_\textrm{\tiny ABC}$, but that prevents the LaTeX code from being interpretted (I end up seeing the raw code instead of the formatted math). How does one shrink the subscript text size when the subscript is a name that needs to be spelled in text mode?
I posted this to usenet yesterday, but no response so far.
I also tried to modify the text in Acrobat Pro, but I can't actually highlight the individual series of characters (it's the y-axis label).
Finally, I tried to modify it in inkscape, but same problem.
A respondent at the usenet link provided the answer: To use \mathrm instead of \textrm. It looks way better.

Which should not be included in this ZPL Code?

I am developing a Windows Mobile App that requires printing into a Zebra printer. Problem is, I do not have the printer with me here in my country since the client did not provide any.
My approach was to design a label first in ZebraDesigner2, then print out the label into a text file. Printing the label to a text file instead of a printer sends out the ZPL Code to produce the label I was trying to print. Hence, I can generate ZPL codes faster by designing a label first then seeing the ZPL code. Kinda like having a drag and drop GUI with a background XML.
Say that I have this simple label that contains this text:
Hello World!
If I print this in ZebraDesigner2 it would be written to my text file as:
CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR5,5~SD15^JUS^LRN^CI0^XZ
^XA
^MMT
^PW609
^LL0406
^LS0
^FT1,29^A0N,28,28^FH\^FDHello World!^FS
^PQ1,0,1,Y^XZ
My main question is, which one do I include in my C# Code if im going to send this code to the printer via my Windows Mobile C# app? Do I include the part with ^XA until ^XZ? I believe that CT~~CD,~CC^~CT~ should not be included in my code If im not mistaken.
Late answer, but since this is getting viewed...
The CT line and first set of XA..XZ sequence sets up the modes, label length, printable area, etc.
If you remove those, it will take those settings from the label/printer settings, which is usually what you want. The printers can sense the length and width of the label.
Leaving them in can cause big problems, because if you define the printable area in your label, and then the next label type submitted does not, it will use the settings you have defined -- which can cause blank areas in the label, eg. cutoff USPS Label barcodes that are printed after your Zebra Designer custom labels.
Found this out the hard way - leave those out, and you should leave out of the remaining XA..XZ sequence the MMT, PW609, LL0406, and LS0 as well - your Hello World will not be affected.
If you really want to limit the area printed to, set up margins inside the printable area, etc, refer to the manual.
you have to look at the programmers guide before you remove anything of the code. The CT~ command for example changes the control prefix.
Search the internet or zebra.com site for "ZPL Programming guide".
So, leave the text file as is and then include that into your windows mobile application.
PS: zebra offers SDKs for label/receipt printers: http://www.zebra.com/gb/en/products-services/software/adapt-software.html
PS2: without a test printer you may get bad final results.

Resources