Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML show PDF file
Forum Updated to NodeBB v4.3 + New Features

QML show PDF file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
28 Posts 6 Posters 6.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @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?

    M Offline
    M Offline
    Melle_87
    wrote on last edited by
    #9

    @jsulm: At the moment I am a little bit confused.
    I compiled and installed it directly on my raspberry.

    jsulmJ 1 Reply Last reply
    0
    • M Melle_87

      @jsulm: At the moment I am a little bit confused.
      I compiled and installed it directly on my raspberry.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #10

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @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?

        M Offline
        M Offline
        Melle_87
        wrote on last edited by
        #11

        @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?

        jsulmJ 1 Reply Last reply
        0
        • M Melle_87

          @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?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #12

          @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?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • jsulmJ jsulm

            @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?

            M Offline
            M Offline
            Melle_87
            wrote on last edited by
            #13

            @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.

            KroMignonK jsulmJ 2 Replies Last reply
            0
            • M Melle_87

              @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.

              KroMignonK Offline
              KroMignonK Offline
              KroMignon
              wrote on last edited by
              #14

              @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

              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

              M 1 Reply Last reply
              1
              • M Melle_87

                @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.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #15

                @Melle_87 Does it work if you do not change qmldir?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                M 1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @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

                  M Offline
                  M Offline
                  Melle_87
                  wrote on last edited by
                  #16

                  @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?

                  KroMignonK 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Melle_87 Does it work if you do not change qmldir?

                    M Offline
                    M Offline
                    Melle_87
                    wrote on last edited by
                    #17

                    @jsulm: If I don't change the qmldir file I get "module "org.docviewer.poppler" is not installed".

                    1 Reply Last reply
                    0
                    • M Melle_87

                      @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?

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by KroMignon
                      #18

                      @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

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      M 1 Reply Last reply
                      0
                      • KroMignonK KroMignon

                        @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

                        M Offline
                        M Offline
                        Melle_87
                        wrote on last edited by Melle_87
                        #19

                        @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?

                        jsulmJ 1 Reply Last reply
                        0
                        • M Melle_87

                          @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?

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #20

                          @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).

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          M 1 Reply Last reply
                          1
                          • jsulmJ jsulm

                            @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).

                            M Offline
                            M Offline
                            Melle_87
                            wrote on last edited by
                            #21

                            @jsulm: Hmmm... Okay. Unfortunately in Qt5.12.4 folder there is no qmake available ...

                            jsulmJ 1 Reply Last reply
                            0
                            • M Melle_87

                              @jsulm: Hmmm... Okay. Unfortunately in Qt5.12.4 folder there is no qmake available ...

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by jsulm
                              #22

                              @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?

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              M 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @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?

                                M Offline
                                M Offline
                                Melle_87
                                wrote on last edited by Melle_87
                                #23

                                @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?

                                jsulmJ 1 Reply Last reply
                                0
                                • M Melle_87

                                  @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?

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #24

                                  @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.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  M 1 Reply Last reply
                                  1
                                  • CharbyC Offline
                                    CharbyC Offline
                                    Charby
                                    wrote on last edited by
                                    #25

                                    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

                                    M 1 Reply Last reply
                                    1
                                    • CharbyC Charby

                                      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

                                      M Offline
                                      M Offline
                                      Melle_87
                                      wrote on last edited by
                                      #26

                                      @Charby: Okay, thank you. I will have a look at it.

                                      1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @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.

                                        M Offline
                                        M Offline
                                        Melle_87
                                        wrote on last edited by
                                        #27

                                        @jsulm: Ok. Now I am sure that I am using the same Qt libs on host an Raspi. Poppler was built with the same. But now I get a SEG FAULT on start up when I set the variable QML2_IMPORT_PATH = /usr/lib/arm-linux-gnueabihf/qt5/qml in run environment.
                                        What could be the reason for that error?

                                        jsulmJ 1 Reply Last reply
                                        0
                                        • M Melle_87

                                          @jsulm: Ok. Now I am sure that I am using the same Qt libs on host an Raspi. Poppler was built with the same. But now I get a SEG FAULT on start up when I set the variable QML2_IMPORT_PATH = /usr/lib/arm-linux-gnueabihf/qt5/qml in run environment.
                                          What could be the reason for that error?

                                          jsulmJ Offline
                                          jsulmJ Offline
                                          jsulm
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #28

                                          @Melle_87 said in QML show PDF file:

                                          What could be the reason for that error?

                                          Don't know. Run it through debugger.

                                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved