Install pdftk on unbuntu 18.04

PDFTK is a very handy package that handles PDFs. It could open and write to existing PDFs, and a lot of other great things. However, it is missing from the Ubuntu 18 and is very tricky to install on Ubuntu 18 (but works nice and smoothly on Ubuntu 16). This tutorial is intended to save you some time/hair when you have to install PDFTK on ubuntu 18.

  1. RUN sudo apt-get update to update the current libs
  2. RUN sudo apt-get install libcairo2 libpango-1.0-0 libpangocairo-1.0.0 libgdk-pixbuf2.0-0 libffi-dev libmagickwand-dev to install all the necessary packages
  3. RUN locate sources.list to find the path for the sources.list file
    • It is /etc/apt/sources.list on my machine
  4. RUN sudo nano /etc/apt/sources.list to go into the file and edit it
  5. Add the following lines to the bottom of the file:
deb http://no.archive.ubuntu.com/ubuntu/ artful main restricted
deb http://no.archive.ubuntu.com/ubuntu/ artful-updates main restricted
deb http://no.archive.ubuntu.com/ubuntu/ artful universe
deb http://no.archive.ubuntu.com/ubuntu/ artful-updates universe
deb http://no.archive.ubuntu.com/ubuntu/ artful multiverse
deb http://no.archive.ubuntu.com/ubuntu/ artful-updates multiverse
deb http://no.archive.ubuntu.com/ubuntu/ artful-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu artful-security main restricted
deb http://security.ubuntu.com/ubuntu artful-security universe
deb http://security.ubuntu.com/ubuntu artful-security multiverse
  1. Use CTRL + x (and hit enter) to save and quit
  2. Update the system: sudo apt update
  3. Install related system packages in the folowing order:
    • sudo apt-get install libgcj-common
    • sudo apt-get install libgcj17
  4. Install the pdftk package: sudo apt-get install pdftk
  5. After the pdftk package is installed, go back to the sources.list file (i.e step 4) and delete the lines we added in step 5
  6. Update system again (i.e. step 7)

Notes: