PDA

View Full Version : how to generate a PDF file with qt?



ghnie
25th March 2010, 01:24
In Linux OS, for example CentOS, I want to generate a PDF file to show my data.
I did this by HTML, but the font in PDF file is bold and i can't set it to normal (not bold), and the words in the file look like not very clear.

Is there another way to generate PDF file in Qt?

btw: I hope the way is free, that is to say without pay.

Any help will be appreciated.

toutarrive
25th March 2010, 07:23
You have to use the QPrinter class to generate a pdf:


Qprinter printer;
printer.setOutputFileName(filename);
printer.setOutputFormat(QPrinter::PdfFormat);


Have a look at void TextEdit::filePrintPdf() in http://doc.trolltech.com/4.2/demos-textedit-textedit-cpp.html .

Concerning viewing of a pdf doc, Qt is not shipped with a viewer, so you might have to use a third parties library or embed adobe ActiveX control in your app.