Linux Applications

Install PDFtk on Ubuntu

PDF is an integral part of our everyday life. It’s a document format that’s trusted by every single platform. Often times, important documents and books are in PDF format. It’s so widespread that without an appropriate PDF tool at hand, no system is complete. Ubuntu offers a great flexibility in terms of software availability. It’s also one of the most popular Linux distros for being so simple yet powerful and fast, extremely suitable for new to moderate Linux users. Let’s grab PDFtk – the ultimate PDF toolkit you’ll ever need!

PDFtk

There are 2 versions of PDFtk available – Free, Pro ($3.99) and Server. The Pro version offers all the additional features like rotating the PDF, stamping etc. The Server version is the command-line utility for performing various tasks.

PDFtk is available in the default Ubuntu software repository. However, on the latest Ubuntu releases, it’s not accessible directly. You have to use a little trick to get in on your system.

Method 1

Run the following commands –

sudo add-apt-repository ppa:malteworld/ppa
sudo apt update

sudo apt install pdftk

Method 2

You can also download and build PDFtk by yourself. For doing so, you need the Java build tools and dependencies.

Run the following commands –

sudo apt install default-jre-headless libcommons-lang3-java libbcprov-java

sudo apt install git default-jdk-headless ant \
libcommons-lang3-java libbcprov-java

git clone https://gitlab.com/pdftk-java/pdftk.git
 
cd pdftk
mkdir libs
ln -st libs /usr/share/java/{commons-lang3,bcprov}.jar

ant jar
java -jar build/jar/pdftk.jar --help

Method 3 (recommended)

Install the PDFtk snap –

sudo snap install pdftk

Note that this is the “Server” version of PDFtk.

Using PDFtk

After the installation is complete, check out the app working perfectly –

pdftk

In fact, running this command will show a short guide you can use. For the long, in-depth guide, run the following command –

pdftk --help

For checking out the guide later, export it to a text file –

pdftk --help > ~/Desktop/pdftk.txt

Here are some of the most used tasks you can do with PDFtk.

Encrypt a PDF (128-bit encryption)

pdftk dummy.pdf output dummy.128.pdf owner_pw foo user_pw 123

Decrypt a PDF

pdftk dummy.128.pdf input_pw 123 output dummy.unsecured.pdf

Join multiple PDFs into one

pdftk dummy1.pdf dummy2.pdf cat output dummy_merged.pdf

You can also use wildcard –

pdftk *.pdf cat output combined.pdf

Rotate PDF document (must be 1 page document)

# 90° clockwise rotate
pdftk dummy.pdf cat 1east 2-end output dummy_90.pdf

# 180° rotate
pdftk dummy.pdf cat 1-endsouth output dummy_180.pdf

Enjoy!

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.