How to find where NSPrintOperation created the saved PDF (NSPrintSaveJob)

107 views Asked by At

I'm using NSPrintOperation to optionally print or save as PDF. It works great, however, when using Save as PDF (NSPrintSaveJob), NSPrintOperation will put up a standard File Save dialog, and the user can CHANGE the proposed name.

I haven't been able to locate (but see NOTE at end) any returned value that shows the URL of the ultimate final location the user selected for the Save as PDF operation. For example, I looked in the NSPrintInfo dictionary to see if a key-value pair might have been added by NSPrintOperation, but none was:

Screenshot of NSPrintInfo* record

Is discovering that URL even possible?

Here's how I initialize the process (which is printing from a temporary .pdf I generated):

PDFDocument *pdfDocumentToPrint = [[PDFDocument alloc] initWithURL:(__bridge NSURL*)cfURL];
NSPrintOperation *op = [pdfDocumentToPrint printOperationForPrintInfo:(__bridge NSPrintInfo*)printInfo scalingMode:kPDFPrintPageScaleNone autoRotate:NO];

BOOL doPrintPreview = (((__bridge NSPrintInfo*)printInfo).jobDisposition == NSPrintPreviewJob) ? YES : NO;
BOOL doExportAsPDF = (((__bridge NSPrintInfo*)printInfo).jobDisposition == NSPrintSaveJob) ? YES : NO;

op.showsPrintPanel = !(doPrintPreview || doExportAsPDF);

[op runOperation];

CFRelease(cfURL);

NOTE: NSPDFInfo* DOES have a URL field that contains the final, user-specified file path, but it's unclear how to obtain an NSPDFInfo after a print operation.

0

There are 0 answers