Jump to content

QtPDF Build Instructions

From Qt Wiki
Revision as of 14:07, 18 August 2026 by Shawnrutledge (talk | contribs)

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

In case of any issues, please open a bug report for the PDF component at https://bugreports.qt.io/.

Building with an existing Qt 6

  • Install html5lib:
$ apt install python3-html5lib

or

$ pip3 install html5lib
  • sources for the Qt PDF 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 Qt PDF. Configure a shadow build:
$ mkdir build
$ cd build
$ qt-configure-module ../qtwebengine -- -DFEATURE_qtwebengine_build=OFF
  • build Qt PDF
$ cmake --build . --parallel

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

Building Qt and Qt PDF 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 Qt PDF from there than to fix the build in the other repository.