I need to know if the PDFDocument of a PDFView has been printed successfully in order to do some housekeeping afterwards.
When printing a regular NSView from NSDocument, I can do
NSPrintOperation *op = [NSPrintOperation
printOperationWithView:myRegularPrintView
printInfo:self.printInfo];
[op setCanSpawnSeparateThread:NO]; // Because we want to clean up afterwards
[op setShowsPrintPanel:YES];
[self runModalPrintOperation:op
delegate:self
didRunSelector:@selector(documentDidRunModalPrintOperation:success:contextInfo:)
contextInfo:NULL];
In the documentDidRunModalPrintOperation callback I can do the housekeeping. But printing the content of a PDFView only works correctly if I call
[myPDFView printWithInfo:[NSPrintInfo sharedPrintInfo] autoRotate:YES];
So I see no way to run the print operation with a callback function that is going to be called when the print panel is closed.
Since macOS 10.7 there is a function in
PDFDocumentwhich returns aNSPrintOperation, so one can simply doand then continue just like with a normal
NSViewand add a callback when callingrunModalPrintOperation.