[webkit-help] Printing a Webview

MT mt at theescapers.com
Sun Nov 8 03:27:55 PST 2009


Hi,

A seemingly simple question... How do I print a webview, fonts, colors  
and everything...

The code below is my current effort at it, the result is unstyled  
text, no div borders or anything like that.

How do I get a a print-out the same as it appears on screen?

Thanks a lot,

Moray




	WebPreferences* prefs = [_webview preferences];
	[prefs setShouldPrintBackgrounds:YES];
	
	//The below is another effort, same results
	//[[[[_webview mainFrame] frameView] documentView] print:sender];
	
	
	NSPrintInfo * pi = [[[NSPrintInfo alloc] initWithDictionary: 
[NSDictionary dictionary]] autorelease];
	
	NSPrintOperation *op = [NSPrintOperation printOperationWithView: 
[[[_webview mainFrame] frameView] documentView] printInfo:pi];
	[op setShowsPrintPanel:YES];
	[op runOperation];


More information about the webkit-help mailing list