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.

AirPrint Documentation

Posts under AirPrint tag

26 Posts
Sort by:
Post not yet marked as solved
5 Replies
1.1k Views
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 ?
Posted
by
Post not yet marked as solved
0 Replies
882 Views
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!!
Posted
by
Post not yet marked as solved
0 Replies
792 Views
My app is crashing intermittently when showing the printer options to print html data. I am unable to reproduce this crash however here is the stack trace from crash logs Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x9e88 __exceptionPreprocess 1 libobjc.A.dylib 0x178d8 objc_exception_throw 2 Foundation 0x545b4c _userInfoForFileAndLine 3 UIKitCore 0x14bc40 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] 4 UIKitCore 0x21a330 -[UITableView _createPreparedCellForRowAtIndexPath:willDisplay:] 5 UIKitCore 0x219f18 -[UITableView _heightForRowAtIndexPath:] 6 UIKitCore 0x219db4 -[UISectionRowData heightForRow:inSection:canGuess:] 7 UIKitCore 0x44cf98 -[UITableViewRowData heightForRow:inSection:canGuess:adjustForReorderedRow:] 8 UIKitCore 0x5a0ec -[UITableViewRowData rectForRow:inSection:heightCanBeGuessed:] 9 UIKitCore 0x44c520 -[UITableViewRowData rectForGlobalRow:heightCanBeGuessed:] 10 UIKitCore 0x44db74 -[UITableViewRowData globalRowsInRect:canGuess:] 11 UIKitCore 0x480050 -[_UITableViewUpdateSupport _faultInRealHeightsOfNeededElements] 12 UIKitCore 0x4ba2dc -[_UITableViewUpdateSupport _setupAnimations] 13 UIKitCore 0x2efb58 -[UITableView _updateWithItems:updateSupport:] 14 UIKitCore 0x2b3500 -[UITableView _endCellAnimationsWithContext:] 15 UIKitCore 0x271ea4 -[UITableView _updateSections:withUpdateAction:rowAnimation:headerFooterOnly:usingPresentationValues:] 16 UIKitCore 0xe70084 -[UITableView _reloadSectionHeaderFooters:withRowAnimation:] 17 PrintKitUI 0x60468 -[UIPrintOptionsTableViewController hideGatheringPrinterInfo] 18 libdispatch.dylib 0x24b4 _dispatch_call_block_and_release 19 libdispatch.dylib 0x3fdc _dispatch_client_callout 20 libdispatch.dylib 0x127f4 _dispatch_main_queue_drain 21 libdispatch.dylib 0x12444 _dispatch_main_queue_callback_4CF 22 CoreFoundation 0x9a6f8 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE 23 CoreFoundation 0x7c058 __CFRunLoopRun 24 CoreFoundation 0x80ed4 CFRunLoopRunSpecific 25 GraphicsServices 0x1368 GSEventRunModal 26 UIKitCore 0x3a23d0 -[UIApplication _run] 27 UIKitCore 0x3a2034 UIApplicationMain 28 PSStore 0xbaa0 main () 29 ??? 0x1e567c960 (Missing)
Posted
by
Post marked as solved
12 Replies
3.3k Views
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!
Posted
by
Post not yet marked as solved
5 Replies
2.6k Views
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.
Posted
by
Post not yet marked as solved
2 Replies
1.7k Views
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?