• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Print report using WebView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Print report using WebView
      • From: "Sherm Pendley" <email@hidden>
  • Prev by Date: Re: NSString's "mutableCopy" creating a leak?
  • Next by Date: Re: NSString's "mutableCopy" creating a leak?
  • Previous by thread: Re: -[NSScanner scanUpToString:stopString:NULL] - 10.3.9 Crash, due Xcode 3.1?
  • Next by thread: Re: Print report using WebView
  • Index(es):
    • Date
    • Thread