[C#] How to create a ZPL from a EMF/PDF byte array



here the background to the question:

In our company we have a webservice from which we can retrieve various labels as a base 64 encoded byte array. The format of the returned array can either be a PDF or an EMF.

The task is to create a valid ZPL string for the returned byte array and store this ZPL string in a database. From there it will retrieved and then send to the printer when required.

What is the easiest way to achieve this?

Within the demo solution of the SDK there is this method which creates a demo file.
The essential line i think is the following, where the "TEST" is the only real content:

configLabel = Encoding.UTF8.GetBytes("^XA^FO17,16^GB379,371,8^FS^FT65,255^A0N,135,134^FDTEST^FS^XZ");
Now, would it be sufficient to add the content of the EMF/PDF ase the content of the ZPL string, with changing the commands regarding size and format?
Is there a possibility to achieve this? Maybe even as easy as sending the byte array to a printer or printer driver and get the formatted ZPL string as result returned?


Submitted by Greg Foote on May 04, 2019 Permalink

Robin what file types are supported by PrinterUtil.ConvertGraphic ?

Here is the code I am using

Stream s = new MemoryStream();
            var zImage = ZebraImageFactory.GetImage(filePath);
            PrinterUtil.ConvertGraphic("", zImage , s);