swift – Can I schedule multi print jobs parallelly in ios using UIPrintInteractionController?


For printing from worker thread to a UIPrinter(whose url i have saved ) i am doing this and able to print :

 func PrintPdfDocument (pDocument:Data)
    {
        // Create a print interaction controller
        let printController = UIPrintInteractionController.shared
        
        // Set the printing options
        let printInfo = UIPrintInfo(dictionary:nil)
        printInfo.jobName = "Print Job "
        printController.printInfo = printInfo
        printController.showsPageRange = true
        
        // Set the PDF document to be printed
        printController.printingItems = pDocument
        
        printController.print(to: defaulttprinter, completionHandler: { (controller, completed, error) in
            if completed {
                print("Printing successful!")
            } else {
                if let error = error {
                    print("Printing failed with error: \(error.localizedDescription)")
                } else {
                    print("Printing was canceled.")
                }
            }
        })
        
    }

When i call PrintPdfDocument (pDocument:Data) function , more than once with diffrent data shown below :

DispatchQueue.global().async {
    PrintPdfDocument (pDocument:data1)
}
DispatchQueue.global().async {
    PrintPdfDocument (pDocument:data2)
}
DispatchQueue.global().async {
    PrintPdfDocument (pDocument:data3)
}

Printer is printing only one document(data1) . For others(data2,data3) call is not executing printController.print (to….) function inside PrintPdfDocument.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img