Jump to content

QtPDF Build Instructions: Difference between revisions

From Qt Wiki
Shawnrutledge (talk | contribs)
remove broken link to marketplace
Shawnrutledge (talk | contribs)
remove Qt 5 info; genericize for whatever Qt 6 version
Line 1: Line 1:
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 QtPdf] binaries are available from the Qt installer; but here's how to build it yourself.


==Building the 5.15 version==
==Building with an existing Qt 6==


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


<pre>
apt install python3-html5lib
$ git clone https://code.qt.io/qt/qtwebengine.git
$ cd qtwebengine
$ git checkout 5.15
$ git submodule update --init --recursive
$ cd ..
</pre>


*fortunately build of QtWebEngine itself is not necessary for QtPdf build; therefore let's configure shadow build with:
or


<pre>
  pip3 install html5lib
$ mkdir build
$ cd build
$ qmake ../qtwebengine -- -no-build-qtwebengine-core
</pre>
 
*you should see configuration summary after previous step:
 
<pre>
Configure summary:
 
Qt WebEngine Build Tools:
  Use System Ninja ....................... yes
  Use System Gn .......................... no
  Jumbo Build Merge Limit ................ 8
  Developer build ........................ no
  QtWebEngine required system libraries:
    fontconfig ........................... yes
    dbus ................................. yes
    nss .................................. yes
    khr .................................. yes
    glibc ................................ yes
  QtWebEngine required system libraries for qpa-xcb:
    x11 .................................. yes
    libdrm ............................... yes
    xcomposite ........................... yes
    xcursor .............................. yes
    xi ................................... yes
    xtst ................................. yes
  Optional system libraries used:
    re2 .................................. yes
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . yes
    opus ................................. yes
    ffmpeg ............................... no
    libvpx ............................... yes
    snappy ............................... yes
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. yes
    libevent ............................. yes
    jsoncpp .............................. yes
    protobuf ............................. yes
    libxml2 and libxslt .................. yes
    lcms2 ................................ yes
    png .................................. yes
    JPEG ................................. yes
    harfbuzz ............................. yes
    freetype ............................. yes
    xkbcommon ............................ 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
Qt PDF Widgets:
  Support Qt PDF Widgets ................. yes
 
Note: QtWebEngine build is disabled by user.
 
Note: The following modules are not being compiled in this configuration:
    webenginecore
    webengine
    webenginewidgets
 
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into '/usr'.
</pre>
 
*QtPdf build will use '''gn''' and '''ninja''' to build Pdfium which is required for the QtPdf module. Let's perform the build:
 
<pre>
$ NINJAJOBS=-j4 make -j4 && make install
</pre>
 
==Building the 6.3 version==


*sources for QtPdf module are hosted within QtWebEngine repository. Let's clone and initialize the git repository:
*sources for QtPdf module are hosted within QtWebEngine repository. Let's clone and initialize the git repository:
Line 100: Line 16:
$ git clone https://code.qt.io/qt/qtwebengine.git
$ git clone https://code.qt.io/qt/qtwebengine.git
$ cd qtwebengine
$ cd qtwebengine
$ git checkout 6.3
$ git checkout 6.12 (or whatever version)
$ git submodule update --init --recursive
$ git submodule update --init --recursive
$ cd ..
$ cd ..
</pre>
</pre>


* Install html5lib:
*fortunately build of QtWebEngine itself is not necessary for QtPdf. Configure a shadow build:
 
pip3 install html5lib
 
*configure shadow build with:


<pre>
<pre>
Line 117: Line 29:
</pre>
</pre>


*build the pdf
*build QtPdf


<pre>
<pre>
Line 123: Line 35:
</pre>
</pre>


Since QtPdf comes with Qml and Widget APIs examples using those can be found in examples/pdf and examples/pdfwidgets.
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/<nowiki/>.'''
'''In case of any issues please open bug report for PDF component in https://bugreports.qt.io/<nowiki/>.'''

Revision as of 13:52, 18 August 2026

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
$ cd ..
  • 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/.

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.