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

75 Posts

Post

Replies

Boosts

Views

Activity

How to print double-sided pages using UIPrintInteractionController(AirPrint) in Swift
I'm using UIPrintInteractionController(AirPrint) to print documents in my swift application. I was able to print the documents using my application, but all of them are printing in one-sided. Now i want to add a double-sided printing as an option to my application. After some research i found that it can be implement by adding info.duplex = UIPrintInfo.Duplex.longEdge to printInfo. I tried it using the below code. private var printController = UIPrintInteractionController.shared let info = UIPrintInfo.printInfo() info.duplex = UIPrintInfo.Duplex.longEdge <<<<<< info.jobName = "XXXPrint" info.orientation = .portrait printController.printInfo = info printController.print(to: printer, completionHandler: { [self] controller, completed, error in if(error != nil){ print("successfully") }else{ print("Printing error: \(error.localizedDescription)") } } But whether i set it in the code and run my application it is printing the pages by one-sided. So if some one can guide me to double-sided printing workable solution highly appreciated!!
0
0
1.2k
Jul ’23
PrintKitUI Crash - NSInternalInconsistencyException
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)
0
0
1.2k
May ’23
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.6k
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.2k
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
998
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.4k
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
872
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.5k
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.3k
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.8k
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
928
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
982
Feb ’22
How to print double-sided pages using UIPrintInteractionController(AirPrint) in Swift
I'm using UIPrintInteractionController(AirPrint) to print documents in my swift application. I was able to print the documents using my application, but all of them are printing in one-sided. Now i want to add a double-sided printing as an option to my application. After some research i found that it can be implement by adding info.duplex = UIPrintInfo.Duplex.longEdge to printInfo. I tried it using the below code. private var printController = UIPrintInteractionController.shared let info = UIPrintInfo.printInfo() info.duplex = UIPrintInfo.Duplex.longEdge <<<<<< info.jobName = "XXXPrint" info.orientation = .portrait printController.printInfo = info printController.print(to: printer, completionHandler: { [self] controller, completed, error in if(error != nil){ print("successfully") }else{ print("Printing error: \(error.localizedDescription)") } } But whether i set it in the code and run my application it is printing the pages by one-sided. So if some one can guide me to double-sided printing workable solution highly appreciated!!
Replies
0
Boosts
0
Views
1.2k
Activity
Jul ’23
PrintKitUI Crash - NSInternalInconsistencyException
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)
Replies
0
Boosts
0
Views
1.2k
Activity
May ’23
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.6k
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.2k
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
998
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.4k
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
872
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.5k
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.3k
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.8k
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
928
Activity
Aug ’22
Help with print
Documents with mixed size pages won’t print correctly
Replies
1
Boosts
0
Views
1.1k
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.6k
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
887
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
982
Activity
Feb ’22