mardi 5 mai 2015

Need to Print a Custom Header using obj-c

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?

Aucun commentaire:

Enregistrer un commentaire