How do I convert an image to hex for use with ~DG ZPL code?

J Jon-Luke West 3 years 6 months ago
416 2 0

I am using the Zebra SDK with Java on Android.
 
I need to print an image as part of a receipt-type printout, but the only references I can find in the SDK documentation is for printing just an image.  ie. printer.printImage(); in the GraphicsUtil example  But I would like to convert an image for use while sending raw ZPL to the printer.  How would you recommend I accomplish this?  Should I be skipping ~DG altogether and use printer.storeImage(); and then use ^XGFILE.GRF,1,1 in ZPL?
 
Thank you very much!

Please Register or Login to post a reply

2 Replies

E Efkan YILMAZ

Hi Jon-Luke,
Yes, for your use case, you do want to use the printer.storeImage() function.  The storeImage() function can convert many standard image file types, but not all, to the GRF format that the printer understands.  The storeImage() then sends the file to the printer using the ~DG or !CISDF command (I'm not sure which) so you don't have to worry about it.  Then you can use the ^XG command in your print format as you have in your example. This way you only have to send the lengthy image file once per printer and it's remembered.  It shortens the data you send to print each time considerably, yet you still can print nice logos.   printImage() is more designed for if your entire label is an image file.
Robin

J Jon-Luke West

Great to know Robin.

On a related note, if I push an image file with printer.storeImage() using a file name that already exists on the printer will it overwrite?  I want to avoid accidentally filling up the printer memory with orphaned files while I am developing.

Thanks a bunch!

CONTACT
Can’t find what you’re looking for?