Run pdftk on Ubuntu 18.04 or later

Share and Enjoy !

Shares

The convenient pdf manipulation tool [cci]pdftk[/cci] is not available in Ubuntu 18.04 repositories because of some licensing incompatibilities. Using some docker magic and a small script we’ll use it as in previous Ubuntu releases, since it’s still available in 16.04 repositories. Here we will exploit the docker capabilities to run the [cci]pdftk[/cci] binaries in the container.

Prerequisites: docker should be installed and working. Easiest thing to do is [cc]sudo apt-get update && sudo apt-get install docker-ce && sudo usermod -aG docker $USER[/cc] and reinitiate the user session for the changes to take effect (logoff completely and relogin) or you’ll be able to run docker as root user only.

A convenience installation one-liner (second version of the script):
[cc]
sudo wget https://gist.githubusercontent.com/sheershoff/a1e068b3f6ed60ed87f56a9e5dce312b/raw/ea9bc8462c0b8aab6e30efa7bffc9e02d0e58cfe/pdftk -O /usr/local/bin/pdftk && sudo chmod a+x /usr/local/bin/pdftk
[/cc]

Or for manual installation put this script somewhere on your [cci]$PATH[/cci] named [cci]pdftk[/cci], ensure [cci]chmod a+x SCRIPT_PATH[/cci]. Then use [cci]pdftk[/cci] normally as you did before.

Comments, corrections are welcome )

Share and Enjoy !

Shares