Printing Problem (Was: Re: Generating PDFs....)
Printing Problem (Was: Re: Generating PDFs....)
- Subject: Printing Problem (Was: Re: Generating PDFs....)
- From: Dave DeLong <email@hidden>
- Date: Wed, 29 Jun 2005 19:13:11 -0500
Hi everyone,
Thanks for the tips on how to make PDFs. I tried a couple different
ways (drawing directly into an NSImage, typing into a hidden
NSTextView and then getting PDF data), but I didn't have much success
with either.
A friend of mine then pointed out I could try printing to a file, so
we worked up some code that takes the NSTextView and saves it to a
file (resulting in the wanted PDF). There's one glitch: every other
page in the PDF is blank. I end up with a 66 page PDF instead of a
33 page PDF.
Here's my printing code (textView is my NSTextView containing all of
the properly formatted text):
NSString * save = [@"~/Desktop/Preview.pdf"
stringByExpandingTildeInPath];
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:save 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];
Any ideas as to what I'm missing?
Thanks!
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden