У меня есть такая функция печати:
- (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];
}
Это печатает представление предварительного просмотра страницы под названием sheet , которое является NSBox
. Это отлично работает.
Иногда у меня есть больше информации, которая может поместиться на странице, и поэтому у меня есть кнопки «Следующая страница», которые заполняют sheet представлением Page2, Page3 и т. Д. Путем перезагрузки sheet с соответствующими данными. Это отлично работает.
Теперь, если я хочу распечатать информацию, которая уместится на 2 или 3 страницах, а не на 1, я хочу, чтобы можно было вручную * NSPrintInfo
или NSPrintOperation
добавить дополнительные страницы до того, как они будут напечатаны, вместо разбивки на страницы , Что-то вроде:
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];
Есть какие-нибудь решения? Заранее спасибо.