cocoansprintoperationnsprintinfo

Automatically open PDF in Preview when printing


I'm setting jobDisposition to NSPrintPreviewJob in NSPrintInfo, but the value seems to be ignored. Instead of opening the document in Preview, the print operation displays the print panel as usual.


Solution

  • To go directly to preview, you need to suppress the print panel:

    printInfo.jobDisposition = NSPrintPreviewJob;
    NSPrintOperation *op = [NSPrintOperation printOperationWithView:view
                                                          printInfo:printInfo];
    op.showsPrintPanel = NO;
    [op runOperation];