How do I export a view to PDF in OS X?

In OS X 10.9, Apple introduced an easy way to export custom content as PDF. The Export as PDF menu item is used to present a save sheet for exporting data. (An example for this is Safari) Apple demonstrated how this works in their WWDC videos, but my solution seems to be wrong. I am using a non document based application.

I've managed to get the save sheet so far, but with my current code, I also got the print sheet. Also, until the data is saved.

Here is my code:

NSPrintOperation* printOP = [NSPrintOperation printOperationWithView:_textView];
printOP.printInfo.jobDisposition = NSPrintSaveJob;
[printOP runOperationModalForWindow:_window 
                           delegate:nil didRunSelector:nil contextInfo:nil];

      

What am I doing wrong?

thank

+3


source to share


1 answer


From NSView Class Reference :



dataWithPDFInsideRect:
Returns PDF data that draws the destination area within the specified rectangle.

+5


source







All Articles