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

74 Posts

Post

Replies

Boosts

Views

Activity

Crash when printing a document from UIActivityViewController or QLPreviewController on iOS 16
Seems like the printing doesn't appear to be worked correctly on iOS 16. We've been getting a lot of crash reports related to printing since iOS 16 was released, for instance print_crash_report.txt Unfortunately, we are unable to reproduce those crashes. This article says that SEGV_MAPERR crash is due to an invalid memory fetch. For this reason, we decided to debug our app with the Address Sanitizer tool enabled in Xcode. As a result, we found out that almost every time the app accesses a freed heap region when the print UI is presented. address_sanitizer_report.txt The were able to reproduce 2 cases in a separated project: Printing a docx file from QLPreviewController Printing the same file from UIActivityViewController passing WKWebView.viewPrintFormatter as an activity item. In order to get the error, once you get to the print UI start scrolling the document preview. See the sample code bellow: import UIKit import WebKit import QuickLook final class PrintCrashViewController: UIViewController { private let webView = WKWebView() /* 27 page document from the app bundle */ private lazy var docFileURL = URL(fileURLWithPath: Bundle.main.path(forResource: "description", ofType: "docx")!) override func loadView() { view = webView } override func viewDidLoad() { super.viewDidLoad() navigationItem.rightBarButtonItems = [ UIBarButtonItem(title: "QL", style: .plain, target: self, action: #selector(openQLPreview)), UIBarButtonItem(title: "Share", style: .plain, target: self, action: #selector(openActivityVC)) ] webView.loadFileURL(docFileURL, allowingReadAccessTo: docFileURL) } @objc private func openActivityVC() { let items: [Any] = [docFileURL, webView.viewPrintFormatter()] let activityVC = UIActivityViewController(activityItems: items, applicationActivities: nil) present(activityVC, animated: true) } @objc private func openQLPreview() { let qlPreviewVC = QLPreviewController() qlPreviewVC.dataSource = self present(qlPreviewVC, animated: true) } } extension PrintCrashViewController: QLPreviewControllerDataSource { func numberOfPreviewItems(in controller: QLPreviewController) -> Int { 1 } func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { docFileURL as NSURL } } Both approaches have been in our app for years.
1
2
1.5k
Apr ’23
UIPrintInteractionController's printToPrinter crash in 'lookupLastUsedPrinter' API call.
Hi, We are seeing following crash in our codebase (iOS 15) with following call stack in UIPrintInteractionController. Could anyone please help with your inputs on how we can address following "UIPrintInteractionController's printToPrinter api crash" Crash stack uncaught ObjC exception, reason: -[PKPrinter _internalPrinter]: unrecognized selector sent to instance Last Exception Backtrace: 2 libobjc.A.dylib objc_exception_throw (??:0)w + 3 CoreFoundation __CFOAInitializeNSObject (??:0)3 + 4 CoreFoundation ___forwarding___ (??:0)3 + 5 CoreFoundation __CFRunLoopDoTimers (??:0)0 + 6 UIKitCore __51-[UIPrintPanelViewController lookupLastUsedPrinter]_block_invoke (??:0)5 + 7 UIKitCore -[UIPrintPanelViewController loadView] (??:0)5 + 8 UIKitCore __88-[UIPrintInteractionController _generatePDFInRange:useFullRange:withQuality:completion:]_block_invoke (??:0)5 + 9 UIKitCore -[UIPrintInteractionController printToPrinter:completionHandler:] (??:0)5 + 10 UIKitCore -[UIPrintInteractionController _completePrintPageWithError:] (??:0)5 + 11 UIKitCore -[UIPrintInteractionController printToPrinter:completionHandler:] (??:0)5 + Codebase that resulted above crash UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController]; UIPrintInteractionCompletionHandler completionHandler = ^(UIPrintInteractionController *printControllerT, BOOL completed, NSError *error) { [printControllerT setDelegate:nil]; }; [printController setDelegate:printDelegate]; [printController setPrintingItem:rurlPrintJob]; [printController presentAnimated:YES completionHandler:completionHandler]; More info meanwhile I have found one apple thread where its mentioned that “App Crash when using print of UIPrintInteractionController” ==>https://developer.apple.com/forums/thread/689876. Above thread suggested to use printer.contactPrinter instead of printerController.print.Since our current codebase used default iOS codepath(printToPrinter) with ‘[[UIPrintInteractionController sharedPrintController]presentAnimated:YES completionHandler:completionHandler]]’ api call , I am not able to apply this suggestion in current codebase.
1
1
1.7k
Apr ’23
Which errors can be handled by the UIPrintInteractionController.CompletionHandler
I would like to know what errors can be handled by the UIPrintInteractionController.CompletionHandler.According to the UIKit documentation, four constants were defined for UIPrintError.Code, but that is very rough and I don't know which error codes are returned at specific times. When I print from my iPad using AirPrint, can I get detailed errors such as out of ink, paper jam, or insufficient paper? Also, is there another way to get and handle print errors other than using the UIPrintInteractionController.CompletionHandler?
0
0
1.1k
Mar ’23
How to get the list of all the printer connected to ios device programmatically?
I want to print documents using UIPrintIntrectionController() and need to pass one of the available printer but i have to pass the printer programmatically instead of hardcoding the details of printer i tried using NetServiceBrower() but it is depreceted and resources are not available about it `let printController = UIPrintInteractionController.shared let printInfo = UIPrintInfo(dictionary: nil) printInfo.jobName = "printing" printInfo.outputType = UIPrintInfo.OutputType.general printController.printInfo = printInfo let str = "hello" let dataStr: Data = Data(str.utf8) let data = NSData(data: dataStr) printController.printingItem = data //need to access a printer to pass to printerController let printer = ?? printController.print(to: printer)
0
1
958
Mar ’23
Airprint - background printing produces blanks pages
When using iOS 16, when a pdf or image is printed from our app without interaction using UIPrintInteractionController.SharedPrintController and PrintToPrinterAsync(), the first item printed prints successfully but each successive print just prints out blank pages, even when printing the same pdf or image. This continues until the app is restarted. Once restarted, the first item will print correctly again but everything after will print blank pages. If a pdf or image is printed via the print UI with PresentAsync() or PresentFromRectInViewAsync(), the item will print properly each time. It seems there is some problem with PrintToPrinterAsync on iOS 16 and/or xcode 14 (tested with xcode 14.1).
2
2
2.3k
Feb ’23
AirPrint authentication using client certificate
Hello, Is the AirPrint authentication via client certificates supported in iOS 16.1? Bonjour specification defines an "air" key in the TXT record with a "certificate" as a valid option. We tried to import a certificate into iOS and modify our print server to negotiate the client certificate during the TLS handshake but iOS didn't provide any client certificate during the handshake. Thanks, Radim
0
3
830
Feb ’23
Page Setup dialog crashing on macOS Ventura 13.1
A small percentage of my customers is experiencing crashes when invoking the vanilla Page Setup dialog in our document-based macOS AppKit app. So far only AirPrint printers are affected though I cannot replicate the issue locally when printing to an AirPrint target. As soon as the Page Setup dialog is invoked via the usual runPageLayout: method in NSDocument the crash occurs deep inside the system frameworks in the PJCCreateSuggestedPaper() method: Crashed Thread:        0  Dispatch queue: com.apple.main-thread Exception Type:        EXC_BAD_ACCESS (SIGSEGV) Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Codes:       0x0000000000000001, 0x0000000000000000 Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process:   exc handler [16825] VM Region Info: 0 is not in any region.  Bytes before following region: 4402925568       REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL       UNUSED SPACE AT START --->         __TEXT                      1066f5000-1067ed000    [  992K] r-x/r-x SM=COW  ...M App Thread 0 Crashed::  Dispatch queue: com.apple.main-thread 0   PrintCore                        0x7ff81623d183 PJCCreateSuggestedPaper + 71 1   PrintingUI                           0x12ab25b43 0x12aadb000 + 305987 2   PrintingUI                           0x12ab259ef 0x12aadb000 + 305647 3   PrintingUI                           0x12aaf24c3 0x12aadb000 + 95427 4   PrintingUI                           0x12ab09ab6 0x12aadb000 + 191158 5   PrintingUI                           0x12ab093af 0x12aadb000 + 189359 6   PrintingUI                           0x12ab0fa85 0x12aadb000 + 215685 7   PrintingUI                           0x12ab15c52 0x12aadb000 + 240722 8   AppKit                            0x7ff80bc3b2af -[NSWindowController _windowDidLoad] + 548 9   AppKit                            0x7ff80bc36f78 -[NSWindowController window] + 110 10  AppKit                            0x7ff80c1767d4 -[NSPageLayout beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:] + 217 11  AppKit                            0x7ff80bfda3e7 __82-[NSDocument runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:]_block_invoke + 394 12  AppKit                            0x7ff80c06fce2 -[NSDocument(NSDocumentSerializationAPIs) _performActivity:] + 1672 13  AppKit                            0x7ff80c070e37 -[NSDocument(NSDocumentSerializationAPIs) performActivityWithSynchronousWaiting:usingBlock:cancellationHandler:] + 431 14  AppKit                            0x7ff80bfda257 -[NSDocument runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:] + 94 For the affected customers the crash is 100% reproducible. As there is no application specific code whatsoever in any of the stack traces and the app is using vanilla NSDocument methods to run the Page Setup dialog this very much looks like a bug in macOS Ventura... Any suggestions or workarounds highly appreciated! Cheers, Jay
1
1
1.4k
Jan ’23
App Crash when using print of UIPrintInteractionController
Using the latest Xcode 13 Beta 5 and try to print a PDF document on a predefined printer the App Crashes. I created a new iOS App running it on Simulator iPhone 12/iOS 15 with the following code: let a4Document = Bundle.main.url(forResource: "A4", withExtension: "pdf")! let airPrinter = UIPrinter(url: URL(string: "ipps://oki-c332.local.:443/ipp/print")!) struct ContentView: View {     var body: some View {         Button("Print") {             DispatchQueue.main.async {                 let printController = UIPrintInteractionController.shared                 let printInfo = UIPrintInfo(dictionary:nil)                 printInfo.jobName = "AirPrint"                 printInfo.outputType = UIPrintInfo.OutputType.grayscale                 printController.printInfo = printInfo                 printController.printingItem = a4Document                 printController.print(to: airPrinter)             }         }     } } It failed when trying to print with: 2021-09-13 10:59:01.880869+0200 AirPrintTest[40566:741434] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally a view controller <UIAlertController: 0x7fb79a035c00> that is already being presented by <UIViewController: 0x7fb7987229c0>.' 2*** First throw call stack: 3( 4 0 CoreFoundation 0x00007fff203fc8a8 __exceptionPreprocess + 242 5 1 libobjc.A.dylib 0x00007fff2019ebe7 objc_exception_throw + 48 6 2 UIKitCore 0x00007fff2484b382 -[UIViewController _presentViewController:withAnimationController:completion:] + 5854 7 3 UIKitCore 0x00007fff2484bf6c __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2 + 70 8 4 UIKitCore 0x00007fff2559baa5 +[UIView(Animation) performWithoutAnimation:] + 84 9 5 UIKitCore 0x00007fff2484bec1 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 211 10 6 UIKitCore 0x00007fff2484c186 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 519 11 7 UIKitCore 0x00007fff2484bdae -[UIViewController _presentViewController:animated:completion:] + 173 12 8 UIKitCore 0x00007fff2484c23c -[UIViewController presentViewController:animated:completion:] + 155 13 9 UIKitCore 0x00007fff24faee9e -[UIPrintingProgress _mainQueue_presentProgressAlert] + 395 14 10 UIKitCore 0x00007fff24faf2fe -[UIPrintingProgress _mainQueue_showProgress:immediately:] + 844 15 11 UIKitCore 0x00007fff24faef03 -[UIPrintingProgress showProgress:immediately:] + 66 16 12 UIKitCore 0x00007fff24faf8ae -[UIPrintingProgress setPrintInfoState:] + 119 17 13 UIKitCore 0x00007fff24fbf50c -[UIPrintInteractionController _setPrintInfoState:] + 80 18 14 UIKitCore 0x00007fff24fb8d36 __65-[UIPrintInteractionController printToPrinter:completionHandler:]_block_invoke.151 + 236 19 15 libdispatch.dylib 0x0000000100ef3a18 _dispatch_call_block_and_release + 12 20 16 libdispatch.dylib 0x0000000100ef4bfc _dispatch_client_callout + 8 21 17 libdispatch.dylib 0x0000000100f03366 _dispatch_main_queue_callback_4CF + 1195 22 18 CoreFoundation 0x00007fff2036a555 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 23 19 CoreFoundation 0x00007fff20364db2 __CFRunLoopRun + 2772 24 20 CoreFoundation 0x00007fff20363dfb CFRunLoopRunSpecific + 567 25 21 GraphicsServices 0x00007fff2cbb5cd3 GSEventRunModal + 139 26 22 UIKitCore 0x00007fff24fee193 -[UIApplication _run] + 928 27 23 UIKitCore 0x00007fff24ff2bfb UIApplicationMain + 101 28 24 SwiftUI 0x00007fff5cc8f6d5 $s7SwiftUI17KitRendererCommon33_ACC2C5639A7D76F611E170E831FCA491LLys5NeverOyXlXpFAESpySpys4Int8VGSgGXEfU_ + 196 29 25 SwiftUI 0x00007fff5cc8f60f $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 148 30 26 SwiftUI 0x00007fff5c685e55 $s7SwiftUI3AppPAAE4mainyyFZ + 61 31 27 AirPrintTest 0x0000000100dcf99e $s12AirPrintTest0abC3AppV5$mainyyFZ + 30 32 28 AirPrintTest 0x0000000100dcfa19 main + 9 33 29 dyld 0x0000000100fe4e1e start_sim + 10 34 30 ??? 0x00000001062794d5 0x0 + 4398224597 35) 36libc++abi: terminating with uncaught exception of type NSException Is this bug known?
15
0
7.2k
Nov ’22
crash on iOS 15 when use UIPrintInteractionController to print PDF file
Is is a bug of iOS 15 itself? What can I do to fix this? It crashs when [UIPrintPreviewViewController reloadVisibleItems] It only happends on iOS from 15.0.0 to 15.5.0 so far When will UIPrintPreviewViewController reloadVisibleItems ? We can't even reproduce the crash, but we get lots crash reports on Firebase. Source code UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController]; if (controller) { UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; printInfo.duplex = UIPrintInfoDuplexLongEdge; controller.printInfo = printInfo; controller.printingItems = [self dataList]; LYWeakifySelf; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *controller, BOOL completed, NSError *error) { }; [controller presentAnimated:YES completionHandler:completionHandler]; } - (NSArray<NSData *> *)dataList { NSMutableArray *dataList = [NSMutableArray array]; [self enumerateDataUsingBlock:^(NSData *data, NSString *fileName) { [dataList addObject:data]; }]; return dataList; } Crash info on Firebase Fatal Exception: NSInternalInconsistencyException. attempt to delete item 1 from section 0 which only contains 0 items before the update. Stack trace 0 CoreFoundation __exceptionPreprocess 1 libobjc.A.dylib objc_exception_throw 2 Foundation _userInfoForFileAndLine 3 UIKitCore -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] 4 UIKitCore -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] 5 UIKitCore -[UICollectionView reloadItemsAtIndexPaths:] 6 UIKitCore -[UIPrintPreviewViewController reloadVisibleItems:] 7 UIKitCore __58-[UIPrintPreviewViewController updateLayoutWithPdfUpdate:]_block_invoke_2 8 Foundation __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ 9 Foundation -[NSBlockOperation main] 10 Foundation __NSOPERATION_IS_INVOKING_MAIN__ 11 Foundation -[NSOperation start] 12 Foundation __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ 13 Foundation __NSOQSchedule_f 14 libdispatch.dylib _dispatch_block_async_invoke2 15 libdispatch.dylib _dispatch_client_callout 16 libdispatch.dylib _dispatch_main_queue_drain 17 libdispatch.dylib _dispatch_main_queue_callback_4CF 18 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 19 CoreFoundation __CFRunLoopRun 20 CoreFoundation CFRunLoopRunSpecific 21 GraphicsServices GSEventRunModal 22 UIKitCore -[UIApplication _run] 23 UIKitCore UIApplicationMain 24 EverLens main.m - Line 14 main + 14
1
0
1.7k
Nov ’22
AirPrint booklet feature
AirPrint panel doesn’t show the booklet print feature. Is there a possibility to find / Has anybody found a work-around? None of the apps available at the app store seem to provide the feature. iPhone 8/iOS 15.6.1 and HP LaserJet Pro M501dn here.
0
0
891
Aug ’22
Create printers for ios
In android there is a way to create a printer object inside of an app and that printer can be used on all the other apps, is available in the list of printer of the os. **Is there a way to do that in iphone? ** So I can create this printer object and can be seen in the native printing functionality and be used in all the apps installed on the device
0
0
1.1k
Apr ’22
iOS Custom UIPrintPaper size
Hello, I am wondering is anyone has been able to successfully print to a custom paper size using UIPrintIneteractionController, or if it is even possible. Apple seems to think that only the standard size paper for your machine's local matter. Unfortunately, not all print jobs are for predefined standard paper sizes.What i am attempting to do:Print a PDF, that is 5.66" x 11", or ~408pts x 792pt, on a sheet of paper that is the of the same dimensions.What I have tried:Attempt 1:I have used the UIPrintInteractionController in it's most basic form, allowing a user to select the paper size. As expected, this did not match the size required because the desired size was not offered as an optionBasic UIPrintInteractionController implementation:if UIPrintInteractionController.canPrintURL(pdf!.localPDFUrl!) { let printInfo = UIPrintInfo(dictionary: nil) printInfo.jobName = pdf!.localPDFUrl!.lastPathComponent! printInfo.outputType = .Photo // .General printInfo.duplex = UIPrintInfoDuplex.None let printController = UIPrintInteractionController.sharedPrintController() printController.printInfo = printInfo printController.showsNumberOfCopies = false printController.printingItem = pdf!.localPDFUrl printController.presentAnimated(true, completionHandler: nil) }Attempt 2:I have let UIPrintIntereactionController do it's thing by attempting to auto-select the paper size based on the document via the printInteractionController(_:choosePaper:) method in UIPrintInteractionControllerDelegate, using the bestPaperForPageSize(_:withPapersFromArray:) static method of UIPrintPaper. Again this selects a size that does not match the document, but it select the smallest size paper that will contain the pdf page (US Letter in this case). Again this was expected.printInteractionController(_:choosePaper:) Code:func printInteractionController(printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -&gt; UIPrintPaper { // Get the size of the PDF Page let size: CGSize = pdf!.getPageSize() // Let the Printer api pick the best UIPrintPaper object for the print job let paper:UIPrintPaper = UIPrintPaper.bestPaperForPageSize(size, withPapersFromArray: paperList) // Log: Paper Object, Paper Size, Paper's Printable Rectangle, Class type print(size, paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) // return UIPrintPaper object return paper }print(size, paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) output:PDF Page Size: (792.0, 408.0) Paper Object: &lt;UIPrintPaper:0x7f8978fac450 &lt;PKPaper: 0x7f8978fee460&gt;&gt; Paper Size: (612.0, 792.0) Paper Printable Rect: (11.9905511811024, 11.9905511811024, 588.018897637795, 768.018897637795) Dynamic Object Type: UIPrintPaperAttempt 3:In this attempt I tried to get sneaky and subclass the UIPrintPaper object and then force bestPaperForPageSize(_:withPapersFromArray:) to return my desired paper size.UIPrintPaper subclass:import UIKit class CaseCard: UIPrintPaper { internal override var paperSize: CGSize { get { return CGSizeMake(5.66 * 72, 11 * 72) } } internal override var printableRect: CGRect { get { return CGRectMake(0, 0, 5.66 * 72, 11 * 72) } } }printInteractionController(_:choosePaper:) Code:func printInteractionController(printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -&gt; UIPrintPaper { // Force selection of custom paper size let paper:UIPrintPaper = CaseCard() as UIPrintPaper // Log: Paper Object, Paper Size, Paper's Printable Rectangle, Class type print( paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) // UIPrintPaper object return paper }print(paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) output:Paper Object: &lt;UIPrintPaper:0x7f9ebb5b6b30 (null)&gt; Paper Size: (407.52, 792.0) Paper Printable Rect: (0.0, 0.0, 407.52, 792.0) Dynamic Object Type : pdfviewer1.CaseCardThis is where things get interesting. You will notice that the Paper Object differs from Attempt 2 and Attempt 3.Attempt 2 &gt; Paper Object: &lt;UIPrintPaper:0x7f8978fac450 &lt;PKPaper: 0x7f8978fee460&gt;&gt;Attempt 3 &gt; Paper Object: &lt;UIPrintPaper:0x7f9ebb5b6b30 (null)&gt;Attempt 2 returns a predefined UIPrintPaper object, which is backed by a PrintKit.PKPaper instance, which is a private framework object that is inaccessible to developers. Attempt 3 returns my subclass'd UIPrintPaper, but without he PrintKit.PKPaper instance. Unfortuantely there is no way to assign a PKPaper object during the instantiation of the custom UIPrintPaper and the UIPrintInteractionController fallbacks to it's default size of US Letter (8.5 x11)So after all that, the question is: Can you print to a custom paper size from iOS UIPrintInteractionController? As of right now, I don't think this is possible, but I would love to be proven wrong. Even if it was in a future release of iOS(edit: typos, and there are probably still more)
3
0
5.6k
Mar ’22
Are Apple PDEs (Printer Dialog Extensions) a Legacy Technology?
As the title says I wonder if PDEs are still supported in Mac OS or if there are alternatives to accomplish the same function. In the current Apple documentation I have not found anything relevant to other than old code examples. Anyway Looking at the printer drivers of various printer manufacturers (at least on Mac OS Catalina), it seems that PDEs are still widely used in Mac OS. Any hint to the correct documentation would be appreciated.
0
0
940
Feb ’22
Managed vs Local Printer
I am developing an app that will install and manage network printers. The app installs the printers using the lpadmin tool. Now, we have a customer that uses MDM profile for devices. The profile has the setting "showOnlyManagedPrinter" set to disallow installation of local printers. The customer wants our app to be able to install printers though. The result is that the printers can be installed with the app but will not show up in dialogs, etc. (For example the Printer & Scanners dialog). This causes a problem for them. My question is, is there a way to "fool" macOS to treat these printers as "managed" printers and show them. For example is there a flag or setting that you can apply when you install or post-installation of a printer. How does the OS decide which printers are managed or not?
0
0
905
Jan ’22
Can't debug Xcode crash log
I have a problem with debuging crash log. I have tried debuging it in Xcode, but it is not pointing to any line of code. I don't know how to debug it. It crashed only on iPad (It crashed to some user in production). I think it is regarding PrintKit on thread 0. Can please someone help me? Thanks in advance Code for displaying PrintController: if UIPrintInteractionController.canPrint(pdfURL) {             let printInfo = UIPrintInfo(dictionary: nil)             printInfo.jobName = pdfURL.lastPathComponent             printInfo.outputType = .general             let printController = UIPrintInteractionController.shared             printController.printInfo = printInfo             printController.showsNumberOfCopies = false             printController.printingItem = pdfURL             printController.present(animated: true, completionHandler: nil)         } Crash log: Incident Identifier: INCIDENT ID Hardware Model: iPad13,2 Process: **APP-NAME** [89317] Path: /private/var/containers/Bundle/Application/**ID**/**APP-NAME**.app/**APP-NAME** Identifier: BUNDLE ID Version: 1.0 (4) AppStoreTools: 13C88a AppVariant: 1:iPad13,2:15 Code Type: ARM-64 (Native) Role: Background Parent Process: launchd [1] Coalition: BUNDLE ID Date/Time: 2022-01-05 09:09:35.5332 +0000 Launch Time: 2022-01-05 07:15:54.2451 +0000 OS Version: iPhone OS 15.1 (19B74) Release Type: User Baseband Version: 3.00.00 Report Version: 104 Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001b97c3558 semaphore_timedwait_trap + 8 1 libdispatch.dylib 0x00000001831ccc6c _dispatch_sema4_timedwait + 64 (lock.c:154) 2 libdispatch.dylib 0x00000001831cd270 _dispatch_semaphore_wait_slow + 76 (semaphore.c:116) 3 PrintKit 0x00000001e4adf548 -[PK_HTTPProxy withProtocolSync:] + 252 (PKBonjour.m:232) 4 PrintKit 0x00000001e4adfa94 pk_proxyConnectHTTP + 572 (PKBonjour.m:264) 5 PrintKit 0x00000001e4af4a34 -[PKPrinter(PKPrinterPrivate) getAttributes:count:] + 240 (PKPrinter.m:2744) 6 PrintKit 0x00000001e4af1004 -[PKPrinter doMedia2:] + 84 (PKPrinter.m:1542) 7 PrintKit 0x00000001e4aee88c -[PKPrinter printInfoSupported] + 1216 (PKPrinter.m:969) 8 UIKitCore 0x000000018687ed04 -[UIPrinterUtilityTableViewController initWithPrinter:] + 588 (UIPrinterUtilityTableViewController.m:230) 9 UIKitCore 0x000000018687254c -[UIPrinterBrowserViewController printerInfoButtonTapped:] + 80 (UIPrinterBrowserViewController.m:578) 10 UIKitCore 0x0000000186871340 -[UIPrinterTableViewCell printerAccessoryViewInfoButtonPressed:] + 84 (UIPrinterBrowserViewController.m:327) 11 UIKitCore 0x000000018687054c -[UIPrinterAccessoryView infoButtonPressed:] + 92 (UIPrinterBrowserViewController.m:124) 12 UIKitCore 0x0000000185e2fbf0 -[UIApplication sendAction:to:from:forEvent:] + 100 (UIApplication.m:5360) 13 UIKitCore 0x0000000185f5ba4c -[UIControl sendAction:to:forEvent:] + 128 (UIControl.m:871) 14 UIKitCore 0x0000000185cd72c8 -[UIControl _sendActionsForEvents:withEvent:] + 352 (UIControl.m:942) 15 UIKitCore 0x0000000185d73ae0 -[UIButton _sendActionsForEvents:withEvent:] + 160 (UIButton.m:4142) 16 UIKitCore 0x00000001860067c0 -[UIControl touchesEnded:withEvent:] + 536 (UIControl.m:637) 17 UIKitCore 0x0000000185acbd40 _UIGestureEnvironmentUpdate + 6708 (UIGestureEnvironment.m:653) 18 UIKitCore 0x0000000185afe8c8 -[UIGestureEnvironment _updateForEvent:window:] + 784 (UIGestureEnvironment.m:1332) 19 UIKitCore 0x0000000185b0ba68 -[UIWindow sendEvent:] + 4428 (UIWindow.m:3265) 20 UIKitCore 0x0000000185cbb318 -[UIApplication sendEvent:] + 828 (UIApplication.m:11864) 21 UIKitCore 0x0000000185adec30 __dispatchPreprocessedEventFromEventQueue + 7904 (UIEventDispatcher.m:2290) 22 UIKitCore 0x0000000185ad3a1c __processEventQueue + 6760 (UIEventDispatcher.m:2597) 23 UIKitCore 0x0000000185ad8ec8 __eventFetcherSourceCallback + 172 (UIEventDispatcher.m:2669) 24 CoreFoundation 0x000000018357c020 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1972) 25 CoreFoundation 0x000000018358cce0 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2016) 26 CoreFoundation 0x00000001834c6fe8 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2053) 27 CoreFoundation 0x00000001834cc7f4 __CFRunLoopRun + 820 (CFRunLoop.c:2951) 28 CoreFoundation 0x00000001834e03b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268) 29 GraphicsServices 0x000000019ee7038c GSEventRunModal + 164 (GSEvent.c:2200) 30 UIKitCore 0x0000000185e806a8 -[UIApplication _run] + 1100 (UIApplication.m:3493) 31 UIKitCore 0x0000000185bff7f4 UIApplicationMain + 2092 (UIApplication.m:5046) 32 SwiftUI 0x000000018b143258 closure #1 in KitRendererCommon(_:) + 164 (UIKitApp.swift:35) 33 SwiftUI 0x000000018b071534 runApp<A>(_:) + 252 (<compiler-generated>:0) 34 SwiftUI 0x000000018b052cb4 static App.main() + 128 (App.swift:114) 35 **APP-NAME** 0x0000000100fa08f0 $main + 28 (<compiler-generated>:10) 36 **APP-NAME** 0x0000000100fa08f0 main + 40 (TLContact.swift:0) 37 dyld 0x0000000101185a24 start + 520 (dyldMain.cpp:876) EOF
0
0
1k
Jan ’22
Crash when printing a document from UIActivityViewController or QLPreviewController on iOS 16
Seems like the printing doesn't appear to be worked correctly on iOS 16. We've been getting a lot of crash reports related to printing since iOS 16 was released, for instance print_crash_report.txt Unfortunately, we are unable to reproduce those crashes. This article says that SEGV_MAPERR crash is due to an invalid memory fetch. For this reason, we decided to debug our app with the Address Sanitizer tool enabled in Xcode. As a result, we found out that almost every time the app accesses a freed heap region when the print UI is presented. address_sanitizer_report.txt The were able to reproduce 2 cases in a separated project: Printing a docx file from QLPreviewController Printing the same file from UIActivityViewController passing WKWebView.viewPrintFormatter as an activity item. In order to get the error, once you get to the print UI start scrolling the document preview. See the sample code bellow: import UIKit import WebKit import QuickLook final class PrintCrashViewController: UIViewController { private let webView = WKWebView() /* 27 page document from the app bundle */ private lazy var docFileURL = URL(fileURLWithPath: Bundle.main.path(forResource: "description", ofType: "docx")!) override func loadView() { view = webView } override func viewDidLoad() { super.viewDidLoad() navigationItem.rightBarButtonItems = [ UIBarButtonItem(title: "QL", style: .plain, target: self, action: #selector(openQLPreview)), UIBarButtonItem(title: "Share", style: .plain, target: self, action: #selector(openActivityVC)) ] webView.loadFileURL(docFileURL, allowingReadAccessTo: docFileURL) } @objc private func openActivityVC() { let items: [Any] = [docFileURL, webView.viewPrintFormatter()] let activityVC = UIActivityViewController(activityItems: items, applicationActivities: nil) present(activityVC, animated: true) } @objc private func openQLPreview() { let qlPreviewVC = QLPreviewController() qlPreviewVC.dataSource = self present(qlPreviewVC, animated: true) } } extension PrintCrashViewController: QLPreviewControllerDataSource { func numberOfPreviewItems(in controller: QLPreviewController) -> Int { 1 } func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem { docFileURL as NSURL } } Both approaches have been in our app for years.
Replies
1
Boosts
2
Views
1.5k
Activity
Apr ’23
Printing question
Is it posible to add printers by code in iphone? Do they need to have air print on them?
Replies
1
Boosts
0
Views
1.3k
Activity
Apr ’23
UIPrintInteractionController's printToPrinter crash in 'lookupLastUsedPrinter' API call.
Hi, We are seeing following crash in our codebase (iOS 15) with following call stack in UIPrintInteractionController. Could anyone please help with your inputs on how we can address following "UIPrintInteractionController's printToPrinter api crash" Crash stack uncaught ObjC exception, reason: -[PKPrinter _internalPrinter]: unrecognized selector sent to instance Last Exception Backtrace: 2 libobjc.A.dylib objc_exception_throw (??:0)w + 3 CoreFoundation __CFOAInitializeNSObject (??:0)3 + 4 CoreFoundation ___forwarding___ (??:0)3 + 5 CoreFoundation __CFRunLoopDoTimers (??:0)0 + 6 UIKitCore __51-[UIPrintPanelViewController lookupLastUsedPrinter]_block_invoke (??:0)5 + 7 UIKitCore -[UIPrintPanelViewController loadView] (??:0)5 + 8 UIKitCore __88-[UIPrintInteractionController _generatePDFInRange:useFullRange:withQuality:completion:]_block_invoke (??:0)5 + 9 UIKitCore -[UIPrintInteractionController printToPrinter:completionHandler:] (??:0)5 + 10 UIKitCore -[UIPrintInteractionController _completePrintPageWithError:] (??:0)5 + 11 UIKitCore -[UIPrintInteractionController printToPrinter:completionHandler:] (??:0)5 + Codebase that resulted above crash UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController]; UIPrintInteractionCompletionHandler completionHandler = ^(UIPrintInteractionController *printControllerT, BOOL completed, NSError *error) { [printControllerT setDelegate:nil]; }; [printController setDelegate:printDelegate]; [printController setPrintingItem:rurlPrintJob]; [printController presentAnimated:YES completionHandler:completionHandler]; More info meanwhile I have found one apple thread where its mentioned that “App Crash when using print of UIPrintInteractionController” ==>https://developer.apple.com/forums/thread/689876. Above thread suggested to use printer.contactPrinter instead of printerController.print.Since our current codebase used default iOS codepath(printToPrinter) with ‘[[UIPrintInteractionController sharedPrintController]presentAnimated:YES completionHandler:completionHandler]]’ api call , I am not able to apply this suggestion in current codebase.
Replies
1
Boosts
1
Views
1.7k
Activity
Apr ’23
Which errors can be handled by the UIPrintInteractionController.CompletionHandler
I would like to know what errors can be handled by the UIPrintInteractionController.CompletionHandler.According to the UIKit documentation, four constants were defined for UIPrintError.Code, but that is very rough and I don't know which error codes are returned at specific times. When I print from my iPad using AirPrint, can I get detailed errors such as out of ink, paper jam, or insufficient paper? Also, is there another way to get and handle print errors other than using the UIPrintInteractionController.CompletionHandler?
Replies
0
Boosts
0
Views
1.1k
Activity
Mar ’23
How to get the list of all the printer connected to ios device programmatically?
I want to print documents using UIPrintIntrectionController() and need to pass one of the available printer but i have to pass the printer programmatically instead of hardcoding the details of printer i tried using NetServiceBrower() but it is depreceted and resources are not available about it `let printController = UIPrintInteractionController.shared let printInfo = UIPrintInfo(dictionary: nil) printInfo.jobName = "printing" printInfo.outputType = UIPrintInfo.OutputType.general printController.printInfo = printInfo let str = "hello" let dataStr: Data = Data(str.utf8) let data = NSData(data: dataStr) printController.printingItem = data //need to access a printer to pass to printerController let printer = ?? printController.print(to: printer)
Replies
0
Boosts
1
Views
958
Activity
Mar ’23
Airprint - background printing produces blanks pages
When using iOS 16, when a pdf or image is printed from our app without interaction using UIPrintInteractionController.SharedPrintController and PrintToPrinterAsync(), the first item printed prints successfully but each successive print just prints out blank pages, even when printing the same pdf or image. This continues until the app is restarted. Once restarted, the first item will print correctly again but everything after will print blank pages. If a pdf or image is printed via the print UI with PresentAsync() or PresentFromRectInViewAsync(), the item will print properly each time. It seems there is some problem with PrintToPrinterAsync on iOS 16 and/or xcode 14 (tested with xcode 14.1).
Replies
2
Boosts
2
Views
2.3k
Activity
Feb ’23
AirPrint authentication using client certificate
Hello, Is the AirPrint authentication via client certificates supported in iOS 16.1? Bonjour specification defines an "air" key in the TXT record with a "certificate" as a valid option. We tried to import a certificate into iOS and modify our print server to negotiate the client certificate during the TLS handshake but iOS didn't provide any client certificate during the handshake. Thanks, Radim
Replies
0
Boosts
3
Views
830
Activity
Feb ’23
Page Setup dialog crashing on macOS Ventura 13.1
A small percentage of my customers is experiencing crashes when invoking the vanilla Page Setup dialog in our document-based macOS AppKit app. So far only AirPrint printers are affected though I cannot replicate the issue locally when printing to an AirPrint target. As soon as the Page Setup dialog is invoked via the usual runPageLayout: method in NSDocument the crash occurs deep inside the system frameworks in the PJCCreateSuggestedPaper() method: Crashed Thread:        0  Dispatch queue: com.apple.main-thread Exception Type:        EXC_BAD_ACCESS (SIGSEGV) Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Codes:       0x0000000000000001, 0x0000000000000000 Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process:   exc handler [16825] VM Region Info: 0 is not in any region.  Bytes before following region: 4402925568       REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL       UNUSED SPACE AT START --->         __TEXT                      1066f5000-1067ed000    [  992K] r-x/r-x SM=COW  ...M App Thread 0 Crashed::  Dispatch queue: com.apple.main-thread 0   PrintCore                        0x7ff81623d183 PJCCreateSuggestedPaper + 71 1   PrintingUI                           0x12ab25b43 0x12aadb000 + 305987 2   PrintingUI                           0x12ab259ef 0x12aadb000 + 305647 3   PrintingUI                           0x12aaf24c3 0x12aadb000 + 95427 4   PrintingUI                           0x12ab09ab6 0x12aadb000 + 191158 5   PrintingUI                           0x12ab093af 0x12aadb000 + 189359 6   PrintingUI                           0x12ab0fa85 0x12aadb000 + 215685 7   PrintingUI                           0x12ab15c52 0x12aadb000 + 240722 8   AppKit                            0x7ff80bc3b2af -[NSWindowController _windowDidLoad] + 548 9   AppKit                            0x7ff80bc36f78 -[NSWindowController window] + 110 10  AppKit                            0x7ff80c1767d4 -[NSPageLayout beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:] + 217 11  AppKit                            0x7ff80bfda3e7 __82-[NSDocument runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:]_block_invoke + 394 12  AppKit                            0x7ff80c06fce2 -[NSDocument(NSDocumentSerializationAPIs) _performActivity:] + 1672 13  AppKit                            0x7ff80c070e37 -[NSDocument(NSDocumentSerializationAPIs) performActivityWithSynchronousWaiting:usingBlock:cancellationHandler:] + 431 14  AppKit                            0x7ff80bfda257 -[NSDocument runModalPageLayoutWithPrintInfo:delegate:didRunSelector:contextInfo:] + 94 For the affected customers the crash is 100% reproducible. As there is no application specific code whatsoever in any of the stack traces and the app is using vanilla NSDocument methods to run the Page Setup dialog this very much looks like a bug in macOS Ventura... Any suggestions or workarounds highly appreciated! Cheers, Jay
Replies
1
Boosts
1
Views
1.4k
Activity
Jan ’23
App Crash when using print of UIPrintInteractionController
Using the latest Xcode 13 Beta 5 and try to print a PDF document on a predefined printer the App Crashes. I created a new iOS App running it on Simulator iPhone 12/iOS 15 with the following code: let a4Document = Bundle.main.url(forResource: "A4", withExtension: "pdf")! let airPrinter = UIPrinter(url: URL(string: "ipps://oki-c332.local.:443/ipp/print")!) struct ContentView: View {     var body: some View {         Button("Print") {             DispatchQueue.main.async {                 let printController = UIPrintInteractionController.shared                 let printInfo = UIPrintInfo(dictionary:nil)                 printInfo.jobName = "AirPrint"                 printInfo.outputType = UIPrintInfo.OutputType.grayscale                 printController.printInfo = printInfo                 printController.printingItem = a4Document                 printController.print(to: airPrinter)             }         }     } } It failed when trying to print with: 2021-09-13 10:59:01.880869+0200 AirPrintTest[40566:741434] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally a view controller <UIAlertController: 0x7fb79a035c00> that is already being presented by <UIViewController: 0x7fb7987229c0>.' 2*** First throw call stack: 3( 4 0 CoreFoundation 0x00007fff203fc8a8 __exceptionPreprocess + 242 5 1 libobjc.A.dylib 0x00007fff2019ebe7 objc_exception_throw + 48 6 2 UIKitCore 0x00007fff2484b382 -[UIViewController _presentViewController:withAnimationController:completion:] + 5854 7 3 UIKitCore 0x00007fff2484bf6c __63-[UIViewController _presentViewController:animated:completion:]_block_invoke_2 + 70 8 4 UIKitCore 0x00007fff2559baa5 +[UIView(Animation) performWithoutAnimation:] + 84 9 5 UIKitCore 0x00007fff2484bec1 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 211 10 6 UIKitCore 0x00007fff2484c186 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 519 11 7 UIKitCore 0x00007fff2484bdae -[UIViewController _presentViewController:animated:completion:] + 173 12 8 UIKitCore 0x00007fff2484c23c -[UIViewController presentViewController:animated:completion:] + 155 13 9 UIKitCore 0x00007fff24faee9e -[UIPrintingProgress _mainQueue_presentProgressAlert] + 395 14 10 UIKitCore 0x00007fff24faf2fe -[UIPrintingProgress _mainQueue_showProgress:immediately:] + 844 15 11 UIKitCore 0x00007fff24faef03 -[UIPrintingProgress showProgress:immediately:] + 66 16 12 UIKitCore 0x00007fff24faf8ae -[UIPrintingProgress setPrintInfoState:] + 119 17 13 UIKitCore 0x00007fff24fbf50c -[UIPrintInteractionController _setPrintInfoState:] + 80 18 14 UIKitCore 0x00007fff24fb8d36 __65-[UIPrintInteractionController printToPrinter:completionHandler:]_block_invoke.151 + 236 19 15 libdispatch.dylib 0x0000000100ef3a18 _dispatch_call_block_and_release + 12 20 16 libdispatch.dylib 0x0000000100ef4bfc _dispatch_client_callout + 8 21 17 libdispatch.dylib 0x0000000100f03366 _dispatch_main_queue_callback_4CF + 1195 22 18 CoreFoundation 0x00007fff2036a555 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 23 19 CoreFoundation 0x00007fff20364db2 __CFRunLoopRun + 2772 24 20 CoreFoundation 0x00007fff20363dfb CFRunLoopRunSpecific + 567 25 21 GraphicsServices 0x00007fff2cbb5cd3 GSEventRunModal + 139 26 22 UIKitCore 0x00007fff24fee193 -[UIApplication _run] + 928 27 23 UIKitCore 0x00007fff24ff2bfb UIApplicationMain + 101 28 24 SwiftUI 0x00007fff5cc8f6d5 $s7SwiftUI17KitRendererCommon33_ACC2C5639A7D76F611E170E831FCA491LLys5NeverOyXlXpFAESpySpys4Int8VGSgGXEfU_ + 196 29 25 SwiftUI 0x00007fff5cc8f60f $s7SwiftUI6runAppys5NeverOxAA0D0RzlF + 148 30 26 SwiftUI 0x00007fff5c685e55 $s7SwiftUI3AppPAAE4mainyyFZ + 61 31 27 AirPrintTest 0x0000000100dcf99e $s12AirPrintTest0abC3AppV5$mainyyFZ + 30 32 28 AirPrintTest 0x0000000100dcfa19 main + 9 33 29 dyld 0x0000000100fe4e1e start_sim + 10 34 30 ??? 0x00000001062794d5 0x0 + 4398224597 35) 36libc++abi: terminating with uncaught exception of type NSException Is this bug known?
Replies
15
Boosts
0
Views
7.2k
Activity
Nov ’22
crash on iOS 15 when use UIPrintInteractionController to print PDF file
Is is a bug of iOS 15 itself? What can I do to fix this? It crashs when [UIPrintPreviewViewController reloadVisibleItems] It only happends on iOS from 15.0.0 to 15.5.0 so far When will UIPrintPreviewViewController reloadVisibleItems ? We can't even reproduce the crash, but we get lots crash reports on Firebase. Source code UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController]; if (controller) { UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; printInfo.duplex = UIPrintInfoDuplexLongEdge; controller.printInfo = printInfo; controller.printingItems = [self dataList]; LYWeakifySelf; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *controller, BOOL completed, NSError *error) { }; [controller presentAnimated:YES completionHandler:completionHandler]; } - (NSArray<NSData *> *)dataList { NSMutableArray *dataList = [NSMutableArray array]; [self enumerateDataUsingBlock:^(NSData *data, NSString *fileName) { [dataList addObject:data]; }]; return dataList; } Crash info on Firebase Fatal Exception: NSInternalInconsistencyException. attempt to delete item 1 from section 0 which only contains 0 items before the update. Stack trace 0 CoreFoundation __exceptionPreprocess 1 libobjc.A.dylib objc_exception_throw 2 Foundation _userInfoForFileAndLine 3 UIKitCore -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] 4 UIKitCore -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] 5 UIKitCore -[UICollectionView reloadItemsAtIndexPaths:] 6 UIKitCore -[UIPrintPreviewViewController reloadVisibleItems:] 7 UIKitCore __58-[UIPrintPreviewViewController updateLayoutWithPdfUpdate:]_block_invoke_2 8 Foundation __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ 9 Foundation -[NSBlockOperation main] 10 Foundation __NSOPERATION_IS_INVOKING_MAIN__ 11 Foundation -[NSOperation start] 12 Foundation __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ 13 Foundation __NSOQSchedule_f 14 libdispatch.dylib _dispatch_block_async_invoke2 15 libdispatch.dylib _dispatch_client_callout 16 libdispatch.dylib _dispatch_main_queue_drain 17 libdispatch.dylib _dispatch_main_queue_callback_4CF 18 CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 19 CoreFoundation __CFRunLoopRun 20 CoreFoundation CFRunLoopRunSpecific 21 GraphicsServices GSEventRunModal 22 UIKitCore -[UIApplication _run] 23 UIKitCore UIApplicationMain 24 EverLens main.m - Line 14 main + 14
Replies
1
Boosts
0
Views
1.7k
Activity
Nov ’22
Printer Tray
Hello, how can I check the number of trays in the connected printer? Can I set a programmatically required tray for printing different paper sizes?
Replies
3
Boosts
0
Views
2.4k
Activity
Oct ’22
AirPrint booklet feature
AirPrint panel doesn’t show the booklet print feature. Is there a possibility to find / Has anybody found a work-around? None of the apps available at the app store seem to provide the feature. iPhone 8/iOS 15.6.1 and HP LaserJet Pro M501dn here.
Replies
0
Boosts
0
Views
891
Activity
Aug ’22
Help with print
Documents with mixed size pages won’t print correctly
Replies
1
Boosts
0
Views
996
Activity
Jul ’22
Quick Look
Hi! I'm new to Apple developing. Could anyone please tell me how to configure a quick look for my document? Also, how to print my document? Thanks🙏
Replies
1
Boosts
0
Views
1.5k
Activity
May ’22
Create printers for ios
In android there is a way to create a printer object inside of an app and that printer can be used on all the other apps, is available in the list of printer of the os. **Is there a way to do that in iphone? ** So I can create this printer object and can be seen in the native printing functionality and be used in all the apps installed on the device
Replies
0
Boosts
0
Views
1.1k
Activity
Apr ’22
iOS Custom UIPrintPaper size
Hello, I am wondering is anyone has been able to successfully print to a custom paper size using UIPrintIneteractionController, or if it is even possible. Apple seems to think that only the standard size paper for your machine's local matter. Unfortunately, not all print jobs are for predefined standard paper sizes.What i am attempting to do:Print a PDF, that is 5.66" x 11", or ~408pts x 792pt, on a sheet of paper that is the of the same dimensions.What I have tried:Attempt 1:I have used the UIPrintInteractionController in it's most basic form, allowing a user to select the paper size. As expected, this did not match the size required because the desired size was not offered as an optionBasic UIPrintInteractionController implementation:if UIPrintInteractionController.canPrintURL(pdf!.localPDFUrl!) { let printInfo = UIPrintInfo(dictionary: nil) printInfo.jobName = pdf!.localPDFUrl!.lastPathComponent! printInfo.outputType = .Photo // .General printInfo.duplex = UIPrintInfoDuplex.None let printController = UIPrintInteractionController.sharedPrintController() printController.printInfo = printInfo printController.showsNumberOfCopies = false printController.printingItem = pdf!.localPDFUrl printController.presentAnimated(true, completionHandler: nil) }Attempt 2:I have let UIPrintIntereactionController do it's thing by attempting to auto-select the paper size based on the document via the printInteractionController(_:choosePaper:) method in UIPrintInteractionControllerDelegate, using the bestPaperForPageSize(_:withPapersFromArray:) static method of UIPrintPaper. Again this selects a size that does not match the document, but it select the smallest size paper that will contain the pdf page (US Letter in this case). Again this was expected.printInteractionController(_:choosePaper:) Code:func printInteractionController(printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -&gt; UIPrintPaper { // Get the size of the PDF Page let size: CGSize = pdf!.getPageSize() // Let the Printer api pick the best UIPrintPaper object for the print job let paper:UIPrintPaper = UIPrintPaper.bestPaperForPageSize(size, withPapersFromArray: paperList) // Log: Paper Object, Paper Size, Paper's Printable Rectangle, Class type print(size, paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) // return UIPrintPaper object return paper }print(size, paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) output:PDF Page Size: (792.0, 408.0) Paper Object: &lt;UIPrintPaper:0x7f8978fac450 &lt;PKPaper: 0x7f8978fee460&gt;&gt; Paper Size: (612.0, 792.0) Paper Printable Rect: (11.9905511811024, 11.9905511811024, 588.018897637795, 768.018897637795) Dynamic Object Type: UIPrintPaperAttempt 3:In this attempt I tried to get sneaky and subclass the UIPrintPaper object and then force bestPaperForPageSize(_:withPapersFromArray:) to return my desired paper size.UIPrintPaper subclass:import UIKit class CaseCard: UIPrintPaper { internal override var paperSize: CGSize { get { return CGSizeMake(5.66 * 72, 11 * 72) } } internal override var printableRect: CGRect { get { return CGRectMake(0, 0, 5.66 * 72, 11 * 72) } } }printInteractionController(_:choosePaper:) Code:func printInteractionController(printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -&gt; UIPrintPaper { // Force selection of custom paper size let paper:UIPrintPaper = CaseCard() as UIPrintPaper // Log: Paper Object, Paper Size, Paper's Printable Rectangle, Class type print( paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) // UIPrintPaper object return paper }print(paper, paper.paperSize, paper.printableRect, NSStringFromClass(paper.dynamicType)) output:Paper Object: &lt;UIPrintPaper:0x7f9ebb5b6b30 (null)&gt; Paper Size: (407.52, 792.0) Paper Printable Rect: (0.0, 0.0, 407.52, 792.0) Dynamic Object Type : pdfviewer1.CaseCardThis is where things get interesting. You will notice that the Paper Object differs from Attempt 2 and Attempt 3.Attempt 2 &gt; Paper Object: &lt;UIPrintPaper:0x7f8978fac450 &lt;PKPaper: 0x7f8978fee460&gt;&gt;Attempt 3 &gt; Paper Object: &lt;UIPrintPaper:0x7f9ebb5b6b30 (null)&gt;Attempt 2 returns a predefined UIPrintPaper object, which is backed by a PrintKit.PKPaper instance, which is a private framework object that is inaccessible to developers. Attempt 3 returns my subclass'd UIPrintPaper, but without he PrintKit.PKPaper instance. Unfortuantely there is no way to assign a PKPaper object during the instantiation of the custom UIPrintPaper and the UIPrintInteractionController fallbacks to it's default size of US Letter (8.5 x11)So after all that, the question is: Can you print to a custom paper size from iOS UIPrintInteractionController? As of right now, I don't think this is possible, but I would love to be proven wrong. Even if it was in a future release of iOS(edit: typos, and there are probably still more)
Replies
3
Boosts
0
Views
5.6k
Activity
Mar ’22
Lack of Paper Size options for AirPrint with Pantum P2506w
Hi I’m using AirPad Air 4, iPad Pro 11, iphone 7s, iPhone 10, iPhone 13 running iOS 15.4 on all the devices. when I use the AirPrint feature on the devices to Print on the Pantum P2506w the only option is A4. is there a way to change this ? if not when can apple include support.
Replies
1
Boosts
0
Views
822
Activity
Mar ’22
Are Apple PDEs (Printer Dialog Extensions) a Legacy Technology?
As the title says I wonder if PDEs are still supported in Mac OS or if there are alternatives to accomplish the same function. In the current Apple documentation I have not found anything relevant to other than old code examples. Anyway Looking at the printer drivers of various printer manufacturers (at least on Mac OS Catalina), it seems that PDEs are still widely used in Mac OS. Any hint to the correct documentation would be appreciated.
Replies
0
Boosts
0
Views
940
Activity
Feb ’22
Managed vs Local Printer
I am developing an app that will install and manage network printers. The app installs the printers using the lpadmin tool. Now, we have a customer that uses MDM profile for devices. The profile has the setting "showOnlyManagedPrinter" set to disallow installation of local printers. The customer wants our app to be able to install printers though. The result is that the printers can be installed with the app but will not show up in dialogs, etc. (For example the Printer & Scanners dialog). This causes a problem for them. My question is, is there a way to "fool" macOS to treat these printers as "managed" printers and show them. For example is there a flag or setting that you can apply when you install or post-installation of a printer. How does the OS decide which printers are managed or not?
Replies
0
Boosts
0
Views
905
Activity
Jan ’22
Can't debug Xcode crash log
I have a problem with debuging crash log. I have tried debuging it in Xcode, but it is not pointing to any line of code. I don't know how to debug it. It crashed only on iPad (It crashed to some user in production). I think it is regarding PrintKit on thread 0. Can please someone help me? Thanks in advance Code for displaying PrintController: if UIPrintInteractionController.canPrint(pdfURL) {             let printInfo = UIPrintInfo(dictionary: nil)             printInfo.jobName = pdfURL.lastPathComponent             printInfo.outputType = .general             let printController = UIPrintInteractionController.shared             printController.printInfo = printInfo             printController.showsNumberOfCopies = false             printController.printingItem = pdfURL             printController.present(animated: true, completionHandler: nil)         } Crash log: Incident Identifier: INCIDENT ID Hardware Model: iPad13,2 Process: **APP-NAME** [89317] Path: /private/var/containers/Bundle/Application/**ID**/**APP-NAME**.app/**APP-NAME** Identifier: BUNDLE ID Version: 1.0 (4) AppStoreTools: 13C88a AppVariant: 1:iPad13,2:15 Code Type: ARM-64 (Native) Role: Background Parent Process: launchd [1] Coalition: BUNDLE ID Date/Time: 2022-01-05 09:09:35.5332 +0000 Launch Time: 2022-01-05 07:15:54.2451 +0000 OS Version: iPhone OS 15.1 (19B74) Release Type: User Baseband Version: 3.00.00 Report Version: 104 Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001b97c3558 semaphore_timedwait_trap + 8 1 libdispatch.dylib 0x00000001831ccc6c _dispatch_sema4_timedwait + 64 (lock.c:154) 2 libdispatch.dylib 0x00000001831cd270 _dispatch_semaphore_wait_slow + 76 (semaphore.c:116) 3 PrintKit 0x00000001e4adf548 -[PK_HTTPProxy withProtocolSync:] + 252 (PKBonjour.m:232) 4 PrintKit 0x00000001e4adfa94 pk_proxyConnectHTTP + 572 (PKBonjour.m:264) 5 PrintKit 0x00000001e4af4a34 -[PKPrinter(PKPrinterPrivate) getAttributes:count:] + 240 (PKPrinter.m:2744) 6 PrintKit 0x00000001e4af1004 -[PKPrinter doMedia2:] + 84 (PKPrinter.m:1542) 7 PrintKit 0x00000001e4aee88c -[PKPrinter printInfoSupported] + 1216 (PKPrinter.m:969) 8 UIKitCore 0x000000018687ed04 -[UIPrinterUtilityTableViewController initWithPrinter:] + 588 (UIPrinterUtilityTableViewController.m:230) 9 UIKitCore 0x000000018687254c -[UIPrinterBrowserViewController printerInfoButtonTapped:] + 80 (UIPrinterBrowserViewController.m:578) 10 UIKitCore 0x0000000186871340 -[UIPrinterTableViewCell printerAccessoryViewInfoButtonPressed:] + 84 (UIPrinterBrowserViewController.m:327) 11 UIKitCore 0x000000018687054c -[UIPrinterAccessoryView infoButtonPressed:] + 92 (UIPrinterBrowserViewController.m:124) 12 UIKitCore 0x0000000185e2fbf0 -[UIApplication sendAction:to:from:forEvent:] + 100 (UIApplication.m:5360) 13 UIKitCore 0x0000000185f5ba4c -[UIControl sendAction:to:forEvent:] + 128 (UIControl.m:871) 14 UIKitCore 0x0000000185cd72c8 -[UIControl _sendActionsForEvents:withEvent:] + 352 (UIControl.m:942) 15 UIKitCore 0x0000000185d73ae0 -[UIButton _sendActionsForEvents:withEvent:] + 160 (UIButton.m:4142) 16 UIKitCore 0x00000001860067c0 -[UIControl touchesEnded:withEvent:] + 536 (UIControl.m:637) 17 UIKitCore 0x0000000185acbd40 _UIGestureEnvironmentUpdate + 6708 (UIGestureEnvironment.m:653) 18 UIKitCore 0x0000000185afe8c8 -[UIGestureEnvironment _updateForEvent:window:] + 784 (UIGestureEnvironment.m:1332) 19 UIKitCore 0x0000000185b0ba68 -[UIWindow sendEvent:] + 4428 (UIWindow.m:3265) 20 UIKitCore 0x0000000185cbb318 -[UIApplication sendEvent:] + 828 (UIApplication.m:11864) 21 UIKitCore 0x0000000185adec30 __dispatchPreprocessedEventFromEventQueue + 7904 (UIEventDispatcher.m:2290) 22 UIKitCore 0x0000000185ad3a1c __processEventQueue + 6760 (UIEventDispatcher.m:2597) 23 UIKitCore 0x0000000185ad8ec8 __eventFetcherSourceCallback + 172 (UIEventDispatcher.m:2669) 24 CoreFoundation 0x000000018357c020 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28 (CFRunLoop.c:1972) 25 CoreFoundation 0x000000018358cce0 __CFRunLoopDoSource0 + 208 (CFRunLoop.c:2016) 26 CoreFoundation 0x00000001834c6fe8 __CFRunLoopDoSources0 + 268 (CFRunLoop.c:2053) 27 CoreFoundation 0x00000001834cc7f4 __CFRunLoopRun + 820 (CFRunLoop.c:2951) 28 CoreFoundation 0x00000001834e03b8 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268) 29 GraphicsServices 0x000000019ee7038c GSEventRunModal + 164 (GSEvent.c:2200) 30 UIKitCore 0x0000000185e806a8 -[UIApplication _run] + 1100 (UIApplication.m:3493) 31 UIKitCore 0x0000000185bff7f4 UIApplicationMain + 2092 (UIApplication.m:5046) 32 SwiftUI 0x000000018b143258 closure #1 in KitRendererCommon(_:) + 164 (UIKitApp.swift:35) 33 SwiftUI 0x000000018b071534 runApp<A>(_:) + 252 (<compiler-generated>:0) 34 SwiftUI 0x000000018b052cb4 static App.main() + 128 (App.swift:114) 35 **APP-NAME** 0x0000000100fa08f0 $main + 28 (<compiler-generated>:10) 36 **APP-NAME** 0x0000000100fa08f0 main + 40 (TLContact.swift:0) 37 dyld 0x0000000101185a24 start + 520 (dyldMain.cpp:876) EOF
Replies
0
Boosts
0
Views
1k
Activity
Jan ’22