Alternative to poppler for converting a pdf document to QImage
-
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 -
Did you check:
-
Did you check:
@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?
- https://doc.qt.io/qt-6/qtpdf-module.html - especially https://doc.qt.io/qt-6/qpdfdocument.html#render
-
@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?
@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 - https://doc.qt.io/qt-6/qtpdf-module.html - especially https://doc.qt.io/qt-6/qpdfdocument.html#render
-
It seems that the QPdfDocument is not available for Qt5 (that I am using for the development). The Qt documentation seems wrong
-
QPdfDocument is available in Qt5 since Qt5.10 as you can see in the documentation: https://doc.qt.io/qt-5/qpdfdocument.html
-
I tried to include the QPdfDocument header file and it's not recognized
-
I tried to include the QPdfDocument header file and it's not recognized
-
I tried to include the QPdfDocument header file and it's not recognized
@franco-amato then you did not install the QtPdf module or it's development package.
-
I tried to include the QPdfDocument header file and it's not recognized
@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?
Orfind_package(Qt5 COMPONENTS Pdf REQUIRED) target_link_libraries(mytarget Qt5::Pdf)
to your CMakeLists.txt file?
-
It seems that my Qt installation has some limitation.
Below is what I got after adding "Pdf" to the find_packageC:\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)
-
Then you did not install QtPdf module as others pointed out. Install it first.
-
It's not available for Qt5
-
It's not available for Qt5
@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? -
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 -
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@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.