You could use wkhtmltopdf (or study its sources): 
http://code.google.com/p/wkhtmltopdf/

Helmut Mülner
________________________________________
Von: interest-bounces+helmut.muelner=joanneum...@qt-project.org 
[interest-bounces+helmut.muelner=joanneum...@qt-project.org] im Auftrag von 
d3fault [d3faultdot...@gmail.com]
Gesendet: Donnerstag, 28. März 2013 20:27
An: interest
Betreff: Re: [Interest] Combine PDF files into a single PDF File

On Thu, Mar 28, 2013 at 11:06 AM, Michael Jackson
<imikejack...@gmail.com> wrote:
> I would like to take a bunch of PDF files and combine them into a single PDF 
> file. Would this be possible with Qt? I see where I can print an HTML file to 
> a PDF but I have 60 html files that I want to convert into a single PDF file.
>
> Thanks for any pointers
> ---
> Mike Jackson
>

Hi Mike, Qt 5 includes QPdfWriter [0] that makes generating multi-page
PDFs a breeze. I haven't used it myself, but the documentation makes
it look easy. I'm surprised there's no corresponding QPdfReader
(perhaps it's still a WIP?), but since you're using HTML as input you
can simply use QtWebKit to load the files and then render them to a
QPaintDevice (image, pdf, etc). There's an example in the docs showing
you how to do just that [1], but you're going to have to glue the
pieces together yourself to iterate over your 60 HTML files, rendering
and calling QPdfWriter::newPage() where appropriate.


d3fault

[0] - http://qt-project.org/doc/qt-5.0/qtgui/qpdfwriter.html
[1] - 
http://qt-project.org/doc/qt-5.0/qtwebkitexamples/webkitwidgets-framecapture.html
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to