Hide window that show when we use NSPrintOperation

321 views Asked by At

I use below code for print view1 and when i run it, a window open and i should select settings and click on print button then the view will print.how to do it (settings) in code (means window doesn't open and directly print view1 with settings that we set in code)

NSPrintOperation *printOperation= [NSPrintOperation 

printOperationWithView:view1];
[printOperation runOperation];
1

There are 1 answers

1
Justin Boo On BEST ANSWER

You can suppress the display of the NSPrintPanel object by sending setShowsPrintPanel: with a NO argument to the NSPrintOperation object before running the operation.

Just like this:

NSPrintOperation *printOperation= [NSPrintOperation printOperationWithView:view1];

[printOperation setShowsPrintPanel:NO];
[printOperation runOperation];