170

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.

dessert
  • 39,982
WiKrIe
  • 1,939

17 Answers17

131

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 install pdftk 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:

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

The package contains a wrapper script placed in /usr/bin, so you can invoke it as normally:

pdftk <arguments> ...

Install from source

  1. Install the build tools and dependencies:

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

    Of course you can use a different supported JDK than the one supplied by default-jdk-headless.

  2. Download Marc Vinyal’s pdftk fork:

    git clone https://gitlab.com/pdftk-java/pdftk.git
    cd pdftk
    
  3. Place symbolic links to the required libraries into the lib folder:

    mkdir lib
    ln -st lib /usr/share/java/{commons-lang3,bcprov}.jar
    
  4. Build the JAR package:

    ant jar
    
  5. Run the JAR package:

    java -jar build/jar/pdftk.jar --help
    
  6. (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 libraries libcommons-lang3-java and libbcprov-java:

    sudo apt install default-jre-headless libcommons-lang3-java libbcprov-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).

  7. (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:

  • No, PDF Chain is a C++ application and not directly affected by the deprecation of GCJ. It needs a working pdftk executable but doesn’t care how it works under the hood. In any case, PDF Chain was dropped from Bionic as well as pdftk.
David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • I was reading another question about installing a different package that was dropped from the repos for 18.04, and one user suggested installing the .deb package using gdebi, which should handle dependencies. Do you think that would work or would it create some problems? That may be a dumb question--I'm just trying to understand more about package management. – Hee Jin May 15 '18 at 16:22
  • 6
    Both sets of instructions in this answer install Marc Vinyal’s pdftk-java fork. That will be (very probably) the official replacement for pdftk in Debian (see) and in Ubuntu (with a package available for 18.10). So this seems to be the best answer, as it is "future proof": from 18.10 on, you'll get the same software served in the official repos. – tanius Aug 26 '18 at 16:59
  • @DavidFoerster On it. Question: Is there a particular reason for recommending ant with libraries installed via apt over using Gradle for the build? – Raphael Jan 04 '19 at 10:01
  • At a follow-up question regarding said dummy packages, doubts arose as to whether the dependencies of pdftk-java are well-chose. You may want to check that out. – Raphael Jan 04 '19 at 12:10
  • I created package descriptions for equivs that provide Java installed by SDKMAN! as a package that fulfills the dependencies of pdftk-java. – Raphael Jan 04 '19 at 12:11
  • Absolutely excellent answer - I now have pdftk on my 18.04 install, thank you so much! – Astrid_Redfern Dec 16 '20 at 17:57
106

For Ubuntu 18.04, just install the pdftk snap package:

sudo snap install pdftk
smoser
  • 1,825
pgoetz
  • 1,233
  • 1
    Symlinking didn't work for me, because snap seems to need the script name. But a minimal wrapper script /snap/bin/pdftk-smoser.pdftk "$@" works equally well. – Boldewyn Jun 27 '18 at 20:30
  • What version of Ubuntu? The precise instructions I give above worked for me. I call pdftk from some perl xml processing scripts and the acid test is the scripts work and produce merged pdf's. – pgoetz Jun 28 '18 at 22:34
  • Kubuntu 18.04, just upgraded from 16.04 and found pdftk missing. When I do the symlink, running pdftk in bash yields snaps help message. ¯\(ツ) – Boldewyn Jun 29 '18 at 06:46
  • Make sure the snap daemon is running. – pgoetz Jul 07 '18 at 21:14
  • 3
    i updated the answer above to use just 'pdftk' rather than 'pdftk' as I (smoser) have uploaded a snap named 'pdftk' to the store with the same content. (https://snapcraft.io/pdftk) – smoser Jul 12 '18 at 19:27
  • can you (@pgoetz or @smoser) expand a bit on what additional steps are necessary? I needed to symlink the snap to /usr/local/bin/pdftk to get the command working in the bash and still have trouble accessing a pdf in /var/www/some/path, even if I reinstall the snap in devmode – cypherabe Jul 26 '18 at 15:34
  • The symlink is just a path issue I suspect. You want to do this in any case for convenience sake. I'm not sure why you'd have trouble accessing a pdf in /var/www/* though -- have you checked to make sure this isn't just a permissions problem? What happens when you try to open a pdf from these locations? I seem to remember having left a much more detailed answer, which smoser appears to have edited. Maybe he can chime in on this as well. One would think that at the very least you'd want the symlink to a common path location. – pgoetz Jul 27 '18 at 17:18
  • 7
    This seemed to install fine but then pdftk would not open or work on any files (always says 'Error: Unable to find file. Error: Failed to open PDF file:'), also has no man page. In the end I removed it with snap remove and went with @abu_bua solution above, which works perfectly. – scoobydoo Jul 30 '18 at 10:08
  • This snap-installed version of pdftk doesn't seem to work with files owned by a user who is not the user running pdftk, even if those files are set world readable. I went with the PPA by "David Foerster" mentioned above and it worked better. (Though I still have issues with using the file "-") – Daniel Martin Aug 06 '18 at 17:23
  • 2
    Due to design points of snaps, a snap cannot access all files. Some information on this is available at https://github.com/smoser/pdftk/issues/1 . The easiest solution is to put files in your home directory. – smoser Aug 07 '18 at 18:58
  • 1
    Thank you, I did snap install pdftk on Ubuntu 18.04 LTS and it's working perfectly out-of-the-box! – Timo Jyrinki Aug 17 '18 at 13:04
  • 1
    /snap/bin/whatever would work for a while and break with all kinds of permission denied problems on Ubuntu 18.04. For pdftk, the error is java.io.FileNotFoundException. The list of failure for other apps is endless. I had to remove virtually all snap apps and replace them with apt. Snap is the worst thing happening on Ubuntu 18.04 at the moment. – SYK Oct 28 '18 at 07:07
65

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 installcommand! 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.

abu_bua
  • 10,783
16

This works for ubuntu 18.04:

sudo add-apt-repository ppa:malteworld/ppa
sudo apt update
sudo apt install pdftk
14

You can try use a docker image of Ubuntu 16.04 with pdftk installed to run pdftk:

  1. Install docker:

    sudo apt install docker.io
    
  2. Pull Ubuntu 16.04 and run a bash shell:

    sudo docker run -it ubuntu:16.04 bash
    
  3. Update and install pdftk from container prompt:

    apt update
    apt install pdftk
    
  4. On a new terminal run:

    sudo docker ps -a
    
  5. Commit the image using the CONTAINER ID of ubuntu:16.04 to a new image with pdftk installed:

    sudo docker commit CONTAINER_ID ubuntu_pdftk
    

    (Replace CONTAINER_ID with your container ID.)

  6. Create a file named pdftk in /usr/bin and then make it executable using chmod +x /usr/bin/pdftk:

    #!/bin/sh
    set -eu
    docker run --name pdftk -it -v "$PWD:/workdir$PWD" -w "/workdir$PWD" ubuntu_pdftk pdftk "$@"
    docker rm pdftk
    
David Foerster
  • 36,264
  • 56
  • 94
  • 147
8

Install the pdftk snap package.

  1. Run:

     sudo snap install pdftk
    
  2. Do as follows to run your package from root or you want to run from node, etc.

    Once you install Pdftk from snap you need to change the path /snap/pdftk/current/usr/.. to Ubuntu to /usr for replace run the following command.

     sudo ln -s /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
    

    or for overwrite run the following command.

     sudo ln -fs /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk
    
  3. Test with pdftk input.pdf cat output new.pdf

karel
  • 114,770
5

I was able to install pdftk from artful (17.10) deb packages. Download and then install, in that order :

It's best to install gcc-6-base first to avoid dependencies error if you do it from cli.

That should do the trick… for now.

amha
  • 51
  • 2
3

For getting pdftk onto 18.04 specifically, I've found that this works:

  1. get 18.10 version of the deb for pdftk-java
  2. install dependencies from normal 18.04 repos
  3. dpkg install pdftk-java package downloaded from 18.10

IE:

$ wget wget http://launchpadlibrarian.net/383018194/pdftk-java_0.0.0+20180723.1-1_all.deb
$ sudo apt install default-jre-headless libcommons-lang3-java libbcprov-java
$ sudo dpkg -i pdftk-java_0.0.0+20180723.1-1_all.deb
Joel Kleier
  • 1,401
2

I made a quick and dirty workaround to get PDFTK running under Bionic.

lsb_release -a && pdftk --version
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:        18.04
Codename:       bionic

pdftk 2.02 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2003-13 Steward and Lee, LLC - Please Visit: www.pdftk.com

I update my sources.list and include the following lines:

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

After that I run a simple

sudo apt update

to make the changes take effect.

Then install pdftk via

sudo apt install pdftk

Then remove the Artful sources from the source.list again and this is how I get PDFTK running under Bionic.

Source: https://christiandietze.de/pdftk-with-ubuntu-bionic-18-04/

David Foerster
  • 36,264
  • 56
  • 94
  • 147
WiKrIe
  • 1,939
  • 5
    Hi Christian, would you mind updating your answer to include what your workaround is? We prefer if you include the essential parts of the answer here and then provide the link for reference. Thanks! – CalvT May 01 '18 at 19:31
  • 1
    Yes, especially since the site you linked to seems to be down. – terdon May 02 '18 at 08:35
  • Hi CalvT, the workaround I use is simply add the artfull packages to apt, install pdftk and remove them. And terdon my site was not down within the last 30 days so I do not know why you should not access the site. – WiKrIe May 07 '18 at 19:04
  • @WiKrIe There is a problem with your site. I can reach the base URL, but not the page you linked. Neither can Wayback Machine. Google cache won't load it, but will load the source. There must be a problem on that page somewhere. So that's why terdon♦ thought your site was down. So did I until I checked. Hope that helps. – Dɑvïd Jun 01 '18 at 11:09
  • @David I check my site right now, and for me all pages are online, but I see that there is maybe a block from your IP range, because I use fail2ban to block out bad IP's so if you would send me your IP I could check if I can find it in any jail and why it is in that jail. That would be the only explain from my side. – WiKrIe Jun 01 '18 at 12:52
  • 1
    -1 for the suggestion to mix repositories meant for different Ubuntu releases without proper priority rules. – David Foerster Jun 07 '18 at 10:33
2

I like Ademir's docker answer, but it has the typical problems with security and permissions, because docker has to run as root. If that bothers you, try using Singularity. You need to build the image as root, but any user can then run it.

Here's the Singularity file I used:

# Generate the Singularity container to run pdftk from Ubuntu 16.04.
Bootstrap: docker
From: ubuntu:16.04

%help
    pdftk was removed from Ubuntu 18.04, so this container packages up the old
    version.

%post
    apt-get update -qq
    apt-get install -qq pdftk

%runscript
    pdftk "$@"

Then I built the image.

sudo singularity build pdftk.simg Singularity

Once that worked, I installed it to a folder on the path, along with a wrapper script that sets the home folder to the current directory.

sudo mv pdftk.simg /usr/bin/
echo 'singularity run --home $PWD /usr/bin/pdftk.simg "$@"' > pdftk
sudo chown root:root pdftk
sudo chmod +x pdftk
sudo mv pdftk /usr/bin

And now I can run pdftk.

$ pdftk --version

pdftk 2.02 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2003-13 Steward and Lee, LLC - Please Visit: www.pdftk.com
This is free software; see the source code for copying conditions. There is
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The only down side is that it's a rather large executable, because it contains a complete Ubuntu 16.04 distribution. You might also have trouble if you're trying to manipulate PDF files that aren't in the current directory.

$ ls -lh /usr/bin/pdftk*
-rwxr-xr-x 1 root root  53 Jul 23 12:32 /usr/bin/pdftk
-rwxr-xr-x 1 root root 88M Jul 23 12:06 /usr/bin/pdftk.simg
Don Kirkby
  • 1,457
1

You can run pdftk on Ubuntu 18.04 with docker. That's an enhanced variant of Ademir's answer.

Assuming we only need a cli component of the pdftk and there's docker installed on the machine. Just put the following script somewhere on the $PATH with the name pdftk and executable bit set:

#!/bin/bash

# Build or use cached image and tag with "local/local/ubuntu_pdftk", suppress 
# output to maintain compatibility in case you are parsing the pdftk output.
# It will build the image if it's absent or use the cached one.
echo "FROM ubuntu:16.04
RUN apt-get update && \
    apt-get install -y pdftk && \
    rm -rf /var/lib/apt/lists/*" | docker build -t local/local/ubuntu_pdftk - 2>&1 > /dev/null

# Run the pdftk as current user
set -eu
docker run --name pdftk -it --user $(id -u):$(id -g) --rm -v "$PWD:/workdir$PWD" -w "/workdir$PWD" local/local/ubuntu_pdftk pdftk "$@"

First run will take like 2 minutes to build the image, if the built image will remain on the machine next runs will be faster. You can freely clean up the image, it will be built when you'll need it next time.

1

The download links in the script posted by @abu_bua seem to not be working anymore (probably because of end of support for 17.10?), so here is a modified version of the same script that uses the corresponding packages from the 16.04 build. Tried and tested on a machine running 18.04.

#!/bin/bash
#
# author: abu
# date:   May 12 2018
# description: bash script to install pdftk on Ubuntu 18.04 for amd64 machines
##############################################################################
#
# change to /tmp directory
cd /tmp
# download packages
wget http://mirrors.edge.kernel.org/ubuntu/pool/main/g/gcc-5/libgcj16_5.4.0-6ubuntu1~16.04.10_amd64.deb \
    http://mirrors.edge.kernel.org/ubuntu/pool/main/g/gcc-defaults/libgcj-common_4.9.3-9ubuntu1_all.deb \
    http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/pdftk/pdftk_2.02-4_amd64.deb \
    http://mirrors.edge.kernel.org/ubuntu/pool/universe/p/pdftk/pdftk-dbg_2.02-4_amd64.deb

echo -e "Packages for pdftk downloaded\n\n"
# install packages 
echo -e "\n\n Installing pdftk: \n\n"
sudo apt-get install ./libgcj16_5.4.0-6ubuntu1~16.04.10_amd64.deb \
    ./libgcj-common_4.9.3-9ubuntu1_all.deb \
    ./pdftk_2.02-4_amd64.deb \
    ./pdftk-dbg_2.02-4_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 ./libgcj16_5.4.0-6ubuntu1~16.04.10_amd64.deb
rm ./libgcj-common_4.9.3-9ubuntu1_all.deb
rm ./pdftk_2.02-4_amd64.deb
rm ./pdftk-dbg_2.02-4_amd64.deb
1

Ubuntu 18.04 has a lack of options for pdftk installation. But this one's fastest I came across so far.

Download pdftk-java_3.3.2-1_all.deb from http://ftp.debian.org/debian/pool/main/p/pdftk-java/

Install: sudo apt install ./pdftk-java_3.3.2-1_all.deb

mxdsp
  • 3,818
AVK
  • 111
  • 2
    The same version of pdftk-java can be installed in Ubuntu 22.04 by running sudo apt install pdftk-java – karel Jan 13 '23 at 08:35
  • @karel there's a problem with 18.04. unfortunately apt install doesnt work there. snap package also doesnt work. the only option left is either to go through the build process of pdftk-java or just install that package. i'll amend my post specifying that it's specific to 18.04 – AVK Jan 13 '23 at 12:18
0

What a great opportunity to use some docker magic!

What I did was to use a docker container running ubuntu 16.04, install pdftk inside it and run it there.

Here are the exact steps if you want to do the same thing:

  1. Install docker if you don't already have it (https://docs.docker.com/install/)
  2. Create a directory somewhere called pdftk
  3. Create a directory called docker inside the pdftk directory
  4. Copy this Dockerfile into the pdftk/docker directory: https://github.com/gkotian/gautam_linux/blob/master/docker/pdftk/Dockerfile
  5. Copy this script also into the pdftk/docker directory: https://github.com/gkotian/gautam_linux/blob/master/scripts/dockershell
  6. Make sure the dockershell script is executable
  7. Into the pdftk directory, copy all the pdf files you want to work with
  8. cd /path/to/pdftk
  9. Run the dockershell script with the path of the Dockerfile: docker/dockershell docker/Dockerfile (this will take some time the very first time you run it)

Now you should have a prompt inside the docker container, from where you can run pdftk. When you're done, type exit to exit the container and return to the host machine. Any newly generated files will be present in the pdftk directory (but they'll be owned by root, so you may need to change ownership as necessary).

Gautam
  • 101
0

On my 18.04 running in WSL I did the following

Get the dependencies from the (.deb files):

wget http://hr.archive.ubuntu.com/ubuntu/pool/main/g/gcc-6/libgcj17_6.4.0-8ubuntu1_amd64.deb

wget http://mirrors.edge.kernel.org/ubuntu/pool/main/g/gcc-defaults/libgcj-common_6.4-3ubuntu1_all.deb

sudo apt install gcc-6-base

then install the above dependencies

sudo dpkg -i libgcj*

then I took the .deb from https://packages.debian.org/search?keywords=pdftk

wget http://ftp.us.debian.org/debian/pool/main/p/pdftk/pdftk_2.02-4+b2_amd64.deb
sudo dpkg -i pdftk_2.02-4+b2_amd64.deb
0

Running sudo snap install pdftk on Digital Oceans Droplet Ubuntu 18.04 worked fine for me. PDFTK seems to be added to the system path as well as I can access it from the command line, such as pdftk --help works.

My dev platform is Windows. On my Linux server, what do I substitute for the following line?

$pathToPdfTKBinary = "C:\\Program Files (x86)\\PDFtk Server\\bin\\pdftk.exe";
0

having docker in Ubuntu:

alias pdftk='docker run -v $(pwd):/work mnuessler/pdftk'

pdftk in.pdf cat 1-endeast output out.pdf

Abdennour TOUMI
  • 9,357
  • 9
  • 44
  • 51