NSPrintOperation Fails to Auto-Paginate?
NSPrintOperation Fails to Auto-Paginate?
- Subject: NSPrintOperation Fails to Auto-Paginate?
- From: DairyKnight <email@hidden>
- Date: Mon, 3 May 2010 10:57:01 +0800
Hi all,
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:
MyCustomView *curView = [curDocument textView];
NSPrintInfo *sharedInfo = [NSPrintInfo sharedPrintInfo];
NSMutableDictionary *sharedDict = [sharedInfo dictionary];
NSMutableDictionary *prtInfoDict = [[NSMutableDictionary
alloc]initWithDictionary:sharedDict];
[prtInfoDict setObject:NSPrintSaveJob forKey:NSPrintJobDisposition];
// Set up NSPrintInfo
NSPrintInfo *prtInfo = [[NSPrintInfo alloc] initWithDictionary:prtInfoDict];
[prtInfo setTopMargin:1];
[prtInfo setBottomMargin:1];
[prtInfo setLeftMargin:1];
[prtInfo setRightMargin:1];
[prtInfo setPaperSize:NSMakeSize(1144 / 150 * 72, 786 / 150 * 72)];
[prtInfo setVerticalPagination:NSAutoPagination];
[prtInfo setHorizontalPagination:NSAutoPagination];
[prtInfo setVerticallyCentered:NO];
// Initiate the Print Job
NSPrintOperation *printOp = [NSPrintOperation PDFOperationWithView:curView
insideRect:[curView bounds] toPath:@"/Users/peidaqi/Desktop/test.pdf"
printInfo:prtInfo];
[printOp setShowPanels:NO];
[printOp runOperation];
Thanks.
Cheers,
DairyKnight
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden