[Qt-interest] Qt + Native WebKit + Native Print on Mac
Ângelo Suzuki
tinsukesuzuki at gmail.com
Wed Sep 16 17:08:11 CEST 2009
Hello guys,
I'm developing one cross-platform application that displays web pages and
some of them are printable. Due to size constraints, I'm using the native
browser API on each platform.
On Windows, it was pretty much easy to embed one IE component and the
printing is done without need of further coding (win32 handles it).
On Mac, I'm using the native WebKit API to render web pages. After some
struggling, the navigation is ready (
http://doc.trolltech.com/qq/qq20-hiviews.html has some nice hints on how to
do it). Opening pop-ups was a pain in the ass and I needed to learn
Objective-C to handle it.
Now I'm down to the last desired feature: web page printing!
The Cocoa way of doing this is veery simple: you set one WebUIDelegate to
your WebView and overload the following function just like this:
- (void)webView:(WebView *)sender printFrameView:(WebFrameView *)frameView
{
NSPrintOperation *operation = [frameView printOperationWithPrintInfo:
[NSPrintInfo sharedPrintInfo]];
[operation runOperation];
}
On print request, it creates one print operation with the system default
preferences (sharedPrintInfo) and runs it. By doing so, it is shown to the
user one configuration dialog and, on completing the config, it SHOULD
print!
Yes.. it SHOULD because it doesn't does so, it get stuck at one tricky
dialog window with "processing page: 1" and a cancel button. This dialog
lasts foreeever, and trying to cancel the operation changes the text to
"canceling" and disables the button. I have to kill the application to close
it.
One curious issue to note is that, if I copy the system NSPrintInfo and fill
it with some information (print to pdf, save to some specific file path) and
set the NSPrintOperation to don't show configuration panels, the pdf file is
successfully generated!!! :oooo
Has anyone of you guys faced similar problem? Plz heeelp!
I think I can use Qt QPrint to print on Mac buut, I'd have to gather the web
page from the native WebView, and.. what if the page is presented with a
scroll bar on the WebView?
Can you help me??
Tnx in advance,
--
Ângelo Suzuki
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090916/f48c220a/attachment.html
More information about the Qt-interest-old
mailing list