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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to