Converting Image to Send to Bluetooth Low Energy Printer on IOS

// Expert user has replied.
A Andrew Moultrie 2 years 11 months ago
65 1 0

Hi guys,
 
In our use-case, we want to support users being able to use Zebra printers through our IOS application connecting via Bluetooth Low Energy.  When we go to print, the label that we print may contain a logo (that we want to pre-load onto the printer).
 
Looking at the Zebra SDK, I see the ability to storeImage() onto a printer.  However, as I understand it, this SDK does not support BLE, as it does not have a connection that interacts with CoreBluetooth at all.
 
I have already implemented the logic to send the label to the printer using BLE service/characteristics, etc.  This works perfectly (as long as I stay under the 512 byte limit).  I know there is a ZPL command to store an image (specifically ^DG), and have some familiarity with the way it works.  My problem right now, is trying to implement the logic to go from UIImage (or CGImage) to the correct hex string that the printer will support, so that it can be recalled later onto the labels we want to print.
 
To add to this complexity, these cannot be pre-converted and added statically at build time, because they are dictated by the user of our application.
 
Any help would be greatly appreciated!

Please register or login to post a reply

1 Replies

C Christal Spaeth

Andrew,

In this case, the easiest way to do this is to convert the image to a bitmap/png in base64 format and downloading it using the Download Object command (~DY). The base64EncodedStringWithOptions method will return a base64 encoded string. The ~DY command also handles these image formats better than the ~DG command. The ZPL Manual gives a more in depth explanation on base64 encoding.

Christal

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