我正在创建一个 NSView 并使用这段代码打印得很好:
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];
我在 applicationDidFinishLaunching 中也有这段代码
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:@YES forKey:NSPrintHeaderAndFooter];
现在,如果我尝试覆盖这些方法
- (void)drawPageBorderWithSize:(NSSize)pageSize
- (NSAttributedString *)pageHeader
他们甚至没有被叫到。有人知道为什么吗?