0

Is it possible to cancel an already running NSPrintOperation? I have the following code:

let printOp: NSPrintOperation = NSPrintOperation(view: ..., printInfo: ...)
printOp.jobTitle = "Custom Print"
printOp.showsPrintPanel = false
printOp.showsProgressPanel = false
printOp.canSpawnSeparateThread = true
printOp.run()

I see there's a NSPrintInfo jobDisposition of .cancel but I don't know how I would apply that to an existing task thats running. You're able to do it in the printer job queue in macOS but I can't find a way to do it in code.

Thanks.

JoeBayLD
  • 939
  • 2
  • 10
  • 25
  • I don't know if it's possible to cancel the print operation but from where do you want to cancel? – Willeke Sep 30 '19 at 21:32
  • I’m not using a print panel. It’s all print command in swift code. If you open the printer queue in system preferences, you can delete jobs there - but I want that ability in my app. – JoeBayLD Oct 01 '19 at 22:05
  • Do you want to cancel the print operation while it is running or do you want to remove a completed print operation from the queue? – Willeke Oct 01 '19 at 22:15
  • Cancel a currently running operation. So say my app sent out 30 print commands, I want a way to cancel one (or all) of the currently running jobs. – JoeBayLD Oct 02 '19 at 02:42
  • Do you run 30 print operations simultaniously? It is possible to cancel a running print opereration with (the Swift equivalent of) `NSPrintOperation.currentOperation.printInfo.jobDisposition = NSPrintCancelJob;`. It is not possible to cancel a finished operation. – Willeke Oct 02 '19 at 09:02
  • Yeah.. I send a lot of batch prints. How does macOS do it then? In the printer jobs app I’m able to see all pending jobs and delete all of them. – JoeBayLD Oct 02 '19 at 09:11
  • Your question is How to cancel `printOp.run()` ("incoming" in the queue). Please ask a new question How to remove pending print jobs ("printing" in the queue). – Willeke Oct 02 '19 at 15:00

0 Answers0