Printing a Webview
Printing a Webview
- Subject: Printing a Webview
- From: Greg Hulands <email@hidden>
- Date: Fri, 6 Feb 2004 16:33:13 +1000
Hi,
I am making a simple web cafe solution that allows the client machine
to print the current web page in a Web View. Because we don't want the
person to be able to get access to the standard print panel, because
they can just leave without paying for it, I am trying to get the web
view to return itself as a formatted pdf.
But when I view the pdf, it only shows what was seen on the screen, not
the whole page.
- (void)print:(id)sender
{
NSMutableData *data = [NSMutableData data];
NSPrintInfo *info = [NSPrintInfo sharedPrintInfo];
[info setOrientation:NSPortraitOrientation];
[info setPaperSize:[NSPrintInfo sizeForPaperName:@"A4"]];
NSPrintOperation *op = [NSPrintOperation PDFOperationWithView:webview
insideRect:[webview frame]
to
Data:data
printInfo:info];
if ([op runOperation])
{
[cafeController client:self printPDF:data];
}
else
{
NSRunAlertPanel(@"Error Printing", @"There was an error printing the
page.", @"OK", nil, nil);
}
}
I have tried the webview's bounds as well, but no luck. I have tried
getting the webview to return the pdf inside a rect, but no luck. Is it
at all possible to achieve this without displaying the print panel?
Any help is greatly appreciated,
Regards,
Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.