Installing pdftk on Ubuntu 18.04 amd64
I've written a small bash script which automatise the installation on Ubuntu 18.04. Note that I've downloaded only amd64 packages!
#!/bin/bash
#
# author: abu
# date: July 3 2019 (ver. 1.1)
# description: bash script to install pdftk on Ubuntu 18.04 for amd64 machines
##############################################################################
#
# change to /tmp directory
cd /tmp
# download packages
wget http://launchpadlibrarian.net/340410966/libgcj17_6.4.0-8ubuntu1_amd64.deb \
http://launchpadlibrarian.net/337429932/libgcj-common_6.4-3ubuntu1_all.deb \
https://launchpad.net/ubuntu/+source/pdftk/2.02-4build1/+build/10581759/+files/pdftk_2.02-4build1_amd64.deb \
https://launchpad.net/ubuntu/+source/pdftk/2.02-4build1/+build/10581759/+files/pdftk-dbg_2.02-4build1_amd64.deb
echo -e "Packages for pdftk downloaded\n\n"
# install packages
echo -e "\n\n Installing pdftk: \n\n"
sudo apt-get install ./libgcj17_6.4.0-8ubuntu1_amd64.deb \
./libgcj-common_6.4-3ubuntu1_all.deb \
./pdftk_2.02-4build1_amd64.deb \
./pdftk-dbg_2.02-4build1_amd64.deb
echo -e "\n\n pdftk installed\n"
echo -e " try it in shell with: > pdftk \n"
# delete deb files in /tmp directory
rm ./libgcj17_6.4.0-8ubuntu1_amd64.deb
rm ./libgcj-common_6.4-3ubuntu1_all.deb
rm ./pdftk_2.02-4build1_amd64.deb
rm ./pdftk-dbg_2.02-4build1_amd64.deb
This script will download the packages to /tmp
and install from there using an apt install
command! Afterwards the packages in the /tmp
directory will be removed.
To run this script, copy it in an editor and save it e.g. pdftk_installer. Then run it in a terminal with
chmod 755 pdftk_installer
./pdftk_installer
Installing pdftk on Ubuntu 20.04 amd64
The script above will fail due to missing gcc-6 libraries on Ubuntu 20.04. However, those who would like to avoid the snap or docker solution may use schroot. I know that this is a pretty overload - it takes about 500MB; but you can use this environment to install further elderly programs, libs, compilers, etc. in the Xenial (Ubuntu 16.04) environment.
First install the schroot
package
sudo apt install schroot debootstrap
The last package is required to install a debian-like-system.
Now write a xenial.conf
file into the /etc/schroot/schroot.d
directory:
cat <<EOF | sudo tee /etc/schroot/chroot.d/xenial.conf
> [xenial]
> description=Ubuntu 16.04
> directory=/srv/chroot/xenial
> root-users=$USER
> type=directory
> users=$USER
> EOF
Verify that the new conf-file is written
cat /etc/schroot/chroot.d/xenial.conf
Next create the xenial directory (if you choose another directory alter the conf file above):
sudo mkdir -p /srv/chroot/xenial
Now the show begins, while installing go for a coffee:
sudo debootstrap xenial /srv/chroot/xenial
The xenial file system is now available on /srv/chroot/xenial
.
Now it's time to include the necessary xenial apt repositories. To do so type
cat <<EOF | sudo tee /srv/chroot/xenial/etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
EOF
Again check that the file /srv/chroot/xenial/etc/apt/sources.list
exists
cat /srv/chroot/xenial/etc/apt/sources.list
It's time to enter the xenial schroot (note: no root privileges needed!) and update the apt
schroot -c xenial -u root apt-get update
Finally you are ready to install the pdftk package
:
schroot -c xenial -u root apt-get install pdftk
You can use pdftk
by invoking it via the schroot:
schroot -c xenial -- pdftk <your arguments>
E.g. to show the help menu type
schroot -c xenial -- pdftk --help
Last of all I suggest to make an alias for pdftk in your .bashrc
file:
First make a copy of your .bashrc
cp ~/.bashrc ~/.bashrc_backup
and then add an alias
echo alias pdftk='schroot -c xenial -- pdftk' >> ~/.bashrc
Now you can use pdf
as usual in your bash. To test open a new terminal and type
pdftk --version
If you have to install other older programs as I had to do, use the apt commands similar as described above.
Note that all commands beside the apt-get
and the xenial.config
are executed with user privileges.