Printing:

  • To print, call:
let printingStatus: PrintingStatus = try await (printerDetails?.print(template: template!, printingOptions: printingOptions, dontPrintTrailerFlag: true)) ?? PrintingStatus.PrintingFailed)
  • template is the Template object (reference the Open Templates page).
  • printingOptions is the PrintOptions object we initialize (reference below).
  • dontPrintTrailerFlag is a Boolean that represents if we want a trailer on our label.

The SDKs PrintingOptions is used to set CutOptions and the number of copies to print, like:

let printingOptions: PrintingOptions = PrintingOptions()
printingOptions.cutOption = CutOption.EndOfJob
printingOptions.numberOfCopies = 1
printingOptions.isCollated = true
  • Because the print() method is asynchronous, the await keyword is used. This also allows this method to return the result of the print operation after it is finished in the form of a PrintingStatus object.

  • Check the status of the print job like this:

if printingStatus == PrintingStatus.PrintingSucceeded {
    print("Print Successful!")
}
else {
    print("Print Failed!")
}
  • Alternatively, if the desire is to simply print an image instead of a Brady Workstation template, you may use the print method shown below.
public func printImage(image: UIImage) async {
        let printingOptions: PrintingOptions = PrintingOptions()
        printingOptions.cutOption = CutOption.EndOfJob
        printingOptions.numberOfCopies = 1

    do {
            let printingStatus: PrintingStatus = try await (printerDetails?.print(image: image, printingOptions: printingOptions, dontPrintTrailerFlag: false)) ?? PrintingStatus.PrintingFailed

            if printingStatus == PrintingStatus.PrintingSucceeded {
                debugPrint(" Please wait...")
            }
            else {
                debugPrint("Print Failed!")
            }
    }
    catch let error as SdkApiException {
        debugPrint("Printing Error...")
    }
}
  • To convert a PNG, JPG, JPEG, WEBP, or SVG file to a UIImage, simply do:
//The PNG file "bradylogo.png" was selected by a user.
let selection: String = "bradylogo.png"
let imageToLoad =  UIImage(named: selection) ?? UIImage()