View Full Version : Is Qt right for this job?

7th October 2008, 13:14
I want to write a program to convert html files to pdfs that supports the linux and windows platforms. I may not have time to implement an html parser so I was wondering would it be possible to use a Qt widget to load the html file and then have Qt print it to pdf. I was thinking of QWebkit but maybe there are other options thanks.

7th October 2008, 13:23
you can load html using QTextEdit (http://doc.trolltech.com/4.4/qtextedit.html), QTextBrowser (http://doc.trolltech.com/4.4/qtextbrowser.html), QWebView (http://doc.trolltech.com/4.4/qwebview.html).

7th October 2008, 14:57
i don't know if using Qt you can print anything to PDF. But you can try using PDF convertors like Ghostscript etc...which are also cross-platform.

So, use Qt's web widgets to display the HTML page and use Ghostscript etc... in the background to convert it to PDF.

7th October 2008, 15:59
It's easy to print to a PDF file with Qt. I've used it with several components but not with webkit. But from what I look at the docs, it has a print function so you're good to go.
Just create a printer object and set it's format to PDF. Here's a code sample:

QWebView *webkit = new QWebView();
QPrinter printer(QPrinter::HighResolution);



That should get you going.

Qt for multi-platform is very good. And for this task you need, it gets the job done easy.

Good luck!

8th October 2008, 18:51
Check out cutycapt (http://cutycapt.sourceforge.net/).