Jump to content

QtPDF Build Instructions

From Qt Wiki
Revision as of 14:03, 18 August 2026 by Shawnrutledge (talk | contribs) (add my usual configure line for Qt and QtPDF together)

QtPdf binaries are available from the Qt installer; but here's how to build it yourself.

Building with an existing Qt 6

  • Install html5lib:
$ apt install python3-html5lib

or

$ pip3 install html5lib
  • sources for QtPdf module are hosted within QtWebEngine repository. Let's clone and initialize the git repository:
$ 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 QtPdf. Configure a shadow build:
$ mkdir build
$ cd build
$ qt-configure-module ../qtwebengine -- -DFEATURE_qtwebengine_build=OFF
  • build QtPdf
$ cmake --build . --parallel

QtPdf comes with Qml and Widget APIs examples, found in examples/pdf and examples/pdfwidgets.

In case of any issues please open bug report for PDF component in https://bugreports.qt.io/.

Building Qt and QtPDF together

  • 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 QtPDF from there than to fix the build in the other repository.