Search code examples
c#zebra-printerszplepl

c# Zebra Printer SDK: Convert ZPL to EPL2


I'm developing a small app to print labels on Zebra printers, and I used ZPL language and the Zebra Printer SDK package for that.

My app is fully functional with ZPL that I tested on a TLP 2824 Plus, but I discovered the actual printer that will be used is a TLP 2844 that only use EPL language (before any question, the TLP 2824 is defective, so just good for tests).

My printing methods are based on this : https://github.com/Zebra/devtalks/blob/121317-LinkOS_CSharp/BasicWpfPrintApp/MainWindow.xaml.cs

My methods check language and only print ZPL it seems, so I'll have to modify them, but my main problem is switching my string from ZPL to EPL.

Here's my ZPL code:

^XA
^CFA,20
^FB456,1,0,C^FO0,50^FDAR_Ref^FS
^FB252,1,0,C^FO0,80^FDDate^FS
^FB660,1,0,C^FO0,80^FDPrix^FS

^FB456,1,0,C^FO0,138^FDAR_Ref^FS
^FB252,1,0,C^FO0,168^FDDate^FS
^FB660,1,0,C^FO0,168^FDPrix^FS

^FB456,1,0,C^FO0,226^FDAR_Ref^FS
^FB252,1,0,C^FO0,256^FDDate^FS
^FB660,1,0,C^FO0,256^FDPrix^FS

^FB456,1,0,C^FO0,314^FDAR_Ref^FS
^FB252,1,0,C^FO0,344^FDDate^FS
^FB660,1,0,C^FO0,344^FDPrix^FS
^CFA,15
^XZ

Here's the viewer link to see the result.

EPL seems similar to ZPL and I suppose the printing method must be similar, that's why I'm searching to write the same sort of string that the one above and adapt my methods.

Thank you for reading!


Solution

  • So! With the help of:

    I managed to obtain something similar:

    N
    q456
    Q352,56
    A186,20,0,4,1,1,N,"AR_Ref"
    A86,50,0,4,1,1,N,"Date"
    A314,50,0,4,1,1,N,"Prix"
    P1,1
    

    (labels are divided by 4, that just the code for the first one to show as an example).

    I used variables in both EPL and ZPL for horizontal and vertical positions. I didn't find how to center in EPL, so I used the old good C# for that :

    double textLength = myText.Length * 14; // 14 is the horizontal dots number for font 4
    int pos = (int)Math.Floor((width - textLength) / 2 );
    

    (and so on for the desired positions)

    EPL doesn't seem to like the € symbol, and I didn't understand how to use the oR command to do that (nor how to get rid of slashed 0 with the same command, but I could always see that later, at least EPL code is working!).