Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Alternative to poppler for converting a pdf document to QImage
Forum Updated to NodeBB v4.3 + New Features

Alternative to poppler for converting a pdf document to QImage

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 1.1k Views 1 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.
  • franco.amatoF Offline
    franco.amatoF Offline
    franco.amato
    wrote on last edited by
    #1

    I tried to compile poppler for two days without success particularly I'm having trouble compiling the pixman and cairo dependencies, I can not fix the error I am getting during the compilation.
    Is there any alternative to poppler that I can use to convert a pdf document (single or multi page ) to a QImage? Or do you know of a precompiled poppler version that I can use with Qt5? I tried this but it's not working https://github.com/SergeyZaz/pdfViewer/tree/master/lib_dynamic

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      Did you check:

      • https://doc.qt.io/qt-6/qtpdf-module.html - especially https://doc.qt.io/qt-6/qpdfdocument.html#render
      • https://github.com/qpdf/qpdf

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

      franco.amatoF 1 Reply Last reply
      0
      • jsulmJ jsulm

        Did you check:

        • https://doc.qt.io/qt-6/qtpdf-module.html - especially https://doc.qt.io/qt-6/qpdfdocument.html#render
        • https://github.com/qpdf/qpdf
        franco.amatoF Offline
        franco.amatoF Offline
        franco.amato
        wrote on last edited by
        #3

        @jsulm said in Alternative to poppler for converting a pdf document to QImage:

        Did you check:

        • https://doc.qt.io/qt-6/qtpdf-module.html - especially https://doc.qt.io/qt-6/qpdfdocument.html#render
          Thank you.
          I need to specify the resolution of 500 dpi and I don't understand how with the qpdfdocument. Do you know how?
        C 1 Reply Last reply
        0
        • franco.amatoF franco.amato

          @jsulm said in Alternative to poppler for converting a pdf document to QImage:

          Did you check:

          • https://doc.qt.io/qt-6/qtpdf-module.html - especially https://doc.qt.io/qt-6/qpdfdocument.html#render
            Thank you.
            I need to specify the resolution of 500 dpi and I don't understand how with the qpdfdocument. Do you know how?
          C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          @franco-amato said in Alternative to poppler for converting a pdf document to QImage:

          I need to specify the resolution of 500 dpi and I don't understand how with the qpdfdocument. Do you know how?

          Does this work? Render the document page to a QImage of whatever pixel size corresponds to the desired (notional) physical size, set the notional X and Y pixels-per-metre on the image, and save the image. 500 DPI ~ 19685 PPM.
          QImage::setDotsPerMeterX and
          QImage::setDotsPerMeterY

          1 Reply Last reply
          2
          • franco.amatoF Offline
            franco.amatoF Offline
            franco.amato
            wrote on last edited by
            #5

            It seems that the QPdfDocument is not available for Qt5 (that I am using for the development). The Qt documentation seems wrong

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              QPdfDocument is available in Qt5 since Qt5.10 as you can see in the documentation: https://doc.qt.io/qt-5/qpdfdocument.html

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • franco.amatoF Offline
                franco.amatoF Offline
                franco.amato
                wrote on last edited by
                #7

                I tried to include the QPdfDocument header file and it's not recognized

                JoeCFDJ Christian EhrlicherC jsulmJ 3 Replies Last reply
                0
                • franco.amatoF franco.amato

                  I tried to include the QPdfDocument header file and it's not recognized

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by
                  #8

                  @franco-amato did you install pdf module? Which Qt version are you using?

                  1 Reply Last reply
                  0
                  • franco.amatoF franco.amato

                    I tried to include the QPdfDocument header file and it's not recognized

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @franco-amato then you did not install the QtPdf module or it's development package.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • franco.amatoF franco.amato

                      I tried to include the QPdfDocument header file and it's not recognized

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

                      @franco-amato said in Alternative to poppler for converting a pdf document to QImage:

                      I tried to include the QPdfDocument header file and it's not recognized

                      Did you add "QT += pdf" to your pro file?
                      Or

                      find_package(Qt5 COMPONENTS Pdf REQUIRED)
                      target_link_libraries(mytarget Qt5::Pdf)
                      

                      to your CMakeLists.txt file?

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

                      1 Reply Last reply
                      0
                      • franco.amatoF Offline
                        franco.amatoF Offline
                        franco.amato
                        wrote on last edited by
                        #11

                        It seems that my Qt installation has some limitation.
                        Below is what I got after adding "Pdf" to the find_package

                        C:\Users\Franco\Work\BioImp\Sources\CMakeLists.txt:51: error: Could not find a package configuration file provided by "Qt5Pdf" with any
                        of the following names:
                        
                          Qt5PdfConfig.cmake
                          qt5pdf-config.cmake
                        
                        Add the installation prefix of "Qt5Pdf" to CMAKE_PREFIX_PATH or set
                        "Qt5Pdf_DIR" to a directory containing one of the above files.  If "Qt5Pdf"
                        provides a separate development package or SDK, be sure it has been
                        installed.
                        
                        Call stack:
                          C:/Users/Franco/Work/BioImp/Sources/CMakeLists.txt:51 (find_package)
                          C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
                        
                        1 Reply Last reply
                        0
                        • jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Then you did not install QtPdf module as others pointed out. Install it first.

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

                          1 Reply Last reply
                          0
                          • franco.amatoF Offline
                            franco.amatoF Offline
                            franco.amato
                            wrote on last edited by
                            #13

                            It's not available for Qt5

                            jsulmJ 1 Reply Last reply
                            0
                            • franco.amatoF franco.amato

                              It's not available for Qt5

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

                              @franco-amato said in Alternative to poppler for converting a pdf document to QImage:

                              It's not available for Qt5

                              As was already pointed out by @Christian-Ehrlicher it is available since Qt 5.10.
                              What exact Qt version do you use?

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

                              1 Reply Last reply
                              0
                              • franco.amatoF Offline
                                franco.amatoF Offline
                                franco.amato
                                wrote on last edited by
                                #15

                                I am using Qt 5.15.2
                                Could you show exactly from where it can be downloaded? Using the maintenance tool, it's available only for Qt 6

                                C 1 Reply Last reply
                                0
                                • franco.amatoF franco.amato

                                  I am using Qt 5.15.2
                                  Could you show exactly from where it can be downloaded? Using the maintenance tool, it's available only for Qt 6

                                  C Offline
                                  C Offline
                                  ChrisW67
                                  wrote on last edited by
                                  #16

                                  @franco-amato Source-wise QPdfDocument is part of Qt Webengine. However, installing this module's binary from the installer does not deliver this class (at least on my Linux box). YMMV may vary on Windows.

                                  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