QtPDF Build Instructions: Difference between revisions
mNo edit summary |
WindJunkie (talk | contribs) added details about using "qt-configure-module" |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
[https://doc.qt.io/qt-6/qtpdf-index.html Qt PDF] binaries are available from the Qt installer; but here's how to build it yourself. | [https://doc.qt.io/qt-6/qtpdf-index.html Qt PDF] binaries are available from the Qt installer under "Extensions"; but here's how to build it yourself. | ||
In case of any issues, please open a bug report for the | In case of any issues, please open a bug report for the [https://qt-project.atlassian.net/issues/?jql=project%20%3D%20%22QTBUG%22%20AND%20component%20%3D%20%22PDF%22 PDF component at Qt Bug Reports]. | ||
==Building with an existing Qt 6== | ==Building from git with an existing Qt 6== | ||
This step requires an existing Qt 6 installation. | |||
* Install html5lib: hopefully your system package manager provides a python3-html5lib package; alternatively: | |||
$ pip3 install html5lib | $ pip3 install html5lib | ||
* | * Sources for the Qt PDF module are hosted within QtWebEngine repository. Clone and initialize the git repository (currently about 7.1 GB): | ||
(Commercial Qt customers are advised to use their own access to the source code on git. See the page [[Getting Commercial Qt Sources]] for more details)<pre> | |||
<pre> | |||
$ git clone https://code.qt.io/qt/qtwebengine.git | $ git clone https://code.qt.io/qt/qtwebengine.git | ||
$ cd qtwebengine | $ cd qtwebengine | ||
| Line 22: | Line 19: | ||
</pre> | </pre> | ||
* | * Fortunately build of QtWebEngine itself is not necessary for Qt PDF. Qt PDF uses just PDFium as a part of Chromium inside the QtWebEngine. Configure a shadow build: | ||
<pre> | <pre> | ||
$ mkdir build | $ mkdir build | ||
$ cd build | $ cd build | ||
$ qt-configure-module ../qtwebengine -- -DQT_FEATURE_qtwebengine_build=OFF | $ <path to the "bin" folder in your Qt 6 installation>/qt-configure-module ../qtwebengine -- -DQT_FEATURE_qtwebengine_build=OFF | ||
</pre> | </pre> | ||
* | * Build Qt PDF | ||
<pre> | <pre> | ||
| Line 36: | Line 33: | ||
</pre> | </pre> | ||
Qt PDF | * Install Qt PDF | ||
<pre> | |||
$ cmake --install . | |||
</pre> | |||
This will install Qt PDF into the Qt 6 installation you specified and used above. | |||
Test the new build with one of the examples provided by Qt PDF. See folders examples/pdf and examples/pdfwidgets. | |||
==Building from source installed with the installer== | ==Building from source installed with the installer== | ||
| Line 48: | Line 53: | ||
$ mkdir build | $ mkdir build | ||
$ cd build | $ cd build | ||
$ qt-configure-module .. -- -DQT_FEATURE_qtwebengine_build=OFF | $ <path to the "bin" folder of this Qt>/qt-configure-module .. -- -DQT_FEATURE_qtwebengine_build=OFF | ||
... | ... | ||
-- Configuration summary has been written to /home/username/Qt/6.12.0/Src/qtwebengine/config.summary | -- Configuration summary has been written to /home/username/Qt/6.12.0/Src/qtwebengine/build/config.summary | ||
... | ... | ||
-- Configuring done (14.0s) | -- Configuring done (14.0s) | ||
| Line 122: | Line 127: | ||
==Building Qt and Qt PDF together== | ==Building Qt and Qt PDF together== | ||
When you build Qt you can include a build of Qt PDF. | |||
*get the qt5.git repository, submodules and dependencies as explained in [[Building Qt 6 from Git]] | *get the qt5.git repository, submodules and dependencies as explained in [[Building Qt 6 from Git]] | ||
Latest revision as of 14:05, 19 August 2026
Qt PDF binaries are available from the Qt installer under "Extensions"; but here's how to build it yourself.
In case of any issues, please open a bug report for the PDF component at Qt Bug Reports.
Building from git with an existing Qt 6
This step requires an existing Qt 6 installation.
- Install html5lib: hopefully your system package manager provides a python3-html5lib package; alternatively:
$ pip3 install html5lib
- Sources for the Qt PDF module are hosted within QtWebEngine repository. Clone and initialize the git repository (currently about 7.1 GB):
(Commercial Qt customers are advised to use their own access to the source code on git. See the page Getting Commercial Qt Sources for more details)
$ git clone https://code.qt.io/qt/qtwebengine.git $ cd qtwebengine $ git checkout 6.12 (or whatever version) $ git submodule update --init --recursive
- Fortunately build of QtWebEngine itself is not necessary for Qt PDF. Qt PDF uses just PDFium as a part of Chromium inside the QtWebEngine. Configure a shadow build:
$ mkdir build $ cd build $ <path to the "bin" folder in your Qt 6 installation>/qt-configure-module ../qtwebengine -- -DQT_FEATURE_qtwebengine_build=OFF
- Build Qt PDF
$ cmake --build . --parallel
- Install Qt PDF
$ cmake --install .
This will install Qt PDF into the Qt 6 installation you specified and used above.
Test the new build with one of the examples provided by Qt PDF. See folders examples/pdf and examples/pdfwidgets.
Building from source installed with the installer
In Qt Maintenance Tool (AKA the installer) you can choose Extensions | Qt PDF | Qt 6.xx.x | Desktop to get the already-built version, and/or Extensions | Qt WebEngine | Qt 6.xx.x | Sources to get the source code for Qt WebEngine and Qt PDF together.
- configure a shadow build
$ cd ~/Qt/6.12.0/Src/qtwebengine (or whatever version)
$ mkdir build
$ cd build
$ <path to the "bin" folder of this Qt>/qt-configure-module .. -- -DQT_FEATURE_qtwebengine_build=OFF
...
-- Configuration summary has been written to /home/username/Qt/6.12.0/Src/qtwebengine/build/config.summary
...
-- Configuring done (14.0s)
-- Generating done (0.1s)
-- Build files have been written to: /home/username/Qt/6.12.0/Src/qtwebengine/build
$ cat config.summary
WebEngine Repository Build Options:
Build Gn ............................... yes
Jumbo Build ............................ yes
Developer build ........................ no
Build with rust ........................ no
Use precompiled headers for 3rdparty ... no
Build QtWebEngine Modules:
Build QtWebEngineCore ................ no
Build QtWebEngineWidgets ............. no
Build QtWebEngineQuick ............... no
Build QtPdf Modules:
Build QtPdfWidgets ................... yes
Build QtPdfQuick ..................... yes
Optional system libraries:
re2 .................................. no
icu .................................. no
libwebp, libwebpmux and libwebpdemux . yes
opus ................................. yes
ffmpeg ............................... no
libvpx ............................... no
snappy ............................... yes
glib ................................. yes
zlib ................................. yes
minizip .............................. yes
libxml2 and libxslt .................. yes
lcms2 ................................ yes
png .................................. no
tiff ................................. yes
jpeg ................................. no
libopenjpeg2 ......................... yes
harfbuzz ............................. no
freetype ............................. yes
libpci ............................... yes
libudev .............................. yes
openh264 ............................. yes
Qt PDF:
Support V8 ............................. no
Support XFA ............................ no
Support XFA-BMP ........................ no
Support XFA-GIF ........................ no
Support XFA-PNG ........................ no
Support XFA-TIFF ....................... no
Bitcode support ........................ no
Use static runtime ..................... no
SBOM:
Generate SBOM .......................... yes
Generate SPDX v2.3 ..................... yes
Generate SPDX v2.3 JSON ................ yes (skipped if dependencies are missing)
Verify SPDX v2.3 JSON ................ yes (skipped if dependencies are missing)
Generate CycloneDX v1.6 ................ no (skipped if dependencies are missing)
Verify CycloneDX v1.6 ................ yes (skipped if dependencies are missing)
SBOM Python interpreter ................ Not found
Generate source SPDX SBOM .............. no
Note:
Scanning for ide sources...
Please note configure can execute faster if called with:
'qt-configure-module path/to/src -- -DQT_SHOW_EXTRA_IDE_SOURCES=OFF'
WARNING: Qt WebEngine And Qt Pdf SBOM generation will be skipped due to missing dependencies. QT_INTERNAL_SBOM_PYTHON_EXECUTABLE is missing a valid path to a python interpreter
Required Python dependencies NOT found: spdx_tools.spdx.clitools.pyspdxtools
- build
$ cmake --build . --parallel
Building Qt and Qt PDF together
When you build Qt you can include a build of Qt PDF.
- get the qt5.git repository, submodules and dependencies as explained in Building Qt 6 from Git
- configure and build a shadow build:
$ cd .. $ mkdir qt6-dbg $ cd qt6-dbg $ ../qt6/configure -developer-build -debug -no-optimize-debug -nomake examples -make tests -no-pch -submodules qtbase,qtdeclarative,qtshadertools,qtwebengine -no-feature-qtwebengine-build $ ninja
Historical repository
The older version in the Qt Labs QtPDF repository still exists, but development now continues in the qtwebengine repository. This was prompted mainly by the upstream Chromium switch of build system from gyp to gn: it was some work to get qtwebengine building with that. Chromium (and thus Qt WebEngine) includes PDFium already; so it was easier to build Qt PDF from there than to fix the build in the other repository.