iOS Barcode Printing - black rectangle


I'm trying to print a barcode onto a label but it just prints a black rectangle in the shape of the barcode image.

To generate the barcode I'm using the following:

            let data = "Hello".data(using: .ascii)

            let filter = CIFilter(name: "CICode128BarcodeGenerator")

            filter?.setValue(data, forKey: "inputMessage")

            return UIImage(ciImage: (filter?.outputImage)!)

When I send this to the printer using ZebraPrinter.getGraphicsUtil().printImage(...) it just prints out a black rectangle as mentioned.

I imagine it is some problem with the format of the generated barcode image as it prints out images taken from the iPads camera ok.

Any help on this would be much appreciated.

Kind Regards