Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Printing Directly To PDF Without Dialog

 
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  drawing updates  
Author Message
mstearne

External


Since: Dec 01, 2004
Posts: 2



(Msg. 1) Posted: Wed Dec 01, 2004 9:30 pm
Post subject: Printing Directly To PDF Without Dialog
Archived from groups: comp>sys>mac>programmer>help (more info?)

I found the following code which saves the contents of a NSTextView to
a PDF. This codde handles the paging and gives the user the standard
dialog asking where to save the file. I am wondering if I can save the
view (in my case a webView ) directly to a filename that I specify
without asking the user to name the file. Is this possible?


NSPrintInfo *printInfo;
NSPrintInfo *sharedInfo;
NSPrintOperation *printOp;
NSMutableDictionary *printInfoDict;
NSMutableDictionary *sharedDict;

sharedInfo = [NSPrintInfo sharedPrintInfo];
sharedDict = [sharedInfo dictionary];
printInfoDict = [NSMutableDictionary
dictionaryWithDictionary:sharedDict];
[printInfoDict setObject:NSPrintSaveJob
forKey:NSPrintJobDisposition];
[printInfoDict setObject:[sheet filename]
forKey:NSPrintSavePath];
printInfo = [[NSPrintInfo alloc] initWithDictionary:
printInfoDict];
[printInfo setHorizontalPagination: NSAutoPagination];
[printInfo setVerticalPagination: NSAutoPagination];
[printInfo setVerticallyCentered:NO];
printOp = [NSPrintOperation printOperationWithView:textView
printInfo:printInfo];
[printOp setShowPanels:NO];
[printOp runOperation];


(Original code from http://cocoadevcentral.com/articles/000074.php)
Thanks for any help...
Michael
Back to top
Login to vote
Frédéric Testuz

External


Since: Oct 06, 2004
Posts: 7



(Msg. 2) Posted: Thu Dec 02, 2004 8:17 am
Post subject: Re: Printing Directly To PDF Without Dialog [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

a écrit dans le message de

> I found the following code which saves the contents of a NSTextView to
> a PDF. This codde handles the paging and gives the user the standard
> dialog asking where to save the file. I am wondering if I can save the
> view (in my case a webView ) directly to a filename that I specify
> without asking the user to name the file. Is this possible?
>
>
> NSPrintInfo *printInfo;
> NSPrintInfo *sharedInfo;
> NSPrintOperation *printOp;
> NSMutableDictionary *printInfoDict;
> NSMutableDictionary *sharedDict;
>
> sharedInfo = [NSPrintInfo sharedPrintInfo];
> sharedDict = [sharedInfo dictionary];
> printInfoDict = [NSMutableDictionary
> dictionaryWithDictionary:sharedDict];
> [printInfoDict setObject:NSPrintSaveJob
> forKey:NSPrintJobDisposition];
> [printInfoDict setObject:[sheet filename]
> forKey:NSPrintSavePath];
> printInfo = [[NSPrintInfo alloc] initWithDictionary:
> printInfoDict];
> [printInfo setHorizontalPagination: NSAutoPagination];
> [printInfo setVerticalPagination: NSAutoPagination];
> [printInfo setVerticallyCentered:NO];
> printOp = [NSPrintOperation printOperationWithView:textView
> printInfo:printInfo];
> [printOp setShowPanels:NO];
> [printOp runOperation];

I don't know why it would not work, but for a WebView, you don't print the
WebView itself. You print [[[WebView mainFrame] frameView] documentView].
And you must wait that the WebView had load the request before sending the
runOperation message. For this use the webView:didFinishLoadForFrame: method
of the WebFrameLoadDelegate.

Personnaly, I used it only for simple web page without frame (HTML frame)
until now. I heard it can be a little more complex otherwise.

--
Frédéric Testuz
Back to top
Login to vote
Display posts from previous:   
Related Topics:
About Dialog Box - Someone please solve my problem I am developing a carbon application in X-code in Mac Os 10.3 and in that i have the ...

Dialog Problems - I am an hobbyist programmer of intermediate skills programming in the C language a Carbon application on Mac OS v 8.6 o...

Modal dialog Filters under X? - I've been trying to write a ModalDialog filter under OSX. The reason is that I need to create an external code for Ins...

dialog box as event - When an application opens up a dialog box, does it generate a mac-scpecific event? As an example, I have an audio progr...

browse file dialog? - Hello... May I know how to create a "Browse" button? How to create a button and having the browse for file c...

Display Dialog in Carbon - What am I doing wrong? - I'm porting my PPC application to OSX in Carbon. I'm trying to create a dialog from a DLOG reference, but no dialog is...
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA



[ Contact us | Terms of Service/Privacy Policy ]