Package: guix-patches;
Reported by: Danny Milosavljevic <dannym <at> friendly-machines.com>
Date: Fri, 14 Mar 2025 23:12:02 UTC
Severity: normal
Tags: patch
Done: 宋文武 <iyzsong <at> envs.net>
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: Danny Milosavljevic <dannym <at> friendly-machines.com> To: 77021 <at> debbugs.gnu.org Cc: Danny Milosavljevic <dannym <at> friendly-machines.com> Subject: [bug#77021] [PATCH] gnu: Add pdftk. Date: Sat, 15 Mar 2025 00:10:14 +0100
* gnu/packages/pdf.scm (pdftk): New variable. Change-Id: Ia331a89d63f114c99e7613d421aff62bbc18e082 --- gnu/packages/pdf.scm | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm index de6df8da93..3268941729 100644 --- a/gnu/packages/pdf.scm +++ b/gnu/packages/pdf.scm @@ -52,6 +52,7 @@ (define-module (gnu packages pdf) #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix utils) + #:use-module (guix build-system ant) #:use-module (guix build-system gnu) #:use-module (guix build-system cmake) #:use-module (guix build-system meson) @@ -84,6 +85,7 @@ (define-module (gnu packages pdf) #:use-module (gnu packages gstreamer) #:use-module (gnu packages gtk) #:use-module (gnu packages image) + #:use-module (gnu packages java) #:use-module (gnu packages javascript) #:use-module (gnu packages kde-frameworks) #:use-module (gnu packages lesstif) @@ -1792,3 +1794,91 @@ (define-public sioyek (description "Sioyek is a PDF viewer with a focus on textbooks and research papers.") (license license:gpl3+))) + +(define-public pdftk + (package + (name "pdftk") + (version "3.3.3") + (source + (origin + (method url-fetch) + (uri (string-append "https://gitlab.com/pdftk-java/pdftk/-/archive/v" + version "/pdftk-v" version ".tar.gz")) + (sha256 + (base32 "11mj0phf78pkbdzvnfhl7n4z476fiv1zjfbf2cx9wlsq8vjpv54w")))) + (build-system ant-build-system) + (arguments + (list + #:jdk openjdk11 + #:tests? #f ; no test suite + #:phases + #~(modify-phases %standard-phases + (add-before 'build 'copy-lib-files + (lambda* (#:key inputs #:allow-other-keys) + (mkdir-p "lib") + (for-each + (lambda (lib) + (copy-file lib (string-append "lib/" (basename lib)))) + (append + (find-files (assoc-ref inputs "java-bouncycastle") "\\.jar$") + (find-files (assoc-ref inputs "java-commons-lang3") "\\.jar$"))))) + (replace 'install + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (share (string-append out "/share")) + (lib (string-append out "/lib")) + (doc (string-append share "/doc/pdftk")) + (man1 (string-append share "/man/man1"))) + (mkdir-p bin) + (mkdir-p lib) + (mkdir-p doc) + (mkdir-p man1) + (install-file "build/jar/pdftk.jar" lib) + ;; Install dependencies. + (for-each + (lambda (dep-jar) + (install-file dep-jar lib)) + (append + (find-files (assoc-ref inputs "java-bouncycastle") "\\.jar$") + (find-files (assoc-ref inputs "java-commons-lang3") "\\.jar$"))) + ;; Create wrapper script. + (with-output-to-file (string-append bin "/pdftk") + (lambda _ + (format #t + "#!~a/bin/bash~@ + CLASSPATH=~a/lib/pdftk.jar:~a/lib/*~@ + exec ~a/bin/java -cp $CLASSPATH com.gitlab.pdftk_java.pdftk \"$@\"~%" + (assoc-ref inputs "bash") + out + out + (assoc-ref inputs "openjdk")))) + ;; Make the wrapper executable. + (chmod (string-append bin "/pdftk") #o755) + (copy-recursively "doc" doc) + (install-file "pdftk.1" man1))))))) + (inputs + (list bash java-bouncycastle java-commons-lang3 openjdk11)) + (home-page "https://gitlab.com/pdftk-java/pdftk") + (synopsis "Tool for manipulating PDF documents") + (description + "This package provides a tool for doing everyday things with PDF +documents. It can: +@itemize +@item Merge PDF documents or collate PDF page scans +@item Split PDF pages into a new document +@item Rotate PDF documents or pages +@item Decrypt input as necessary (password required) +@item Encrypt output as desired +@item Fill PDF forms with X/FDF data and/or flatten forms +@item Generate FDF data stencils from PDF forms +@item Apply a background watermark or a foreground stamp +@item Report PDF metrics, bookmarks and metadata +@item Add/Update PDF bookmarks or metadata +@item Attach files to PDF pages or the PDF document +@item Unpack PDF attachments +@item Burst a PDF document into single pages +@item Uncompress and re-compress page streams +@item Repair corrupted PDF (where possible) +@end itemize") + (license license:gpl2+))) base-commit: 88eaa9e7262481eea79ae4fe45fcc5882160750a -- 2.48.1
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.