Merge XML & ZPL template and print (to file)

What i try to do is to merge an XML file with data and a ZPL file template (created with Zebra Designer for developers) to create a ready-to-print file (or directly print it).

I was using XMLPrinter class, because i thought it would generate a print file combining these 2. However, i discovered it does not do that, it generates a file which has to be send to the printer, where the template is being stored (it only converts the XML). Problem is that we need to work with USB connected printers, so no easy updating of the templates in the printer itself.

So, we would like to central store (and update) the ZPL templates, and use these in our software to combine them locally with an XML file and generate a printfile (ZPL) that is ready to print.

Is that possible with the SDK ? Or should we process the ZPL template with our own to write parser ?

Steven Si
I've not done that personally

I've not done that personally, but I think we can do that if we want to merge the ZPL template with the data from the XML on the application side. If we leave null for destinationDevice parameter in XmlPrinter.print() API, I think the merged content will be in the outputDataStream. Then the application can do another connection.write() to send the content in the outputDataStream to the printer. Give it a try. Hope it works.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Jordy Brouwers
I already tried that, but the

I already tried that, but the output stream only outputs the ZPL of the variables, to be combined in the printer, where i would like to have the complete ZPL (also with the label itself). For now i ended up processing the ZPL as a text file, using RegEx to look for the variables en replace them myself. It works but isn't very elegant.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments