Print report using WebView
Print report using WebView
- Subject: Print report using WebView
- From: "Vitaly Ovchinnikov" <email@hidden>
- Date: Thu, 2 Oct 2008 00:15:54 +0400
Hello,
I need to print reports with various styles. The only reasonable way
for me is to generate HTML and use WebView for rendering and print.
I create WebView, generate HTML string and pass it to WebView. Then I
create NSPrintOperation on it. All works fine, but it prints one empty
page at the end. It seems that I missed something...
The code:
- (NSPrintOperation *) printOperationWithSettings: (NSDictionary *)
settings error: (NSError **) err
{
NSPrintInfo *pi = [NSPrintInfo sharedPrintInfo];
NSSize szPage = [pi paperSize];
NSRect rcFrame = NSMakeRect(0, 0, szPage.width, szPage.height);
WebView *w = [[[WebView alloc] initWithFrame:rcFrame frameName:@""
groupName:@""] autorelease];
[[w mainFrame] loadHTMLString:strMyReport baseUrl:@:""];
// code that waits for loading skipped
return [NSPrintOperation printOperationWithView:w printInfo:pi];
}
One more potential problem: it seems that it is not a good idea to
create printoperation on WebView itself. But when I try to access it's
document view (using -mainFrame, -documentFrame- etc) it crashed.
Does anybody have a working piece of code?
Thank you.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden