Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get "Page Attributes" option in Cocoa print dialog?

The program I'm writing runs under OS X 10.5 Leopard. My target has its Base SDK and Deployment Target both set to Mac OS X 10.5. When I initiate printing, my print dialog doesn't show the Page Attributes option in which the user can select page size and orientation.

No Page Attributes

Other programs running under Leopard do show this option:

Yes Page Attributes

Here's the code that initiates printing:

-(void)print {
    NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
    TemperaturePressurePrintView *printView = [[TemperaturePressurePrintView alloc] initWithFrequencies:frequencies];
    if (printView) {
        [[NSPrintOperation printOperationWithView:printView printInfo:printInfo] runOperation];
        [printView release];
    }
}

What do I need to do to get Page Attributes to show up in my print dialog?

like image 355
SSteve Avatar asked Jan 12 '12 18:01

SSteve


1 Answers

This was a tough thing to search for because the results were mostly about using the print panel, not programming one. I finally found a clue on Cocoabuilder where it mentions NSPrintPanelOptions and NSPrintPanel's -setOptions: method.

This code accomplishes what I need:

-(void)print {
    NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
    TemperaturePressurePrintView *printView = [[TemperaturePressurePrintView alloc] initWithFrequencies:frequencies];
    if (printView) {
        NSPrintOperation *op = [NSPrintOperation printOperationWithView:printView printInfo:printInfo];
        [[op printPanel] setOptions:[[op printPanel] options] | NSPrintPanelShowsPageSetupAccessory];
        [op runOperation];
        [printView release];
    }
}
like image 64
SSteve Avatar answered Nov 10 '22 08:11

SSteve