I have a printing function like so:
- (void)sendToPrinter:(int)code {
NSPrintInfo *printInfo;
NSPrintInfo *sharedInfo;
NSPrintOperation *printOp;
NSMutableDictionary *printInfoDict;
NSMutableDictionary *sharedDict;
sharedInfo = [NSPrintInfo sharedPrintInfo];
sharedDict = [sharedInfo dictionary];
printInfoDict = [NSMutableDictionary dictionaryWithDictionary:
sharedDict];
[printInfoDict setObject:NSPrintSpoolJob
forKey:NSPrintJobDisposition];
printInfo = [[NSPrintInfo alloc] initWithDictionary: printInfoDict];
[printInfo setHorizontalPagination: NSAutoPagination];
[printInfo setVerticalPagination: NSAutoPagination];
[printInfo setVerticallyCentered:NO];
[printInfo setLeftMargin:10];
[printInfo setRightMargin:10];
[printInfo setTopMargin:10];
[printInfo setBottomMargin:10];
[printInfo setScalingFactor:1.1];
printOp = [NSPrintOperation printOperationWithView:sheet
printInfo:printInfo];
[printOp setShowsPrintPanel:YES];
[printOp runOperation];
}
This prints a representation of a page preview called sheet, which is an NSBox
. This works fine.
Sometimes I have more information that can fit on a page and so I have 'next page' buttons that fill sheet with a representation of Page2, Page3, etc. by reloading sheet with the relevant data. This works fine.
Now, if I want to print out information that will fit on 2 or 3 pages rather than 1, I want to be able to feed NSPrintInfo
or NSPrintOperation
additional pages manually before it goes to print, rather than pagination. Something like:
printOp = [NSPrintOperation printOperationWithView:sheet
printInfo:printInfo];
[self nextPage];
printOp = [NSPrintOperation printOperationWithView:sheet
printInfo:printInfo];
[self nextPage];
printOp = [NSPrintOperation printOperationWithView:sheet
printInfo:printInfo];
// run this in loop until all the pages are accounted for
[printOp setShowsPrintPanel:YES];
[printOp runOperation];
Any solutions? Thanks in advance.