How to Open pdf in QtWebview or QML in general ?
-
Hey how can i open pdf in Qtwebview ?
I have a url which has pdf for ex this url : http://www.tutorialspoint.com/java/java_tutorial.pdf
Qtwebview does not open that url .
IS there any other way to open pdf in QML ?
-
Either get https://github.com/qt-labs/qtpdf
or https://poppler.freedesktop.org/ (there´s a qt5 interface)
both can render toQImage
-
For poppler, most major linux dists are providing devel packages so you can
#include <poppler-qt5.h>
and addLIBS += -lpoppler-qt5
to your .pro file. If precompiled poppler (e.g. Windows) is not available, you have to build it from source.For qtpdf, build qpdf.pro (qmake, make, make install) , add
QT += pdf
and#include <QPdfDocument>
in your source.Take a look at the build instruction and examples of each project.