Printing Webview Headers and Footers

I searched on the Internet but could not find a solution for my problem:

I want to print headers and footers when printing my WebView.

[printInfoDict setObject:[NSNumber numberWithBool:YES] forKey:NSPrintHeaderAndFooter]; NSView* viewToPrint = [[[self.webViewController.webView mainFrame] frameView] documentView]; NSPrintOperation* printOp = [NSPrintOperation printOperationWithView:viewToPrint printInfo:printInfo]; 

Footers / headers are not currently printed. In addition, I want to add my own Footer / Header (this is possible by overriding the NSView -(void) pageHeader and -(void) pageFooter ).

I have no idea how to achieve this. Thank you for your help.

+4
source share
1 answer

Check the WebUIDelegate.h file, -webViewHeaderHeight: and -webView: drawHeaderInRect :. There are equivalent methods for the footer.

WebView dividers allow LOT settings, almost bringing you to options.

Also remember that WebKit is open source. Downloading the source and searching inside it can also give you answers if you cannot find them elsewhere. I would recommend this as a last resort. Start with delegates!

+4
source

All Articles