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 <cups/cups.h>
cups_dest_t *dest;
int num_options;
cups_option_t *options;
int job_id;
/* Print a single file */
job_id = cupsPrintFile(dest->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?
Post not yet marked as solved
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.
Post not yet marked as solved
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.
Post not yet marked as solved
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?
Post not yet marked as solved
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?
Post not yet marked as solved
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