On May 2, 2010, at 7:57 PM, DairyKnight wrote:

> I've been working on a tool to print an NSView to a PDF file. I followed
> Apple's documentation but couldn't get the auto-pagination work.
> The resulting PDF file is always long and one-page.  Hope someone with
> relevant experience could help me. My code is as follows:


PDFOperationWithView doesn't do pagination. Instead you need to set the job 
disposition to generate a file rather than to output to a printer. Something 
like this:

NSDictionary *printInfoDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
        NSPrintSaveJob, NSPrintJobDisposition,
        urlToSave, NSPrintJobSavingURL, // use NSPrintSavePath on 10.5 or below.
        [NSNumber numberWithBOOL:hideExtension], 
NSPrintJobSavingFileNameExtensionHidden, // only on 10.6 or above.
        nil];
NSPrintInfo *printInfo = [[[NSPrintInfo alloc] 
initWithDictionary:printInfoDictionary] autorelease];
NSPrintOperation *operation = [NSPrintOperation printOperationWithView:view 
printInfo:printInfo];
--
David Duncan
Apple DTS Animation and Printing

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to