Xpdf
====

version 4.06
2025-nov-14

The Xpdf software and documentation are
copyright 1996-2025 Glyph & Cog, LLC.

Email: xpdf@xpdfreader.com
WWW: http://www.xpdfreader.com/


Compiling xpdf
--------------

Xpdf is written in C++ (with a little bit of C).  It should work with
any ANSI-compliant C++ and C compilers.  The systems and compilers
it's been tested with are listed on the xpdf web page.

Xpdf requires the Qt toolkit.  The non-GUI command line tools do not
use Qt.

The following notes give specific instructions for compiling on
different systems.


*********************
***  Linux, OS X  ***
*********************

* Make sure you have the following installed:

    - CMake 2.8.8 or newer
    - FreeType 2.0.5 or newer
    - Qt 5.x or 6.x (for xpdf only)
    - libpng (for pdftopng and pdftohtml)
    - zlib (for pdftopng and pdftohtml)

  If Qt isn't found, the GUI viewer (xpdf) won't be built, but the
  command line tools will still be built.

* Create a build directory.  These instructions assume that you create
  a directory called "build" under the top-level xpdf source
  directory, but the build directory can be anywhere you like.  Create
  the directory and cd into it:

      cd ..../xpdf-X.YY
      mkdir build
      cd build

* Run cmake:

      cmake -DCMAKE_BUILD_TYPE=Release {other options - see below} ..

  If your build directory isn't under the source, use the full path to
  the source directory:

      cmake -DCMAKE_BUILD_TYPE=Release {other options} ..../xpdf-X.YY

* If cmake doesn't find FreeType, you can set FREETYPE_DIR to point to
  the FreeType install directory.  Add this to the cmake command line:

      -DFREETYPE_DIR=/opt/freetype

  Cmake will look for ${FREETYPE_DIR}/include.

  You can also set the FreeType library location with:

      -DFREETYPE_LIBRARY=/opt/freetype/lib/libfreetype.so

* If cmake doesn't find Qt, make sure qmake is on your executable
  search path.

* To change the xpdf install directory, use:

      -DCMAKE_INSTALL_PREFIX=/opt/xpdf

  If you're familiar with autoconf, this is similar to the "--prefix"
  option.

* Other configuration options are:

    -DSPLASH_CMYK=ON
        Enable CMYK rasterization support.

    -DA4_PAPER=ON
        Switches the default paper size for PostScript output (xpdf
        and pdftops) to A4.  The default is Letter size.

    -DNO_TEXT_SELECT=ON
        With this option, xpdf will not copy text.  (This is only
        useful on closed systems where the user can't get at the PDF
        file directly.)

    -DOPI_SUPPORT=ON
        Enables support for generation of OPI (Open Prepress
        Interface) comments with pdftops.

    -DNO_FONTCONFIG=ON
        Disables use of libfontconfig, which is used to locate system
        fonts on Linux/Unix systems.  The default is to search for the
        library, and to use it if found.

    -DMULTITHREADED=0
        Disables multithreading, which also disables building the GUI
        viewer (xpdf).  This does not affect the command line tools.
        Disabling multithreading should only be necessary if you're
        building with a compiler other than gcc, clang, or Microsoft
        Visual Studio.

    -DXPDFWIDGET_PRINTING=OFF
        Disable printing support.

    -DUSE_XDG=ON
        Enables use of the XDG directories for config and state files.
        This defaults to ON for Linux, and OFF for everything else.

    -DSYSTEM_XPDFRC="/etc/xpdfrc"
        Look for a system-wide xpdfrc config file in this directory.

    -DXPDFRC_DATADIR="/usr/share/xpdf"
        The ${DATADIR} variable in xpdfrc config files will expand to
        this string.

    -DBASE14_FONT_DIR="/usr/share/fonts/type1"
        By default, Xpdf will look for the URW Type 1 fonts in several
        quasi-standard directories on Linux/Mac systems.  This option
        adds another directory to that search path.  On Windows, this
        does the same thing, except for the system TrueType fonts.

    -DCMAKE_DISABLE_FIND_PACKAGE_Qt5Widgets=1
    -DCMAKE_DISABLE_FIND_PACKAGE_Qt6Widgets=1
        Do not search for the Qt5/Qt6 libraries.  This will disable
        building the GUI viewer (xpdf).  Cmake will look for a "qmake"
        binary -- make sure the first qmake binary on your executable
        search path matches the desired version of Qt.

    -DCMAKE_C_FLAGS="..."
    -DCMAKE_CXX_FLAGS="..."
        Set additional options to pass to the C and/or C++ compilers.

    -DCMAKE_EXE_LINKER_FLAGS="..."
        Set additional options to pass to the linker.

    -DCMAKE_INSTALL_BINDIR
        Set the bin directory, relative to CMAKE_INSTALL_PREFIX
        (typically "bin").

    -DCMAKE_INSTALL_MANDIR
        Set the man directory, relative to CMAKE_INSTALL_PREFIX
        (typically "man" or "share/man").

    -DCMAKE_CXX_FLAGS="... -DDISABLE_SESSION_MANAGEMENT"
        Disable the session manager interface, i.e., do not
        automatically save and restore sessions under control of the
        session manager.

* Build:

      make

  This will build the executables in the build directory:

      xpdf/xpdf
      xpdf/pdftops
      xpdf/pdftotext
      xpdf/pdftohtml
      xpdf/pdfinfo
      xpdf/pdffonts
      xpdf/pdfdetach
      xpdf/pdftoppm
      xpdf/pdftopng
      xpdf/pdfimages
      xpdf-qt/xpdf

* If desired, install the binaries and man pages:

      make install

If you want to run a quick test, there is a tiny PDF file included
with xpdf, as misc/hello.pdf .


*****************
***  Windows  ***
*****************

The Windows build procedure is essentially the same as for Unix.  If
building with cygwin, the procedure is identical to Unix.

If building with Visual Studio:

* Make sure you have CMake, FreeType, libpng, and zlib installed.

* You'll need to set the FREETYPE_DIR variable to point to your
  FreeType installation, CMAKE_INCLUDE_PATH to point to your libpng
  includes, CMAKE_LIBRARY_PATH to point to your libpng library, and
  ZLIB_ROOT to point to your zlib installation.

      cmake -G "NMake Makefiles"
            -DCMAKE_BUILD_TYPE=Release
            -DFREETYPE_DIR="c:/software/freetype"
            -DCMAKE_INCLUDE_PATH="c:/software/libpng"
            -DCMAKE_LIBRARY_PATH="c:/software/libpng"
            -DZLIB_ROOT="c:/software/zlib"
            ..

* Build:

      nmake
