简体   繁体   中英

Print Item detail in ZPL zebra printer

I am working on recipt printing with Zebra printer. I am able to print every thing but i would like to print item detail from database for example i got dataReader and would like to run loop to print all items on recipt .(c#) So how i can run loop in ZPL programming.

^XA
^FX Name og adresse.
^CF0,60
^FO180,50^FDVitec AutoData AS.^FS
^CF0,40
^FO180,100^FDPostboks 545^FS
^FO180,135^FDSentrum^FS
^FO180,170^FDNO-0105 OSLO^FS
^FO50,210^GB700,1,3^FS

^FX Second Section.
^CFA,30
^FO50,240^FDName : ^FS
^FO450,240^FDDate :^FS

^FO50,280^FDcounter: ^FS
^FO450,280^FDTime :^FS

^FO50,340^GB700,1,3^FS

I want to run loop here on DataReader that fetch data from database mysql,

^FX Third part  with barcode.
^CFA,30
^FO50,540^FDMVM's : ^FS
^FO450,540^FD0.00 ^FS

^FO50,580^FDSub Totalt: ^FS
^FO450,580^FD0.00 ^FS
^FO50,620^FDTotalt Amount: ^FS
^FO450,620^FD0.00 ^FS
^FO50,660^FDKontant: ^FS
^FO450,660^FD0.00 ^FS
^CFA,40
^FO50,700^FDBalance: ^FS
^FO450,700^FD0.00 ^FS


^FX Fourth section (the two boxes on the bottom).
^BY5,2,150
^FO140,800^BC^FD122232^FS
^XZ

I do not think you can put a loop into ZPL code, it's a formatting language not a programming language.

You can, however, put the loop in your C# code and build strings that you can then concatenate. Pseudo code:

string ZPL = "^XA ^FX Name...";
foreach( var item in dataReader) {
    ZPL += "^FO50,580^FDSub Total: ^FS" + item.SubTotal + "^FS";
}
ZPL += "^XZ";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM