Unsolved QML show PDF file
-
@eyllanesc: Ok. Thank you for the example. I compiled and installed the plugin. But why is it "import org.docviewer.poppler 1.0"?
This gives me the error "module "org.docviewer.poppler" is not installed".
Maybe I should mention that I am cross compiling on Ubuntu my application for raspberry pi. -
@Melle_87 said in QML show PDF file:
But why is it "import org.docviewer.poppler 1.0"?
Well, because you need to import Poppler stuff if you want to use it.
"I compiled and installed the plugin" - did you cross-compiled it for your device or host machine? -
@jsulm: At the moment I am a little bit confused.
I compiled and installed it directly on my raspberry. -
@Melle_87 said in QML show PDF file:
I compiled and installed it directly on my raspberry
It needs to be in your sysroot. Did you resync your sysroot after installing on RPi?
-
@jsulm: Ah okay. Of course, I have to resync my sysroot. I resynced the folders /usr/local/include, /usr/local/lib and /usr/lib/arm-linux-gnueabihf/qt5 from raspberry to host.
Then I added this to my qmldir file:
module org.docviewer.poppler PDFView 1.0 PDFView.qml plugin popplerPlugin typeinfo popplerPlugin.qmltypes
But now I get the error message:
plugin "popplerPlugin" not found
What is the reason for this error message?
-
@Melle_87 I'm not a QML expert.
Not sure you have to change qmldir.
When you installed Poppler on RPi - where was it installed? -
@jsulm: I think on raspi it was installed in /usr/lib/arm-linux-gnueabihf/qt5/qml/org/docviewer/poppler. Because in this folder I find popplerPlugin.qmltypes.
-
@Melle_87 said in QML show PDF file:
think on raspi it was installed in /usr/lib/arm-linux-gnueabihf/qt5/qml/org/docviewer/poppler. Because in this folder I find popplerPlugin.qmltypes.
You can follow the import process when setting environment variable
QML_IMPORT_TRACE
.
As written in documentation, QML import path is:Additional import paths can be added through QQmlEngine::addImportPath() or the QML2_IMPORT_PATH environment variable. When running the qmlscene tool, you can also use the -I option to add an import path.
Take a look here ==> https://doc.qt.io/qt-5/qtqml-syntax-imports.html#qml-import-path
-
@Melle_87 Does it work if you do not change qmldir?
-
@KroMignon: Thank you. So it is possible to set this QML2_IMPORT_PATH variable in Qt Creator in the Run Environment? I set this variable to /usr/lib/arm-linux-gnueabihf/qt5/qml/org/docviewer/poppler. Is this correct?
-
@jsulm: If I don't change the qmldir file I get "module "org.docviewer.poppler" is not installed".
-
@Melle_87 said in QML show PDF file:
So it is possible to set this QML2_IMPORT_PATH variable in Qt Creator in the Run Environment?
Yes, I think so. But I would suggest you first to try out
QML_IMPORT_TRACE
to be aware why your plugin in not loaded.
Perhaps there are missing libs?
==> https://doc.qt.io/qt-5/qtquick-debugging.html#debugging-module-imports -
@KroMignon: Thank for alle the tipps. I leave my qmldir file as it is and only set QML2_IMPORT_PATH = /usr/lib/arm-linux-gnueabihf/qt5/qml. Now the everything seems to be loaded correctly.
But now I have a new problem. On start up I get a "Segmentation fault".
I think the problem is that I compiled poppler with qmake of Qt 5.11.3. But actually I use Qt5.12.4. I have both Qt versions on the raspi. How can I explicitly use the qmake of Qt5.12.4 for compiling poppler? -
@Melle_87 said in QML show PDF file:
How can I explicitly use the qmake of Qt5.12.4 for compiling poppler?
By calling the qmake from the Qt version you want to use (use absolute path to qmake).
-
@jsulm: Hmmm... Okay. Unfortunately in Qt5.12.4 folder there is no qmake available ...
-
@Melle_87 said in QML show PDF file:
Qt5.12.4 folder there is no qmake available
Then this is not a valid Qt installation.
How did you install it? -
@jsulm: It was not me who installed the Qt version ... So I have to ask. But is there a way to get the qmake of this version?
Or maybe it would be easier to cross compile Poppler? -
@Melle_87 said in QML show PDF file:
Or maybe it would be easier to cross compile Poppler?
Cross compiling is more complex than building directly on the device. But you need to make sure you use same Qt version on device and host machine if you want to cross compile your app later.
"But is there a way to get the qmake of this version?" - sure. If it was installed using apt then install the qt dev packages, which exactly depends on the distribution.
-
Another quick and easy way to render a pdf with QML is to use a WebView together with pdfjs lib :
WebView{ url:"file:///%path_to_pdfjs%/web/viewer.html?file=file://%PathToFile%.pdf" }
You can find a working example in Swag projet : https://github.com/a-team-fr/swag/blob/master/Swag/PDFElement.qml
-
@Charby: Okay, thank you. I will have a look at it.