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
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?
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 marked as solved
12 Replies
3.2k 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
0 Replies
771 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 not yet marked as solved
0 Replies
866 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
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
602 Views
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
Posted
by
Post not yet marked as solved
0 Replies
715 Views
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 } }) }
Posted
by
Post not yet marked as solved
0 Replies
500 Views
Cannot look at contents of file in Print Queue with Sonoma Before Sonoma, after I selected print in a application, e.g., Word, I could double click on the document stored in the Print Queue and the pages would be displayed. With Sonoma, cannot see file contents?? One last thing pertaining to this Print Queue = I can't delete any of the accumulated "Completed" Jobs .. menu item to delete selected Jobs is dimmed??
Posted
by
Post not yet marked as solved
1 Replies
650 Views
Environment→ ・Device: iPad 9th generation ・OS: iOS17.0.3 ・Printer model: EPSON PX-S730 What I want→ I would like to programmatically use the AirPrint API to directly print from my application to a selected printer specifying the printing as single-side Current issues → After updating the iOS from 16.6.1 to 17 version, when printing programmatically using the AirPrint API, even setting the print options as single-side, it end up printing on double- side. Issue description→ When I run the code below on iOS16.6.1, it prints on single-side,** but after updating to iOS17.0.3, It’s always printing on double-sides.** Also, the Apple Developer Documentation says that the print method disables duplex printing and it's describe in below URL: https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618174-print Test code: let printInfo = UIPrintInfo(dictionary: nil) printInfo.jobName = "Print Job" printController.printInfo = printInfo let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")! printController.printingItem = pdfURL let printer = UIPrinter(url: printerUrl) printController.print(to: printer, completionHandler: { [self] printController, completed, error in if(error != nil){ print("error") }else if completed{ print("completed") }else{ print("cancel") } }) Does anyone knows if it's a bug in iOS17 or am I missing something?
Posted
by
Post not yet marked as solved
0 Replies
554 Views
Environment→ ・Device: iPad 9th generation ・OS:**iOS17.0.3 ・Printer model:EPSON PX-S730 What I want→ I would like to return an error when I submit a printing job, if the printer is not properly connected to the same WIFI as iPad(iOS17). Current issues→ When I run the below code in iOS17, I was able to successfully submit a print job to printer and, printer returns completed(true) as the result. In iOS16 print job return as an error to the same below code. Problem Description→ In iOS 16.6.1 when you know the correct printer access URL and submit a print job without connecting to the same WIFI as the printer, job return as an error.(return to the error code segment in the below code) But after I updated the app to iOS 17.0.3 and run the same job, it's not returning as an error.(it returns to the completed block in the below code segment and completed Boolean value is true. ) When you check the "Print Summary" window in iPad, the status of the print job is Waiting. So I would like to handle this process in the same way like iOS16 in iOS17. I would like to Print Job to return as a error when printer and iPad not connected to same WIFI(error like "cannot connect to the printer") Test code: let printInfo = UIPrintInfo(dictionary: nil) printInfo.jobName = "Print Job" printController.printInfo = printInfo let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")! printController.printingItem = pdfURL let printer = UIPrinter(url: printerUrl) printController.print(to: printer, completionHandler: { [self] printController, completed, error in if(error != nil){ print("error") }else if completed{ print("completed") }else{ print("cancel") } }) Does anyone knows if it's a bug in iOS17 or am I missing something?
Posted
by
Post not yet marked as solved
1 Replies
550 Views
Hey, fellow iOS developers! I'm working on an app for iOS 17 and need to implement single-side printing using the AirPrint API. I've done some research, but I'm still facing a few challenges. Can anyone provide guidance or share some sample code to achieve this? I've already imported the UIKit and MobileCoreServices frameworks and have set up the basic AirPrint functionality. Now, I'm looking specifically for instructions and code to enable single-sided printing. URL - https://www.controlf5.in/ Test code `**import UIKit import MobileCoreServices // Set up AirPrint functionality func printDocument() { let printController = UIPrintInteractionController.shared let printInfo = UIPrintInfo(dictionary: nil) printInfo.outputType = .general printController.printInfo = printInfo let formatter = UIMarkupTextPrintFormatter(markupText: "Your printable content goes here") formatter.perPageContentInsets = UIEdgeInsets(top: 36, left: 36, bottom: 36, right: 36) printController.printFormatter = formatter printController.present(animated: true) { (controller, success, error) in if success { print("Printing completed successfully") } else if let error = error { print("Printing failed with error: \(error.localizedDescription)") } } }**`
Posted
by
Post not yet marked as solved
0 Replies
461 Views
Recently I was responsible for a project to print PDF reports. The challenge I'm facing is that the tablets used by clients are shared, and they frequently change the print settings on these tablets. However, my app needs to ensure that it always prints in single-sided format (as the reports from another department require the company logo to be printed). I've checked the code and found that I can use UIPrintInfo(dictionary: nil) to set it to single-sided printing. However, no matter how I set it, the printer still defaults to double-sided printing. Is there a way to ensure that when my app is using AirPrint, the print settings won't be affected by the global settings on the iPad? Here is the code: https://gist.github.com/oilking143/a1ea3cce9f73905046e20db0c37a847d I appreciate any guidance on this matter. Thank you!
Posted
by
Post not yet marked as solved
0 Replies
424 Views
Previously in MacOS13 and below versions, we used get the printer name from the running applications by this below code:- let apps = NSWorkspace.shared.runningApplications for app in apps{ if(app.bundleIdentifier == "com.apple.print.PrinterProxy"){ let spoolerName = app.bundleURL?.deletingPathExtension().lastPathComponent print("spooler name is : \(spoolerName ?? "")") //spooler name is : HP LaserJet Pro M428f-M429f } } In MacOS 14, the same approach is not able get the printer name as the implementation is modified to PrintCenter. So, can someone please suggest me the way to the fetch selected printer details from the printCenter. let apps = NSWorkspace.shared.runningApplications for app in apps{ if(app.bundleIdentifier == "com.apple.printcenter"){ let spoolerName = app.bundleURL?.deletingPathExtension().lastPathComponent print("spooler name is : \(spoolerName ?? "")") //spooler name is : Print Centre } }
Posted
by
Post not yet marked as solved
0 Replies
521 Views
Environment→ ・Device: iPad 9th generation ・OS:iPadOS17.1、iPadOS16.6 ・Printer model:EPSON PX-S730 What I want→ I want to determine whether the printer and iPad are connected to the same Wi-Fi network. Current issues→ When I run the below code on an iOS17 iPad, contactPrinter() becomes true even though you are not connected to the same network as the printer. Problem Description→ I want to pass the URL of the printer that I have set in advance and print directly from the device to the printer. So in iOS 16 when i execute the below code, without connecting to the same network as printer, return value of the "contactPrinter" method is FALSE. once i update to iOS 17 and ran the same code with the same conditions(iPad and printer not connected to same network), return value becomes TRUE. [I'm using "contactPrinter" method because after update to iOS 17 i was able to successfully launch a print job even if your device isn't connected to the same network as your printer.But in iOS 16 it return as an Error.] Is this a bug in iOS 17? Or is the method used incorrectly? Test code: let printer = UIPrinter(url: URL(string: "printer url")!) printer.contactPrinter { (available) -> Void in if (available) { // iOS17.1:true, iOS16.6:false print("connected to printer") printController.print(to: printer, completionHandler: printCompletionHandler) } else { print("not connected to printer") } }
Posted
by
Post not yet marked as solved
3 Replies
910 Views
After updating to Mac OS Sonoma, we have encountered compatibility issues with our iPad-designed application, specifically with the AirPrint functionality, when it is run on MacOS. The AirPrint feature stopped working properly through UIPrintInteractionController.shared. We have noticed that when we compile the application using Catalyst, the AirPrint functionality is restored and works as expected. However, this solution is not viable for us due to the restrictions associated with the frameworks we are utilizing. We are seeking alternative solutions, and any help or guidance would be highly appreciated to resolve this issue and ensure a seamless and uninterrupted user experience in our application. STEPS TO REPRODUCE Create an app for ipad with just a button and this code var str = "TEST" let printInfo = UIPrintInfo(dictionary:nil) printInfo.outputType = .general printInfo.jobName = "Report" printInfo.orientation = .portrait let printController = UIPrintInteractionController.shared printController.printInfo = printInfo printController.showsNumberOfCopies = false printController.showsPageRange = false printController.showsNumberOfCopies = false let formatter = UIMarkupTextPrintFormatter(markupText: str) formatter.contentInsets = UIEdgeInsets(top: 72, left: 72, bottom: 72, right: 72) printController.printFormatter = formatter printController.present(animated: true, completionHandler: nil) 2.Run it on a MacOS with Sonoma, there is no error on console or anything but it don't work. -If you run it with Catalyst it just works when adding the Printing permission of App Sandbox in Signing & Capabilities.
Posted
by
Post not yet marked as solved
0 Replies
514 Views
We have a software product that sends prints to a printer driver with the driver settings pre-saved to a file and applied at the time of printing. For reasons outside the scope of this question in some specific cases we need to open a pop up window for the OEM driver for the settings to be accepted by the OEM driver. In these cases the user has to click "Print" a second time, not ideal. Our dev team is having a difficult time automatically clicking that second Print button so the user doesn't have to. The goal is the window would pop up for a fraction of a second and the file is sent off right away with only one click by the user. I have personally tried playing around with AppleScript to accomplish this but have not been able to do so. The application itself is written with QT and here is the info regarding the button in question from Accessibility Inspector: Does anyone have any knowledge how to auto press this button?
Posted
by
Post not yet marked as solved
1 Replies
562 Views
I use the following code to print PDF: let printInfo = UIPrintInfo.printInfo() printInfo.outputType = UIPrintInfo.OutputType.general printInfo.jobName = "My Print Job" printInfo.orientation = .portrait let printController = UIPrintInteractionController.shared printController.printInfo = printInfo printController.printingItem = pdfData printController.delegate = self printController.present(animated: true, completionHandler: nil) Everything works fine, but according to the Xcode Organizer, some users experience sporadic crashes after initiating printing. It appears that these crashes may be related to updates in the UI within UIPrintInteractionController. The majority of these crashes occur on iOS 16, with a few also affecting iOS 17. I am unable to reproduce the issue. Stack trace for iOS 16.6.1: Fatal Exception: NSInternalInconsistencyException Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (0), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out). Collection view: <UICollectionView: 0x14d9a1a00; frame = (0 0; 235 944); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x281fe9fb0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x28164e660>; contentOffset: {0, 0}; contentSize: {235, 88}; adjustedContentInset: {0, 0, 0, 0}; layout: <UIPrintPreviewFlowLayout: 0x14b7c1320>; dataSource: <UIPrintPreviewViewController: 0x14d811200>> Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0x9cb4 __exceptionPreprocess 1 libobjc.A.dylib 0x183d0 objc_exception_throw 2 Foundation 0x4e154c _userInfoForFileAndLine 3 UIKitCore 0x7024f4 -[UICollectionView _Bug_Detected_In_Client_Of_UICollectionView_Invalid_Number_Of_Items_In_Section:] 4 UIKitCore 0x30d5a8 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] 5 UIKitCore 0x26bd5c -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] 6 UIKitCore 0x26d0e0 -[UICollectionView reloadItemsAtIndexPaths:] 7 PrintKitUI 0x2677c __55-[UIPrintPreviewViewController updatePrintPreviewInfo:]_block_invoke_3 8 UIKitCore 0x30494 +[UIView(Animation) performWithoutAnimation:] 9 PrintKitUI 0x266c8 __55-[UIPrintPreviewViewController updatePrintPreviewInfo:]_block_invoke 10 PrintKitUI 0x57b30 -[UIPrintPreviewPageFetcher resetAllPages:] 11 PrintKitUI 0x26460 -[UIPrintPreviewViewController updatePrintPreviewInfo:] 12 PrintKitUI 0x47b84 -[UIPrintPanelViewController updatePrintPreviewInfo] 13 PrintKitUI 0x45d5c -[UIPrintPanelViewController observeValueForKeyPath:ofObject:change:context:] 14 Foundation 0x3c0d0 NSKeyValueNotifyObserver 15 Foundation 0x52618 NSKeyValueDidChange 16 Foundation 0x3f518 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] 17 Foundation 0x3f248 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] 18 Foundation 0x3e1f8 _NSSetLongLongValueAndNotify 19 PrintKitUI 0x52e00 -[UIPrintInColorOption observeValueForKeyPath:ofObject:change:context:] 20 Foundation 0x3c0d0 NSKeyValueNotifyObserver 21 Foundation 0x52618 NSKeyValueDidChange 22 Foundation 0x3f518 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:] 23 Foundation 0x3f248 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:] 24 Foundation 0x3e7dc _NSSetObjectValueAndNotify 25 PrintKitUI 0x496f0 __51-[UIPrintPanelViewController lookupLastUsedPrinter]_block_invoke_2 26 libdispatch.dylib 0x2320 _dispatch_call_block_and_release 27 libdispatch.dylib 0x3eac _dispatch_client_callout ... Stack trace for iOS 17.0.3: Fatal Exception: NSInternalInconsistencyException UITableView dataSource returned a nil cell for row at index path: <NSIndexPath: 0x96b9dd5bd6ad637d> {length = 2, path = 0 - 0}. Table view: <UITableView: 0x108846400; frame = (0 0; 430 542); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x281fa8ae0>; backgroundColor = <UIDynamicSystemColor: 0x280481bc0; name = systemGroupedBackgroundColor>; layer = <CALayer: 0x2817cbea0>; contentOffset: {0, -56}; contentSize: {430, 332.99999618530273}; adjustedContentInset: {56, 0, 0, 0}; dataSource: <UIPrintOptionsTableViewController: 0x108819600>>, dataSource: <UIPrintOptionsTableViewController: 0x108819600> Fatal Exception: NSInternalInconsistencyException 0 CoreFoundation 0xed5e0 __exceptionPreprocess 1 libobjc.A.dylib 0x2bc00 objc_exception_throw 2 Foundation 0x6bc398 _userInfoForFileAndLine 3 UIKitCore 0x289d74 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] 4 UIKitCore 0x289a70 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:] 5 UIKitCore 0x287fbc -[UITableView _updateVisibleCellsNow:] 6 UIKitCore 0xfc45dc -[UITableView _updateAnimationDidStopWithOldVisibleViews:finished:context:] 7 UIKitCore 0x850bc __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ 8 UIKitCore 0x84854 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] 9 UIKitCore 0x83ecc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 10 UIKitCore 0x66498 -[UIViewAnimationState animationDidStop:finished:] 11 QuartzCore 0x7276c run_animation_callbacks(void*) 12 libdispatch.dylib 0x4300 _dispatch_client_callout ... Full exception stacktrace iOS 16 Full exception stacktrace iOS 17 Is anyone experiencing similar issues? Thanks!
Posted
by
Post not yet marked as solved
1 Replies
538 Views
Fatal Exception: NSInvalidArgumentException <UIPrintPanelNavigationController: 0x144010a00> is pushing the same view controller instance (<UIPrinterBrowserViewController: 0x142854400>) more than once which is not supported and is most likely an error in the application : com.myapp.myapp Fatal Exception: NSInvalidArgumentException 0 CoreFoundation 0xec870 __exceptionPreprocess 1 libobjc.A.dylib 0x2bc00 objc_exception_throw 2 UIKitCore 0xcb284 -[UINavigationController pushViewController:transition:forceImmediate:] 3 UIKitCore 0xca398 -[UINavigationController pushViewController:animated:] 4 PrintKitUI 0x45024 -[UIPrintPanelNavigationController pushViewController:animated:] 5 UIKitCore 0x129b78 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] 6 UIKitCore 0x129680 -[_UIViewControllerTransitionContext _runAlongsideCompletions] 7 UIKitCore 0x128d10 -[_UIViewControllerTransitionContext completeTransition:] 8 UIKitCore 0x7a3d48 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_5 9 UIKitCore 0x84a38 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__ 10 UIKitCore 0x841d0 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] 11 UIKitCore 0x83848 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 12 UIKitCore 0x65aa4 -[UIViewAnimationState animationDidStop:finished:] 13 UIKitCore 0x65bb8 -[UIViewAnimationState animationDidStop:finished:] 14 QuartzCore 0x72098 run_animation_callbacks(void*) 15 libdispatch.dylib 0x4300 _dispatch_client_callout 16 libdispatch.dylib 0x12998 _dispatch_main_queue_drain 17 libdispatch.dylib 0x125b0 _dispatch_main_queue_callback_4CF 18 CoreFoundation 0x3720c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 19 CoreFoundation 0x33f18 __CFRunLoopRun 20 CoreFoundation 0x33668 CFRunLoopRunSpecific 21 GraphicsServices 0x35ec GSEventRunModal 22 UIKitCore 0x22c2b4 -[UIApplication _run] 23 UIKitCore 0x22b8f0 UIApplicationMain 24 MyApp 0x4a940 main + 14 (main.m:14) 25 ??? 0x1ac55adcc (Missing) I found this crash in Firebase crashlytics. This is device info Model:iPad Air (5th generation) Version:17.1.1 Orientation:Landscape Please help me to findout the root cause of the crash and possible solution. I have tried to reprduce the crash but didn't reproduce.
Posted
by
Post not yet marked as solved
2 Replies
532 Views
We have an app that exports PDFs with a custom page size, using PSDKit. In iOS16 the PDF export would have the correct page size dimensions, but now iOS17 exports everything to a Letter (8.5x11) size, regardless of what the PDF size specs are defined in the code: let pageWidth: CGFloat = 86.0 / 25.4 * 72 let pageHeight: CGFloat = 54.0 / 25.4 * 72 let pageSize = CGRect(x: 0, y: 0, width: pageWidth, height: pageHeight) Any thoughts as to how to fix this?
Posted
by