PDA

View Full Version : Display pdf file in QTextEdit



toutarrive
7th August 2009, 13:32
Hello,

I want to display a pdf file in an QText Edit. I believe i have to use Qprinter

QString file= "Path/file/my.pdf
QPrinter printer;

printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOutputFileName(file);
docTextEdit->print(&printer);

But QtextEdit shows nothing...
Any help?

Thanks in advance

Olivier

yogeshgokul
7th August 2009, 14:09
First read the Qt Docs for QPrinter.
You are 200% wrong in what you want and how you are trying to do. ;);)

toutarrive
7th August 2009, 14:25
Yes i've just noticed.

the idea is to generate a print of the pdf file and to redirect it to QTextedit.

Is that possible?

yogeshgokul
7th August 2009, 14:40
the idea is to generate a print of the pdf file
That is fine, you can do it using QPrinter.


and to redirect it to QTextedit.
What do you mean by redirect?

toutarrive
7th August 2009, 14:47
The doc says:

The QPrinter class is a paint device that paints on a printer.

This device represents a series of pages of printed output, and is used in almost exactly the same way as other paint devices such as QWidget and QPixmap.

Instead of painting on a printer i would like to paint on QTextEdit (a QWidget).

yogeshgokul
7th August 2009, 15:08
Instead of painting on a printer i would like to paint on QTextEdit (a QWidget).
I am not sure about this. Because I think, Qt docs doesn't says that you can read a PDF file. The only thing Qt deals with is, printing in PDF format. So, Qt can write PDF but cannot read it.
On Windows you can use ActiveQt to embed the Acrobat ActiveX Control.

faldzip
7th August 2009, 15:21
for displaying PDF you can use Poppler library as described here: http://doc.trolltech.com/qq/qq27-poppler.html.
It is available as source and packages (on ubuntu you can install it with apt-get install), and cross-platform, but compiling it for windows is a nightmare :(

toutarrive
7th August 2009, 16:22
OK thanks for your answers guys! i do appreciate it.

I tried to compile poppler on vista.. i gave up.

Lykurg
7th August 2009, 17:51
I tried to compile poppler on vista.. i gave up.
Yes, that's tricky! But search for a project which uses poppler and steal the dll form that project...