I am creating an NSView and it prints fine with this piece of code :
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
[printInfo setHorizontalPagination:NSFitPagination];
[printInfo setHorizontallyCentered:YES];
[printInfo setVerticallyCentered:YES];
NSPrintOperation *operation = [NSPrintOperation printOperationWithView:printView printInfo:printInfo];
NSPrintPanel *printerPanel = operation.printPanel;
printerPanel.options = NSPrintPanelShowsPaperSize | NSPrintPanelShowsPageRange | NSPrintPanelShowsOrientation | NSPrintPanelShowsPageSetupAccessory | NSPrintPanelShowsPreview;
[operation runOperationModalForWindow:window delegate:nil
didRunSelector:nil contextInfo:nil];
I also have this code in applicationDidFinishLaunching
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:@YES forKey:NSPrintHeaderAndFooter];
Now if i try to override these methods
- (void)drawPageBorderWithSize:(NSSize)pageSize
- (NSAttributedString *)pageHeader
They are not even getting called. Anybody know why?
In order for you to over-ride a NSView's methods you first have to sub-class the file and then place your overridden methods inside of the new custom class. Instantiate and use your subclass instead of NSView and remember to make the super calls in the overridden methods so everything works as expected. Shouldn't be too much else to it, if you've already got a sub-class you can post it and I can take a look.