I've searched the web but didn't found a solution for my problem:
I want to print Headers and Footers when prin开发者_如何学Pythonting 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 currently not printed.
Furthermore I want to add my own Footer/Header (this is possible by overriding NSView's -(void) pageHeader
and -(void) pageFooter
).
I have no idea how to achieve this. Thanks for your help.
Check out the WebUIDelegate.h file, -webViewHeaderHeight: and -webView:drawHeaderInRect:. There are equivalent methods for the footer.
WebView delegates allow a LOT of customization, almost to the point of flooding you with options.
Also remember that WebKit is open source. Downloading the source and searching inside it can give you answers, as well, if you can't find them anywhere else. I'd recommend that as a last-ditch option. Start with the delegates!
精彩评论