AirPrint

RSS for tag

AirPrint allows photo and document printing in your iOS apps and macOS apps without the need to download or install drivers.

Posts under AirPrint tag

27 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

After initializing the OS, the AirPrint API always prints on duplex when printing for the first time.
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 } }) }
0
0
807
Aug ’23
PrintKit crash +[_PK_OneShotXPC withTimeout:doSyncronousOneShot:]
Watchdog killed the app because PrintKit is performing XPC operations on the main thread,see the call stacks below. __dispatch_sema4_timedwait __dispatch_semaphore_wait_slow +[_PK_OneShotXPC withTimeout:doSyncronousOneShot:] __pk_mdns_resolveSynchronous -[PKPrinter(PKPrinterPrivate) resolveWithTimeout:] -[PKPrinter printerURL] -[UIPrinter _initWithPrinter:] -[UIPrinterSelectionOption setPrinter:] -[UIPrinterBrowserViewController tableView:didSelectRowAtIndexPath:] -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:isCellMultiSelect:deselectPrevious:performCustomSelectionAction:] -[UITableView _userSelectRowAtPendingSelectionIndexPath:] -[_UIAfterCACommitBlock run] -[_UIAfterCACommitQueue flush] __runAfterCACommitDeferredBlocks __cleanUpAfterCAFlushAndRunDeferredBlocks __UIApplicationFlushCATransaction __UIUpdateSequenceRun _schedulerStepScheduledMainSection _runloopSourceCallback ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ___CFRunLoopDoSource0 ___CFRunLoopDoSources0 ___CFRunLoopRun _CFRunLoopRunSpecific _GSEventRunModal -[UIApplication _run] _UIApplicationMain main main.m:26 start
0
0
655
Jul ’23
PrintKitUI random crash
Code to print self.airPrintWebView.loadHTMLString(html, baseURL: nil) self.view.add(subView:self.airPrintWebView) let formatter = self.airPrintWebView.viewPrintFormatter() //1.5" margins for the page formatter.perPageContentInsets = UIEdgeInsets(top: HALF_INCH_INSET, left: ONE_INCH_INSET, bottom: ONEHALF_INCH_INSET, right: ONE_INCH_INSET) let activityVC = UIActivityViewController(activityItems: [formatter], applicationActivities: nil) // Prevents iBook and PDF from being options activityVC.excludedActivityTypes = [.openInIBooks, .markupAsPDF] activityVC.completionWithItemsHandler = { (activity, success, items, error) in self.airPrintWebView.removeFromSuperview() if shouldRemoveSenderButton { sender.removeFromSuperview() } PredictSpringApplication.sharedInstance.psAlertBlockView?.isHidden = false } if PSUtil.isIpad() { activityVC.popoverPresentationController?.sourceView = self.airPrintWebView activityVC.popoverPresentationController?.sourceRect = sender.frame } self.present(activityVC, animated: true, completion: nil) Crash Crashed: com.apple.main-thread 0 CoreGraphics 0x107e6c CGPDFDocumentIsEncrypted + 12 1 PrintKitUI 0x586b0 -[UIPrintPreviewPageFetcher redrawQuicklookPDF:] + 104 2 PrintKitUI 0x28f4c -[UIPrintPreviewViewController updateQuicklookPDF] + 148 3 Foundation 0xa6f14 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 24 4 Foundation 0x7b020 -[NSBlockOperation main] + 104 5 Foundation 0x7afb0 NSOPERATION_IS_INVOKING_MAIN + 16 6 Foundation 0x3c4d8 -[NSOperation start] + 708 7 Foundation 0x3c20c NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION + 16 8 Foundation 0x4189c __NSOQSchedule_f + 172 9 libdispatch.dylib 0x12fc4 _dispatch_block_async_invoke2 + 148 10 libdispatch.dylib 0x3eac _dispatch_client_callout + 20 11 libdispatch.dylib 0x126a4 _dispatch_main_queue_drain + 928 12 libdispatch.dylib 0x122f4 _dispatch_main_queue_callback_4CF + 44 13 CoreFoundation 0x98c28 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16 14 CoreFoundation 0x7a560 __CFRunLoopRun + 1992 15 CoreFoundation 0x7f3ec CFRunLoopRunSpecific + 612 16 GraphicsServices 0x135c GSEventRunModal + 164 17 UIKitCore 0x39d6e8 -[UIApplication _run] + 888 18 UIKitCore 0x39d34c UIApplicationMain + 340 19 PSStore 0xbaa0 main + 2 (main.swift:2) 20 ??? 0x1b94fedec (Missing) Any body able to solve this random crash ?
7
0
1.1k
Sep ’23
How to print double-sided pages using UIPrintInteractionController(AirPrint) in Swift
I'm using UIPrintInteractionController(AirPrint) to print documents in my swift application. I was able to print the documents using my application, but all of them are printing in one-sided. Now i want to add a double-sided printing as an option to my application. After some research i found that it can be implement by adding info.duplex = UIPrintInfo.Duplex.longEdge to printInfo. I tried it using the below code. private var printController = UIPrintInteractionController.shared let info = UIPrintInfo.printInfo() info.duplex = UIPrintInfo.Duplex.longEdge <<<<<< info.jobName = "XXXPrint" info.orientation = .portrait printController.printInfo = info printController.print(to: printer, completionHandler: { [self] controller, completed, error in if(error != nil){ print("successfully") }else{ print("Printing error: \(error.localizedDescription)") } } But whether i set it in the code and run my application it is printing the pages by one-sided. So if some one can guide me to double-sided printing workable solution highly appreciated!!
0
0
919
Jul ’23
Crash when presenting UIPrintInteractionController on iOS 16
Starting iOS 16 seeing some crashes related to pdf printing in the crash reporter. It looks like the issue is not so frequent. Also, I'm unable to reproduce the crash. Looks like the app crashes when the print preview dialog is opening. According to crash reports, there are some crashes on different iOS 16 versions: 16.0.0, 16.0.2, and 16.0.3. Printing code: let printInfo = UIPrintInfo.printInfo() printInfo.jobName = "Printing Job Name" self.printViewController = UIPrintInteractionController.shared self.printViewController?.printInfo = printInfo self.printViewController?.printingItem = pdfURL self.printViewController?.present(from: barButtonItem, animated: true) { (controller, completed, error) in self.printViewController = nil } Stack trace: compare_key + 4 (CGPDFObject.c:134) bsearch + 68 (bsearch.c:70) CGPDFDictionaryGetUnresolvedObject + 68 (CGPDFDictionary.c:153) CGPDFDictionaryGetObject + 44 (CGPDFDictionary.c:172) CGPDFDictionaryGetDictionary + 44 (CGPDFDictionary.c:284) get_pages_dictionary + 68 (pdf-reader.c:410) pdf_reader_get_number_of_pages + 76 (pdf-reader.c:557) -[UIPrintPreviewPageFetcher fetchNumberOfItems] + 76 (UIPrintPreviewPageFetcher.m:115) -[UIPrintPreviewViewController collectionView:numberOfItemsInSection:] + 32 (UIPrintPreviewViewController.m:482) -[UICollectionViewData _updateItemCounts] + 220 (UICollectionViewData.mm:335) -[UICollectionViewData isIndexPathValid:validateItemCounts:] + 52 (UICollectionViewData.mm:348) -[UICollectionViewData validatedGlobalIndexForItemAtIndexPath:] + 36 (UICollectionViewData.mm:778) -[UICollectionView _cellForItemAtIndexPath:] + 108 (UICollectionView.m:7112) -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 1384 (UICollectionView.m:9357) -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] + 396 (UICollectionView.m:9104) -[UICollectionView reloadItemsAtIndexPaths:] + 52 (UICollectionView.m:9124) -[UIPrintPreviewViewController reloadVisibleItems:] + 256 (UIPrintPreviewViewController.m:568) __63-[UIPrintPreviewViewController updatePdfURL:options:completed:]_block_invoke_2 + 44 (UIPrintPreviewViewController.m:305) __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSOperation.m:1545) -[NSBlockOperation main] + 104 (NSOperation.m:1564) __NSOPERATION_IS_INVOKING_MAIN__ + 16 (NSOperation.m:2189) -[NSOperation start] + 708 (NSOperation.m:2206) There is full stack trace I got from the Organizer Thanks!
12
5
3.5k
Oct ’23
UIPrintInteractionController - Print dialog opens then disappears in iOS 16
I'm using UIPrintInteractionController to display the standard printing window to print a PDF file, passed as NSData using 'setPrintingItem'. Everything was working fine until iOS 16. Now when I call 'presentAnimated', the printing window briefly appears before immediately closing again. In the Xcode debug window I see layout constraint errors - see text below. I don't think I can affect the layout constraints of the print controller? 2022-09-13 16:57:43.220970+0100 myiOSApp[11359:185527] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x6000022e23a0 h=--& v=--& UIView:0x7fa0e588e5a0.minX == 0.5 (active, names: '|':UIView:0x7fa0e588bbe0 )>", "<NSAutoresizingMaskLayoutConstraint:0x6000022e3160 h=--& v=--& UIView:0x7fa0e588bbe0.minX == 0 (active, names: '|':UIPrintPreviewPageCell:0x7fa0e588e060 )>", "<NSLayoutConstraint:0x6000022e0f00 UIView:0x7fa0e588e5a0.leading == UIPrintPreviewPageCell:0x7fa0e588e060.leading (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000022e0f00 UIView:0x7fa0e588e5a0.leading == UIPrintPreviewPageCell:0x7fa0e588e060.leading (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2022-09-13 16:57:43.221720+0100 myiOSApp[11359:185527] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x6000022e23a0 h=--& v=--& UIView:0x7fa0e588e5a0.minX == 0.5 (active, names: '|':UIView:0x7fa0e588bbe0 )>", "<NSAutoresizingMaskLayoutConstraint:0x6000022e2fd0 h=--& v=--& UIView:0x7fa0e588e5a0.width == 124.438 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x6000022e3160 h=--& v=--& UIView:0x7fa0e588bbe0.minX == 0 (active, names: '|':UIPrintPreviewPageCell:0x7fa0e588e060 )>", "<NSLayoutConstraint:0x6000022e0fa0 UIView:0x7fa0e588e5a0.trailing == UIPrintPreviewPageCell:0x7fa0e588e060.trailing (active)>", "<NSLayoutConstraint:0x6000022e32a0 'UIView-Encapsulated-Layout-Width' UIPrintPreviewPageCell:0x7fa0e588e060.width == 125 (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000022e0fa0 UIView:0x7fa0e588e5a0.trailing == UIPrintPreviewPageCell:0x7fa0e588e060.trailing (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2022-09-13 16:57:43.232533+0100 myiOSApp[11359:185527] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x6000022e05a0 h=--& v=--& UIView:0x7fa0e5895a60.minX == 0.5 (active, names: '|':UIView:0x7fa0e5891520 )>", "<NSAutoresizingMaskLayoutConstraint:0x6000022e1630 h=--& v=--& UIView:0x7fa0e5891520.minX == 0 (active, names: '|':UIPrintPreviewPageCell:0x7fa0e58902c0 )>", "<NSLayoutConstraint:0x6000022e0500 UIView:0x7fa0e5895a60.leading == UIPrintPreviewPageCell:0x7fa0e58902c0.leading (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000022e0500 UIView:0x7fa0e5895a60.leading == UIPrintPreviewPageCell:0x7fa0e58902c0.leading (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2022-09-13 16:57:43.233227+0100 myiOSApp[11359:185527] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "<NSAutoresizingMaskLayoutConstraint:0x6000022e05a0 h=--& v=--& UIView:0x7fa0e5895a60.minX == 0.5 (active, names: '|':UIView:0x7fa0e5891520 )>", "<NSAutoresizingMaskLayoutConstraint:0x6000022e0410 h=--& v=--& UIView:0x7fa0e5895a60.width == 124.438 (active)>", "<NSAutoresizingMaskLayoutConstraint:0x6000022e1630 h=--& v=--& UIView:0x7fa0e5891520.minX == 0 (active, names: '|':UIPrintPreviewPageCell:0x7fa0e58902c0 )>", "<NSLayoutConstraint:0x6000022e0690 UIView:0x7fa0e5895a60.trailing == UIPrintPreviewPageCell:0x7fa0e58902c0.trailing (active)>", "<NSLayoutConstraint:0x6000022e14f0 'UIView-Encapsulated-Layout-Width' UIPrintPreviewPageCell:0x7fa0e58902c0.width == 125 (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x6000022e0690 UIView:0x7fa0e5895a60.trailing == UIPrintPreviewPageCell:0x7fa0e58902c0.trailing (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
5
1
2.7k
Oct ’23
printInteractionController choosePaper called multiple times with iPadOS15
I am having problems printing a pdf file in an iPad app when running iPadOS15 or later. With previous iPadOS versions, the choosePaper delegate method is called just once, and is called with a paperList of several valid entries (30 in the case of my printer). Since iPadOS 15, the call is made numerous times. Firstly, it is called a few time with 0 entries in the paperList. Then it is called with the correct number (30 in my case) of entries. But then it is called several more times, with just 1 (and incorrect) entry in the paperList. Has anyone else come across this?
2
1
1.8k
Oct ’23