2 , enablePDFtoPPM ? true
3 , enablePrinting ? true
4 , lib, stdenv, fetchzip, cmake, makeDesktopItem
5 , zlib, libpng, cups ? null, freetype ? null
6 , qtbase ? null, qtsvg ? null, wrapQtAppsHook
9 assert enableGUI -> qtbase != null && qtsvg != null && freetype != null;
10 assert enablePDFtoPPM -> freetype != null;
11 assert enablePrinting -> cups != null;
13 stdenv.mkDerivation rec {
19 "https://dl.xpdfreader.com/xpdf-${version}.tar.gz"
20 "https://dl.xpdfreader.com/old/xpdf-${version}.tar.gz"
22 hash = "sha256-LBxKSrXTdoulZDjPiyYMaJr63jFHHI+VCgVJx310i/w=";
25 # Fix "No known features for CXX compiler", see
26 # https://cmake.org/pipermail/cmake/2016-December/064733.html and the note at
27 # https://cmake.org/cmake/help/v3.10/command/cmake_minimum_required.html
28 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
29 substituteInPlace CMakeLists.txt --replace \
30 'cmake_minimum_required(VERSION 2.8.12)' 'cmake_minimum_required(VERSION 3.1.0)'
35 ++ lib.optional enableGUI wrapQtAppsHook;
37 cmakeFlags = ["-DSYSTEM_XPDFRC=/etc/xpdfrc" "-DA4_PAPER=ON" "-DOPI_SUPPORT=ON"]
38 ++ lib.optional (!enablePrinting) "-DXPDFWIDGET_PRINTING=OFF";
40 buildInputs = [ zlib libpng ] ++
41 lib.optional enableGUI qtbase ++
42 lib.optional enablePrinting cups ++
43 lib.optional enablePDFtoPPM freetype;
45 desktopItem = makeDesktopItem {
48 comment = "Views Adobe PDF files";
51 categories = [ "Office" ];
54 postInstall = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
55 install -Dm644 ${desktopItem}/share/applications/xpdf.desktop -t $out/share/applications
56 install -Dm644 $src/xpdf-qt/xpdf-icon.svg $out/share/pixmaps/xpdf.svg
60 homepage = "https://www.xpdfreader.com";
61 description = "Viewer for Portable Document Format (PDF) files";
63 XPDF includes multiple tools for viewing and processing PDF files.
64 xpdf: PDF viewer (with Graphical Interface)
65 pdftotext: converts PDF to text
66 pdftops: converts PDF to PostScript
67 pdftoppm: converts PDF pages to netpbm (PPM/PGM/PBM) image files
68 pdftopng: converts PDF pages to PNG image files
69 pdftohtml: converts PDF to HTML
70 pdfinfo: extracts PDF metadata
71 pdfimages: extracts raw images from PDF files
72 pdffonts: lists fonts used in PDF files
73 pdfdetach: extracts attached files from PDF files
75 license = with licenses; [ gpl2Only gpl3Only ];
76 platforms = platforms.unix;
77 maintainers = with maintainers; [ sikmir ];
78 knownVulnerabilities = [