-Environment
iPad:10th、iOS:17.6.1、Printer:EPSON PX-S730
-Question
Is this phenomenon due to iOS specifications?
Restarting the iPad solves the problem, but I don't think it's best practice to restart it every time you reproduce it.
Please let me know if you have a good solution.
-Problem
I am developing a print preview screen using AirPrint's print method.
If you submit a print job using AirPrint on an iPad while the printer is turned off and then cancel it, the print center remains on the app switcher.
After that, when I turned on the printer, I was no longer able to print using AirPrint on my iPad.
When using AirPrint's API "print" and when printing by launching AirPrint from Safari, we have confirmed the same behavior in both cases.
-How to reproduce
Turn off the printer
Print from iPad to printer using AirPrint
Launch the print center from the app switcher, cancel the print job, and set the number of print jobs to 0.
When you start the app switcher, the Print Center app remains.
In step 4, turn on the printer and print from the iPad to the printer using AirPrint.
When you start Print Center from the app switcher, the print job status becomes "Waiting" and the print job is not executed.
-Expected result
When there are no print jobs on the print center, the print center is closed on the app switcher.
You can print from your iPad to the printer using AirPrint, and then print from the printer.
-Actual results
When there are no print jobs on the print center, the print center remains on the app switcher without being closed.
In the above situation, when printing from the iPad to the printer using AirPrint, the printer does not print.
When I start the print center, the print job status is "Waiting" and is queued.
-Code
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error").
}else if completed{
print("completed") //this scenario handles completion response
}else{
print("cancel")
}
})
-Link of API used
Apple Developer-AirPrint-print
-Similar inquiries
Apple Developer Forum - Print Center on my iPhone shows a pending document to print and I can't get rid of it
AirPrint
RSS for tagAirPrint allows photo and document printing in your iOS apps and macOS apps without the need to download or install drivers.
Posts under AirPrint tag
16 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Environment→ ・Device: iPad 9th generation ・OS:**iOS17.5.1 ・Printer model:EPSON PX-S730
Current issues→
01). After canceling a print job in the Print Center, the Print Center screen on the iPad does not close.
02). When the printer is turned on and a new print job is sent, the Print Center shows the ongoing waiting job instead of proceeding with printing.
Problem Description→
The AirPrint feature on an iPad 9th generation running iOS 17.5.1 is being used with an EPSON PX-S730 printer. When sending a print job while the printer is off, the Print Center shows the ongoing printing job. If the print job is canceled in the Print Center, the Print Center screen on the iPad does not close. After turning on the printer and sending the print job again, the Print Center shows the ongoing waiting job.
What I want→
The Print Center screen on the iPad to close automatically after canceling a print job.
Test code:
Note: printController.print response is completed but Print Center status is waiting
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error").
}else if completed{
print("completed") //this scenario handles completion response
}else{
print("cancel")
}
})
Environment→ ・Device: iPad 9th generation ・OS:**iOS17.5.1 ・Printer model:EPSON PX-S730
Current issues→
An error message is not returned from the printer if a print job is sent while the printer is off.
Problem Description→
The AirPrint feature on an iPad 9th generation running iOS 17.5.1 is being used with an EPSON PX-S730 printer. When sending a print job while the printer is off, the Print Center shows the ongoing printing job, but the printing cannot be executed because the printer is off.
What I want→
I would like an error to be returned when I submit a printing job while the printer is off.
Test code:
Note: printController.print response is completed but Print Center status is printing
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = "Print Job"
printController.printInfo = printInfo
let pdfURL = Bundle.main.url(forResource: "sample", withExtension: "pdf")!
printController.printingItem = pdfURL
let printer = UIPrinter(url: printerUrl)
printController.print(to: printer, completionHandler: { [self] printController, completed, error in
if(error != nil){
print("error").
}else if completed{
print("completed"). //this scenario handles completion response
}else{
print("cancel")
}
})
Ever since the advent of Ventura, saved print settings don’t save detailed selections. Even with Sonoma, almost 2 years later, this issue is still a problem! There is a plethora of Apple Support Community topics to that end:
Print settings don't work any more when upgraded to Ventura
Updated to Ventura—printer presets won’t save
Ventura—Custom Printer Settings not being saved
Printer Not working after Ventura 13.0 update
Problem saving print presets in Ventura
Ventura is not saving printing presets (fully)
Printing Problem with Ventura
macOS Ventura (13.1) print settings don’t save—any resolution?
Printer presets don’t save in Ventura
Print settings are a MESS in Ventura
We are hoping to port our app which requires printing to visionOS. Can I check if visionOS supports AirPrint/printing? If anyone has already done it, anything we should watch out for?
Hi,
In Windows and Linux, it's possible to ask a printer to print content programmatically in Black & White. This may be referred to as "Monochrome", "Grayscale", "B&W", depending on the device driver.
For feature parity with other operating systems, I'd like to do the same -- programmatically -- in macOS using Objective-C or Swift. Is this possible? If not, what's the best, formal way to request this useful OS feature to Apple so that it may be added in a future release?
More context about this request:
https://github.com/openjdk/jdk/pull/18195
UIPrintInteractionController crashed when I use it to print a html content.
Fatal Exception: NSInternalInconsistencyException
UITableView dataSource returned a nil cell for row at index path: <NSIndexPath: 0x938e90f84baaa518> {length = 2, path = 1 - 0}. Table view: <UITableView: 0x107991000; frame = (0 0; 375 419); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x2846b0000>; backgroundColor = <UIDynamicSystemColor: 0x281d2e400; name = systemGroupedBackgroundColor>; layer = <CALayer: 0x2848aa480>; contentOffset: {0, -56}; contentSize: {375, 357.0830078125}; adjustedContentInset: {56, 0, 0, 0}; dataSource: <UIPrintOptionsTableViewController: 0x107973800>>, dataSource: <UIPrintOptionsTableViewController: 0x107973800>
here is the code
private let webView = WKWebView()
private let printController = UIPrintInteractionController.shared
func showPrintView(encodedHtml: String) {
printController.delegate = self
let decodedHtmlString = base64Decode(encodedHtml)
webView.loadHTMLString(decodedHtmlString, baseURL: nil)
loadPrint()
}
private func loadPrint() {
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.orientation = .landscape
printController.printInfo = printInfo
printController.printFormatter = webView.viewPrintFormatter()
Timer.scheduledTimer(withTimeInterval: 0.6, repeats: false) { _ in
self.printController.present(animated: true) { _, _, error in
guard let error = error else { return }
self.error = error
}
}
}
private func base64Decode(_ text: String) -> String {
if let restoreData = Data(base64Encoded: text) {
if let restoreString = String(data: restoreData, encoding: .utf8) {
return restoreString
}
}
return ""
}
I'm sure did nothing with UIPrintOptionsTableViewController so I have no idea how did this crash happened and how to fix it. Can someone help me?
After updating to the lates OS many of the standard page sizes have disappeared from the HP Officejet Pro 7740 setting such as the full bleed 8.5 x 11 and full bleed 11 x 17... is this up to to correct or HP?
For printing from worker thread to a UIPrinter(whose url i have saved ) i am doing this and able to print :
func PrintPdfDocument (pDocument:Data)
{
// Create a print interaction controller
let printController = UIPrintInteractionController.shared
// Set the printing options
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.jobName = "Print Job "
printController.printInfo = printInfo
printController.showsPageRange = true
// Set the PDF document to be printed
printController.printingItems = pDocument
printController.print(to: defaulttprinter, completionHandler: { (controller, completed, error) in
if completed {
print("Printing successful!")
} else {
if let error = error {
print("Printing failed with error: \(error.localizedDescription)")
} else {
print("Printing was canceled.")
}
}
})
}
When i call PrintPdfDocument (pDocument:Data) function , more than once with diffrent data shown below :
DispatchQueue.global().async {
PrintPdfDocument (pDocument:data1)
}
DispatchQueue.global().async {
PrintPdfDocument (pDocument:data2)
}
DispatchQueue.global().async {
PrintPdfDocument (pDocument:data3)
}
Printer is printing only one document(data1) .
For other call is not executing printController.print (to....) function inside PrintPdfDocument.
I'm working with cupsfilter command to convert files from PDF to PS.
We had been previously working with cupsfilter on Linux, but we had to migrate to macOS and some of the command line arguments are not compatible.
In particular, we can't control autorotation and scaling on macOS. They seem to be "on" by default, but there are some cases where we need to turn them "off" so page doesn't rotate or scale to fit automatically.
On Linux, those options are controlled with -o nopdfAutorotate and -o nofit-to-page.
Any ideas how to control rotation and scaling on macOS?
Thank you very much in advance.
I want to use CUPS in iOS for printing and it is mentioned at many places that we can use cups for printing in ios .But when i import library cups/cups.h ,xcode is giving error "cups/cups.h not found".
code i am using in a objective c file :
import &lt;cups/cups.h&gt;
cups_dest_t *dest;
int num_options;
cups_option_t *options;
int job_id;
/* Print a single file */
job_id = cupsPrintFile(dest-&gt;name, "/usr/share/cups/data/testprint.ps",
"Test Print", num_options, options);
Do i need to intall some driver or any library to make it work ? or is it the case that CUPS is not available for iOS?
We have an app that exports PDFs with a custom page size, using PSDKit. In iOS16 the PDF export would have the correct page size dimensions, but now iOS17 exports everything to a Letter (8.5x11) size, regardless of what the PDF size specs are defined in the code:
let pageWidth: CGFloat = 86.0 / 25.4 * 72
let pageHeight: CGFloat = 54.0 / 25.4 * 72
let pageSize = CGRect(x: 0, y: 0, width: pageWidth, height: pageHeight)
Any thoughts as to how to fix this?
Fatal Exception: NSInvalidArgumentException
<UIPrintPanelNavigationController: 0x144010a00> is pushing the same view controller instance (<UIPrinterBrowserViewController: 0x142854400>) more than once which is not supported and is most likely an error in the application : com.myapp.myapp
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0xec870 __exceptionPreprocess
1 libobjc.A.dylib 0x2bc00 objc_exception_throw
2 UIKitCore 0xcb284 -[UINavigationController pushViewController:transition:forceImmediate:]
3 UIKitCore 0xca398 -[UINavigationController pushViewController:animated:]
4 PrintKitUI 0x45024 -[UIPrintPanelNavigationController pushViewController:animated:]
5 UIKitCore 0x129b78 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:]
6 UIKitCore 0x129680 -[_UIViewControllerTransitionContext _runAlongsideCompletions]
7 UIKitCore 0x128d10 -[_UIViewControllerTransitionContext completeTransition:]
8 UIKitCore 0x7a3d48 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_5
9 UIKitCore 0x84a38 __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__
10 UIKitCore 0x841d0 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]
11 UIKitCore 0x83848 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
12 UIKitCore 0x65aa4 -[UIViewAnimationState animationDidStop:finished:]
13 UIKitCore 0x65bb8 -[UIViewAnimationState animationDidStop:finished:]
14 QuartzCore 0x72098 run_animation_callbacks(void*)
15 libdispatch.dylib 0x4300 _dispatch_client_callout
16 libdispatch.dylib 0x12998 _dispatch_main_queue_drain
17 libdispatch.dylib 0x125b0 _dispatch_main_queue_callback_4CF
18 CoreFoundation 0x3720c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
19 CoreFoundation 0x33f18 __CFRunLoopRun
20 CoreFoundation 0x33668 CFRunLoopRunSpecific
21 GraphicsServices 0x35ec GSEventRunModal
22 UIKitCore 0x22c2b4 -[UIApplication _run]
23 UIKitCore 0x22b8f0 UIApplicationMain
24 MyApp 0x4a940 main + 14 (main.m:14)
25 ??? 0x1ac55adcc (Missing)
I found this crash in Firebase crashlytics.
This is device info
Model:iPad Air (5th generation)
Version:17.1.1
Orientation:Landscape
Please help me to findout the root cause of the crash and possible solution.
I have tried to reprduce the crash but didn't reproduce.
I use the following code to print PDF:
let printInfo = UIPrintInfo.printInfo()
printInfo.outputType = UIPrintInfo.OutputType.general
printInfo.jobName = "My Print Job"
printInfo.orientation = .portrait
let printController = UIPrintInteractionController.shared
printController.printInfo = printInfo
printController.printingItem = pdfData
printController.delegate = self
printController.present(animated: true, completionHandler: nil)
Everything works fine, but according to the Xcode Organizer, some users experience sporadic crashes after initiating printing. It appears that these crashes may be related to updates in the UI within UIPrintInteractionController. The majority of these crashes occur on iOS 16, with a few also affecting iOS 17. I am unable to reproduce the issue.
Stack trace for iOS 16.6.1:
Fatal Exception: NSInternalInconsistencyException
Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (0), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out). Collection view: <UICollectionView: 0x14d9a1a00; frame = (0 0; 235 944); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x281fe9fb0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x28164e660>; contentOffset: {0, 0}; contentSize: {235, 88}; adjustedContentInset: {0, 0, 0, 0}; layout: <UIPrintPreviewFlowLayout: 0x14b7c1320>; dataSource: <UIPrintPreviewViewController: 0x14d811200>>
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x9cb4 __exceptionPreprocess
1 libobjc.A.dylib 0x183d0 objc_exception_throw
2 Foundation 0x4e154c _userInfoForFileAndLine
3 UIKitCore 0x7024f4 -[UICollectionView _Bug_Detected_In_Client_Of_UICollectionView_Invalid_Number_Of_Items_In_Section:]
4 UIKitCore 0x30d5a8 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:]
5 UIKitCore 0x26bd5c -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:]
6 UIKitCore 0x26d0e0 -[UICollectionView reloadItemsAtIndexPaths:]
7 PrintKitUI 0x2677c __55-[UIPrintPreviewViewController updatePrintPreviewInfo:]_block_invoke_3
8 UIKitCore 0x30494 +[UIView(Animation) performWithoutAnimation:]
9 PrintKitUI 0x266c8 __55-[UIPrintPreviewViewController updatePrintPreviewInfo:]_block_invoke
10 PrintKitUI 0x57b30 -[UIPrintPreviewPageFetcher resetAllPages:]
11 PrintKitUI 0x26460 -[UIPrintPreviewViewController updatePrintPreviewInfo:]
12 PrintKitUI 0x47b84 -[UIPrintPanelViewController updatePrintPreviewInfo]
13 PrintKitUI 0x45d5c -[UIPrintPanelViewController observeValueForKeyPath:ofObject:change:context:]
14 Foundation 0x3c0d0 NSKeyValueNotifyObserver
15 Foundation 0x52618 NSKeyValueDidChange
16 Foundation 0x3f518 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
17 Foundation 0x3f248 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
18 Foundation 0x3e1f8 _NSSetLongLongValueAndNotify
19 PrintKitUI 0x52e00 -[UIPrintInColorOption observeValueForKeyPath:ofObject:change:context:]
20 Foundation 0x3c0d0 NSKeyValueNotifyObserver
21 Foundation 0x52618 NSKeyValueDidChange
22 Foundation 0x3f518 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
23 Foundation 0x3f248 -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
24 Foundation 0x3e7dc _NSSetObjectValueAndNotify
25 PrintKitUI 0x496f0 __51-[UIPrintPanelViewController lookupLastUsedPrinter]_block_invoke_2
26 libdispatch.dylib 0x2320 _dispatch_call_block_and_release
27 libdispatch.dylib 0x3eac _dispatch_client_callout
...
Stack trace for iOS 17.0.3:
Fatal Exception: NSInternalInconsistencyException
UITableView dataSource returned a nil cell for row at index path: <NSIndexPath: 0x96b9dd5bd6ad637d> {length = 2, path = 0 - 0}. Table view: <UITableView: 0x108846400; frame = (0 0; 430 542); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x281fa8ae0>; backgroundColor = <UIDynamicSystemColor: 0x280481bc0; name = systemGroupedBackgroundColor>; layer = <CALayer: 0x2817cbea0>; contentOffset: {0, -56}; contentSize: {430, 332.99999618530273}; adjustedContentInset: {56, 0, 0, 0}; dataSource: <UIPrintOptionsTableViewController: 0x108819600>>, dataSource: <UIPrintOptionsTableViewController: 0x108819600>
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0xed5e0 __exceptionPreprocess
1 libobjc.A.dylib 0x2bc00 objc_exception_throw
2 Foundation 0x6bc398 _userInfoForFileAndLine
3 UIKitCore 0x289d74 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
4 UIKitCore 0x289a70 -[UITableView _updateVisibleCellsForRanges:createIfNecessary:]
5 UIKitCore 0x287fbc -[UITableView _updateVisibleCellsNow:]
6 UIKitCore 0xfc45dc -[UITableView _updateAnimationDidStopWithOldVisibleViews:finished:context:]
7 UIKitCore 0x850bc __UIVIEW_IS_EXECUTING_ANIMATION_COMPLETION_BLOCK__
8 UIKitCore 0x84854 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:]
9 UIKitCore 0x83ecc -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
10 UIKitCore 0x66498 -[UIViewAnimationState animationDidStop:finished:]
11 QuartzCore 0x7276c run_animation_callbacks(void*)
12 libdispatch.dylib 0x4300 _dispatch_client_callout
...
Full exception stacktrace iOS 16
Full exception stacktrace iOS 17
Is anyone experiencing similar issues?
Thanks!
After updating to Mac OS Sonoma, we have encountered compatibility issues with our iPad-designed application, specifically with the AirPrint functionality, when it is run on MacOS. The AirPrint feature stopped working properly through UIPrintInteractionController.shared.
We have noticed that when we compile the application using Catalyst, the AirPrint functionality is restored and works as expected. However, this solution is not viable for us due to the restrictions associated with the frameworks we are utilizing.
We are seeking alternative solutions, and any help or guidance would be highly appreciated to resolve this issue and ensure a seamless and uninterrupted user experience in our application.
STEPS TO REPRODUCE
Create an app for ipad with just a button and this code
var str = "TEST"
let printInfo = UIPrintInfo(dictionary:nil)
printInfo.outputType = .general
printInfo.jobName = "Report"
printInfo.orientation = .portrait
let printController = UIPrintInteractionController.shared
printController.printInfo = printInfo
printController.showsNumberOfCopies = false
printController.showsPageRange = false
printController.showsNumberOfCopies = false
let formatter = UIMarkupTextPrintFormatter(markupText: str)
formatter.contentInsets = UIEdgeInsets(top: 72, left: 72, bottom: 72, right: 72)
printController.printFormatter = formatter
printController.present(animated: true, completionHandler: nil)
2.Run it on a MacOS with Sonoma, there is no error on console or anything but it don't work.
-If you run it with Catalyst it just works when adding the Printing permission of App Sandbox in Signing & Capabilities.
Starting iOS 16 seeing some crashes related to pdf printing in the crash reporter. It looks like the issue is not so frequent. Also, I'm unable to reproduce the crash. Looks like the app crashes when the print preview dialog is opening. According to crash reports, there are some crashes on different iOS 16 versions: 16.0.0, 16.0.2, and 16.0.3.
Printing code:
let printInfo = UIPrintInfo.printInfo()
printInfo.jobName = "Printing Job Name"
self.printViewController = UIPrintInteractionController.shared
self.printViewController?.printInfo = printInfo
self.printViewController?.printingItem = pdfURL
self.printViewController?.present(from: barButtonItem, animated: true) { (controller, completed, error) in
self.printViewController = nil
}
Stack trace:
compare_key + 4 (CGPDFObject.c:134)
bsearch + 68 (bsearch.c:70)
CGPDFDictionaryGetUnresolvedObject + 68 (CGPDFDictionary.c:153)
CGPDFDictionaryGetObject + 44 (CGPDFDictionary.c:172)
CGPDFDictionaryGetDictionary + 44 (CGPDFDictionary.c:284)
get_pages_dictionary + 68 (pdf-reader.c:410)
pdf_reader_get_number_of_pages + 76 (pdf-reader.c:557)
-[UIPrintPreviewPageFetcher fetchNumberOfItems] + 76 (UIPrintPreviewPageFetcher.m:115)
-[UIPrintPreviewViewController collectionView:numberOfItemsInSection:] + 32 (UIPrintPreviewViewController.m:482)
-[UICollectionViewData _updateItemCounts] + 220 (UICollectionViewData.mm:335)
-[UICollectionViewData isIndexPathValid:validateItemCounts:] + 52 (UICollectionViewData.mm:348)
-[UICollectionViewData validatedGlobalIndexForItemAtIndexPath:] + 36 (UICollectionViewData.mm:778)
-[UICollectionView _cellForItemAtIndexPath:] + 108 (UICollectionView.m:7112)
-[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 1384 (UICollectionView.m:9357)
-[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] + 396 (UICollectionView.m:9104)
-[UICollectionView reloadItemsAtIndexPaths:] + 52 (UICollectionView.m:9124)
-[UIPrintPreviewViewController reloadVisibleItems:] + 256 (UIPrintPreviewViewController.m:568)
__63-[UIPrintPreviewViewController updatePdfURL:options:completed:]_block_invoke_2 + 44 (UIPrintPreviewViewController.m:305)
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24 (NSOperation.m:1545)
-[NSBlockOperation main] + 104 (NSOperation.m:1564)
__NSOPERATION_IS_INVOKING_MAIN__ + 16 (NSOperation.m:2189)
-[NSOperation start] + 708 (NSOperation.m:2206)
There is full stack trace I got from the Organizer
Thanks!