I want to use the AirPrint API, which is a standard OS printing function, programmatically on an iOS application to print directly to a printer by specifying single-sided printing instead of double-sided printing for the first print after the OS is initialised.
〇Verification environment
・Device: iPad 9 generation
・OS:OS16.6
・Printer model: EPSON PX-S730 / Brother MFC-J7300CDW / Canon G5030 / EPSON PX-M791FT
※All printers used for verification support AirPrint and are capable of duplex printing.
〇Issue
The duplex printing option can be specified from the program using the AirPrint API property "duplex", However, when printing is executed from the program, the specified print option "duplex printing" is not reflected in the AirPrint API.
〇Verification results
Installed the developed print verification app on the device in factory default state, and executed the print process from the app to the printer.
(1st time) Set the property "duplex printing" = duplex or single-sided in the AirPrint API of iOS → In both cases, printing was performed on both sides.
(2nd and subsequent times) Set the property "duplex printing" = duplex or single-sided in the AirPrint API of iOS → In both cases, printing is done on one side.
〇Source Code
The print verification application we developed uses the UIPrintInteractionController class in Swift to specify the printing options for duplex printing. We believe we can specify this by setting "info.duplex = UIPrintInfo.Duplex.none" in the following source code and adding it to printInfo.
func buttonClick(_ sender: Any) {
let printController = UIPrintInteractionController.shared
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "PrintJob from PrintTestApp"
// color
printInfo.outputType = UIPrintInfo.OutputType.general
// duplex mode for the print
printInfo.duplex = UIPrintInfo.Duplex.none // set the single side option
printController.printInfo = printInfo
// PDF printing in project folder
printController.printingItem = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
// printer settings
let printer = UIPrinter(url: URL(string: "ipps://XXXXXXX/ipp/print")!)
// direct printing
printController.print(to: printer, completionHandler: {
controller, completed, error in
guard error == nil else {
return
}
})
}