Jump to content

QtPDF Build Instructions: Difference between revisions

From Qt Wiki
Shawnrutledge (talk | contribs)
Shawnrutledge (talk | contribs)
No edit summary
Line 1: Line 1:
[https://doc.qt.io/qt-6/qtpdf-index.html QtPdf] 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; 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/<nowiki/>.


==Building with an existing Qt 6==
==Building with an existing Qt 6==
Line 11: Line 13:
  $ pip3 install html5lib
  $ pip3 install html5lib


*sources for QtPdf module are hosted within QtWebEngine repository. Let's clone and initialize the git repository:
*sources for the Qt PDF module are hosted within QtWebEngine repository. Let's clone and initialize the git repository:


<pre>
<pre>
Line 20: Line 22:
</pre>
</pre>


*fortunately build of QtWebEngine itself is not necessary for QtPdf. Configure a shadow build:
*fortunately build of QtWebEngine itself is not necessary for Qt PDF. Configure a shadow build:


<pre>
<pre>
Line 28: Line 30:
</pre>
</pre>


*build QtPdf
*build Qt PDF


<pre>
<pre>
Line 34: Line 36:
</pre>
</pre>


QtPdf comes with Qml and Widget APIs examples, found in examples/pdf and examples/pdfwidgets.
Qt PDF 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/<nowiki/>.'''


==Building Qt and QtPDF together==
==Building Qt and Qt PDF together==


*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]]
Line 52: Line 52:
==Historical repository==
==Historical repository==


The older version in the [https://code.qt.io/cgit/qt-labs/qtpdf.git/ Qt Labs QtPDF repository] still exists, but development now continues in the [https://code.qt.io/cgit/qt/qtwebengine.git/tree/src/pdf 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.
The older version in the [https://code.qt.io/cgit/qt-labs/qtpdf.git/ Qt Labs QtPDF repository] still exists, but development now continues in the [https://code.qt.io/cgit/qt/qtwebengine.git/tree/src/pdf 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.

Revision as of 14:07, 18 August 2026

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.