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 (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