Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In OS X 10.9, Apple introduced a simple way to export user content as PDF. The menu item called 'Export as PDF' is used to present a save sheet to export the data. (A example for this is Safari) In its WWDC Videos Apple showed how it works, but my solution doesn't seem to be right. I am using a non-document based app.

I have managed to get the save sheet so far, but with my current code, I get the print sheet as well after that. Furthermore, no data is saved so far.

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?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

From NSView Class Reference:

dataWithPDFInsideRect:
Returns PDF data that draws the region of the receiver within a specified rectangle.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...