Skip navigation.
 
mlPrinting with a WebView
FROM : Frédéric Testuz
DATE : Sat Oct 16 18:11:07 2004

Hello,

I have a program to edit some data. Now I want to print the data in
different forms and I have think of the WebView. Create the html code
is not difficult and you can customize the style easily with css. (And
I have never draw things, so using a view who is doing the job is
easier :-)

It's the first time I print something in a cocoa program. I have some
difficulties with the dimensions of the view.
I set the width with infos from the document printInfo, but for the
height I can't find a way to obtain the bound height of the view which
draw the html code. Here is my code:

- (void)printShowingPrintPanel:(BOOL)flag
{
   WebView *myView;
   NSPrintInfo *pi=[self printInfo];
   
   myView =[[WebView alloc] initWithFrame:NSMakeRect(0, 0, [pi
paperSize].width-[pi leftMargin]-[pi rightMargin], 500)];

   [[myView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:@"file:///Users/myuser/Sites/index.html"]]];
   [myView setFrameSize:NSMakeSize(aWidth, aHeight)]; // <-- here,
aHeight=???
   
   NSPrintOperation *po=[NSPrintOperation printOperationWithView: myView];
   [po setShowPanels:flag];

   [po runOperation];
   
   [myView release];
}

If anyone has an idea ? Thanks.

--
Frédéric Testuz
<mailto:<email_removed>>

Related mailsAuthorDate
mlPrinting with a WebView Frédéric Testuz Oct 16, 18:11
mlRe: Printing with a WebView Frédéric Testuz Oct 18, 21:15
mlRe: Printing with a WebView Steven Kramer Oct 19, 13:58