如何在从PDFView打印时确定打印面板是否成功关闭



我需要知道PDFViewPDFDocument是否已成功打印,以便在之后进行一些内务处理。从NSDocument打印常规NSView时,我可以进行

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];

documentDidRunModalPrintOperation回调中,我可以做内务处理。但是只有当我调用时,打印PDFView的内容才能正常工作

[myPDFView printWithInfo:[NSPrintInfo sharedPrintInfo] autoRotate:YES];

因此,我认为没有办法使用回调函数来运行打印操作,该函数将在打印面板关闭时调用。

由于macOS 10.7,PDFDocument中有一个函数返回NSPrintOperation,因此可以简单地执行

NSPrintOperation *op = [myPDFView.document printOperationForPrintInfo:self.printInfo scalingMode:kPDFPrintPageScaleToFit autoRotate:YES];

然后像正常的CCD_ 9一样继续,并在调用CCD_。

最新更新