Is there any chance of getting pdftk
working in Ubuntu 18.04?
I need this for creating PDF files with a watermark in shell.
Or, does anybody know a working alternative to pdftk
to generate a PDF with a watermark in shell?
I already check/try out all of them:
sudo apt list pdf*
Listing... Done
pdf-presenter-console/bionic 4.1-2 amd64
pdf-redact-tools/bionic,bionic 0.1.2-1 all
pdf.js-common/bionic,bionic 1.5.188+dfsg-1 all
pdf2djvu/bionic 0.9.8-0ubuntu1 amd64
pdf2svg/bionic 0.2.3-1 amd64
pdfcrack/bionic 0.16-1 amd64
pdfcube/bionic 0.0.5-2build6 amd64
pdfcube-dbg/bionic 0.0.5-2build6 amd64
pdfgrep/bionic 2.0.1-1 amd64
pdfminer-data/bionic,bionic 20140328+dfsg-1 all
pdfmod/bionic,bionic 0.9.1-8 all
pdfmod-dbg/bionic,bionic 0.9.1-8 all
pdfposter/bionic,bionic 0.6.0-2 all
pdfresurrect/bionic 0.14-1 amd64
pdfsam/bionic,bionic 3.3.5-1 all
pdfsandwich/bionic 0.1.6-1 amd64
pdfshuffler/bionic,bionic 0.6.0-8 all
pdftoipe/bionic 1:7.2.7-1build1 amd64
But did not find a working tool.
Best Answer
The pdftk package in Ubuntu (and its upstream Debian package) was dropped due to its dependency on the now deprecated GCJ runtime. I found a fork that depends on OpenJDK or similar instead.
Install from a future Ubuntu release (recommended)
Starting with Cosmic (Ubuntu 18.10), Ubuntu ships
pdftk-java
from the same source code as below as a replacement. Attempting to installpdftk
will install this package instead. Users of earlier releases can download it manually from the package repository and install it with their favourite package manager.Install from PPA(outdated)I built a Deb package (for Bionic only) with suitable dependencies:The package contains a wrapper script placed in
/usr/bin
, so you can invoke it as normally:Install from source
Install the build tools and dependencies:
Of course you can use a different supported JDK than the one supplied by
default-jdk-headless
.Download Marc Vinyal’s pdftk fork:
Place symbolic links to the required libraries into the
lib
folder:Build the JAR package:
Run the JAR package:
(Optional) To run the JAR package, e. g. when you distribute it to other systems, you need at least a working (headless) JRE like from the
default-jre-headless
package as well as the Java librarieslibcommons-lang3-java
andlibbcprov-java
:Again you can use a different JRE than
default-jre-headless
. This pdftk fork also supports builds for older JRE versions (≥ 7 according to the documentation).(Optional) You can teach Linux to execute JAR (Java Archive) files via
update-binfmts(8)
. Most JREs shipped in Deb packages, including those in Canonical’s package repositories, take care of that during installation, though it appears to be buggy in some OpenJDK packages.P.S.: I tried this with the non-headless OpenJDK 9 in Ubuntu Trusty but I see little reasons why it shouldn't work with headless OpenJDK 10 in Bionic.
Depending applications
A commenter raised the valid question whether the depending PDF Chain applications is affected by this change: