Reputation: 9
I'm having an issue printing from my desktop application on macosx. I built a view in my IB file that I use for printing. Then a call my action that throu
printOp = [NSPrintOperation printOperationWithView:self.myPrintView printInfo: printInfo];
print the NSView
.
Just before that I use a simple function
[self displayPrintingData];
to build up my data on the view
-(void)displayPrintingData {
//header
self.headerData.alignment = NSTextAlignmentCenter;
self.headerData.string = @"bla bla bla";
self.footerData.string = @"ribla ribla ribla";
[self.printTableView reloadData];
}
My problem is that I need to print as many line as I inserted (using different nsview and different nstableview). How can I reach the goal to shorten or lengthen my NSTableView? Is this the best way to print dynamically multiple lines?
thanks in advance for your suggestions!!!!!
cheers
Upvotes: 0
Views: 796
Reputation: 15633
Example:
NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:self.printTableView];
NSPrintInfo *printInfo = printOperation.printInfo;
[printInfo.dictionary setObject:@YES forKey:NSPrintHeaderAndFooter];
[printOperation runOperation];
Note: the view is the tableview. This is a subclass of NSTableView with methods:
- (NSAttributedString *)pageHeader
{
return [[NSAttributedString alloc] initWithString:@"bla bla bla"];
}
- (NSAttributedString *)pageFooter
{
return [[NSAttributedString alloc] initWithString:@"ribla ribla ribla"];
}
Upvotes: 1