Print image on iPad with swift

Hi,

I am trying to print image via bluetooth with following swift code:

    func printImage(){

        var serialNumber = ""

        let sam: EAAccessoryManager = EAAccessoryManager.shared()

        let connectedAccesories = sam.connectedAccessories

       

        for accessory in connectedAccesories {

           

            if accessory.protocolStrings.index(of: zebraProtocol) != nil {

                serialNumber = accessory.serialNumber

                break;

            }

        }

       

        let printerConn = MfiBtPrinterConnection.init(serialNumber: serialNumber)

        _ = printerConn!.open()

       

        let printer = try! ZebraPrinterFactory.getInstance(printerConn)

        let image = UIImage(named: "image1")?.cgImage!

        DispatchQueue.global(qos: .background).async {

            try! printer.getGraphicsUtil()?.print(image, atX: 0, atY: 0, withWidth: 400, withHeight: 300, andIsInsideFormat: true)

        }

    }

But it gives this error:

ERROR - /BuildRoot/Library/Caches/com.apple.xbs/Sources/ExternalAccessory/ExternalAccessory-383.250.1/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 332 failed to write because stream does not have space available

How should i print images with ZQ510 ?

Thanks