I'm trying to compile a bunch of PDFs into a single document. ls shows the files are in the directory that I'm in and they're readable (-rw-r--r--). But when I try to run pdftk 2017.pdf cat output test.pdf I get an error:

Error: Unexpected Exception in open_reader()
java.io.FileNotFoundException: 2017.pdf (Permission denied)
   at gnu.java.nio.channels.FileChannelImpl.open(libgcj.so.16)
   at gnu.java.nio.channels.FileChannelImpl.<init>(libgcj.so.16)
   at gnu.java.nio.channels.FileChannelImpl.create(libgcj.so.16)
   at java.io.RandomAccessFile.<init>(libgcj.so.16)
   at pdftk.com.lowagie.text.pdf.RandomAccessFileOrArray.<init>(pdftk)
   at pdftk.com.lowagie.text.pdf.PRTokeniser.<init>(pdftk)
   at pdftk.com.lowagie.text.pdf.PdfReader.<init>(pdftk)
   at pdftk.com.lowagie.text.pdf.PdfReader.<init>(pdftk)
Error: Failed to open PDF file: 
Errors encountered.  No output created.
Done.  Input errors, so no output created.

If I add more files to that operation I just get the error for each of them.

I can rename the PDFs from the command line mv 2017.pdf foo.pdf and I get the same error. Error: Unexpected Exception in open_reader() java.io.FileNotFoundException: foo.pdf (Permission denied)

If I try to call a non-existent file, eg. pdftk 123.pdf cat output test.pdf I get a different error:

Error: Unable to find file.
Error: Failed to open PDF file: 
Errors encountered.  No output created.
Done.  Input errors, so no output created.

Even tail 2017.pdf shows the last few lines of 2017.pdf:

/Info 63 0 R
/ID [<cc59759cedaf07420bbe3250ba5d8971><f259ad128310d106c7aa80b673c4bd70>]
/Root 62 0 R
/Size 64

If I can see the file and read it with tail, why would pdftk not be able to read it?

  • That seems very strange. Could you just confirm that you get the same issue if you rename the file to foo.pdf or something, just in case there's a weird bug in pdftk that makes it fail on that filename? I really doubt it will help, but you never know... – terdon Aug 4 '19 at 17:32
  • Tried renaming and copying. Still getting the error. – Amanda Aug 4 '19 at 17:37
  • Hang on, do you have the necessary permissions to all parent directories? Could you have changed the permissions of a parent after having cded into the target dir? Do you get the same issue if you copy your file to your $HOME? – terdon Aug 4 '19 at 17:43
  • Guess: Something is messed up between pdftk and the Java libraries it uses. Try to update both to the newest versions with your package manager. If you have multiple versions of Java installed, try to get rid of the oldest ones. – dirkt Aug 4 '19 at 17:45
  • 1
    @terdon Works fine when I move them to my desktop, so that's a fix. The initial directory is a separate ext4 partition that I created for Dropbox to sync to, but I can do other command line work in that directory just fine. – Amanda Aug 4 '19 at 17:47


Snaps access right management appears to be the source of the issue.

To solve this, you can either:

  • Do your work from your $HOME folder. Note that symlinks will not work.
  • Install pdftk from another source than the one of your distribution. For instance, ppa:malteworld/ppa has version 3.0.0 of pdftk-java.

Original reply

I am having the same issue. I was doing it from a folder on a USB drive. And indeed, doing this from a subfolder of my home directory works.

That puzzled me as I tried to do it from a subfolder under /tmp and it did not work neither (with a different error, less verbose, "Failed to open PDF file"). Same if I try from a subfolder on a secondary disk mounted under /mnt.

I suspect it could be related to limitation with snaps (I am on an up-to-date Ubuntu 18.04.3). But I have very little experience dealing with snaps, so I cannot explore further.

If so, that would be quite broken as that prevent Ubuntu users from using pdftk from anywhere else than their home folder. Eg. a USB drive, a extra disk, a shared network drive.

(sorry I could not reply as comment, not enough reputation...)

  • 1
    Welcome to the site. Please elaborate why you suspect that the Ubuntu Snaps are the reason of this issue, so that other readers may use this as a starting point for further investigations. – AdminBee Nov 8 '19 at 12:18
  • 2
    I suspect that because on this Ubuntu version pdftk comes as a snap, and snaps main point of interest is their focus on extra application security by sandboxing and isolation with least-privilege paradigm. It notably uses AppArmor, namespace, etc. to achieve that. And strange permission errors like the ones encountered here could be symptomatic of a too restrictive rule with one of those security subsystems. – AxelVoitier Nov 12 '19 at 10:52
  • 1
    Not sure if it is pdftk or Ubuntu's snaps, but the issue is exactly that one needs to copy the file in home to do the pdftk work on it. This is quite obnoxius – Davide Jan 2 '20 at 18:49
  • 3
    I believe this error should between pdftk and snap too, I have the same problem here, I tried on /tmp, using links, files in other homedir and other partitions and only works on $HOME and subdirs. So I solved my case, installed pdftk via ppa: malteworld / ppa repository them works fine. – SauloAlessandre Jan 14 '20 at 2:59
  • 2
    Thanks, that helped me too. I will never ever use snap again. – Kjeld Flarup Feb 11 '20 at 22:03

Snap seems to limit access to the filesystem.

Worked for me when I moved the files to $HOME (not /tmp or somewhere else)


For a file on a different drive than /snap, the solution that worked for me was to extend pdftk access to removable media:

snap connect pdftk:removable-media
  • error: snap "pdftk" has no plug named "removable-media". – Regis May Mar 14 at 20:52

Another solution is posted here: https://github.com/smoser/pdftk/issues/7#issuecomment-479782445

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

It's simpler but does require sudo permissions. This worked for me on Ubuntu 18.04.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.