ZPLPrinter Web API - Unicode UTF8 Text Support
Product ZPLPrinter Web API for Docker Published 01/30/2021 Updated 01/30/2021 Author Neodynamic
Overview
Some ZPL commands could contain Unicode / UTF-8 text in different languages. ZPLPrinter Web API for Docker can preview, render and convert those commands to any image or document formats but some considerations must be taken into account depending on the language to be processed.
- If the ZPL commands contain a reference to TT0003M_.FNT or TT0003M_.TTF fonts, then ZPLPrinter Web API for Docker will render the text without any issues. That font supports Latin, Greek, Cyrillic, Eastern European, Turkish, Arabic, and Hebrew characters.
LIMITATION! If the ZPL commands contains texts in RTL (Right-to-Left) languages like Arabic and Hebrew then it cannot be mixed with non-RTL text inside the same ^FD command. - If the ZPL commands contain a reference to SIMSUN.FNT font, then it's likely that the text is in Chinese (Simplified) language. To allow ZPLPrinter Web API for Docker to render the text, that font must be added to the virtual ZPL printer storage.
- If the ZPL commands contain a reference to ANMDS.TTF, ANMDT.TTF, ANMDJ.TTF, or ANMDK.TTF fonts, then it's likely that the text is in Chinese (Simplified - Traditional), Japanese, or Korean languages. Those fonts are from Andale Mono WT family. To allow ZPLPrinter Web API for Docker to render the text, the involved fonts must be added to the virtual ZPL printer.
- If the ZPL commands contain a reference to any Custom Font (*.ttf), then to allow ZPLPrinter Web API for Docker to render the text, that font must be added to the virtual ZPL printer storage.
How to configure Custom TTF Fonts supporting Unicode CharSet
The following steps show how to configure the ZPLPrinter Web API instance to add support for Arial Unicode TTF font for rendering texts in different languages. The same apporach can be used to render texts when using the aforementioned Asian or any other non-resident fonts.
Please follow up these steps
- Be sure you download the Arial Unicode font (in some Windows systems, that font is located at
c:\Windows\Fonts\ARIALUNI.TTF
). Remember that any added font remain the exclusive property of their specific owners and require a license from their owners. - Once you have the
ARIALUNI.TTF
font file, copy it to the Linux box where the ZPLPrinter Web API instance will be running on. NOTE: Download (pull) the latest ZPLPrinter Web API for Docker image if you have not done this yet. - In the home dir of your Linux box, create the following directoy:
MyPrinterSettings
- Copy the
ARIALUNI.TTF
to theMyPrinterSettings
directory - Create a plain text file and name it to
fonts.json
and then write or copy/paste the following content:
[ { "name": "R:ARIUNI.FNT", "fileName": "ARIALUNI.TTF" } ]
This is a JSON Array for each font you want to upload to the virtual printer storage. Each JSON object representing a given custom font must be specified with thename
of the font that is referenced in the ZPL commands and thefileName
which points to the physical font file.
-
To make the custom fonts available in the virtual printer, we have to mount a volume to the instance in this way:
docker run -it --rm -p 8080:80 neodynamic/zplprinterwebapi:[VERSION] -v ~/MyPrinterSettings:/app/PrinterConfig - And that's all. After running the docker image of ZPLPrinter Web API you can try the following request which includes the ZPL commands references to the custom font.
{ "dpi": 203, "zplCommands":"^XA^CWJ,R:ARIUNI.FNT^FO010,160^CI28^AJN,50,40^FDRoman: ABCDEFGHIJKLMNOPQRSTUVWXYZ^FS^FO010,230^CI28^AJN,50,40^FDCyrillic: ЁЂЃЄЅІЇЈЉЊЋЌЎЏАБВГДЕЖЗИЙКЛМН^FS^FO010,300^CI28^AJN,50,40^FDEastern: ŠŚŤŽŹŁĄŞŻĽľŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎ^FS^FO010,370^CI28^AJN,50,40^FDGreek: ΆΈΉΊΌΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫ^FS^FO010,440^CI28^AJN,50,40^FDTurkish: ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎĞÑÒÓÔÕÖ×ØÙÚÛÜİŞ^FS^FO010,510^CI28^AJN,50,40^PA1,1,1,1^FDزيبرة تكنوليجيز اوربا المحدودة^FS^FO010,580^CI28^AJN,50,40^FDChinese: 中文字符^FS^PQ1^XZ", "zplCommandsCodePage": 65001 }