1

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: 
   2017.pdf
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: 
   123.pdf
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
>>
startxref
42883
%%EOF

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 at 17:32
  • Tried renaming and copying. Still getting the error. – Amanda Aug 4 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 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 at 17:45
  • @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 at 17:47

Your Answer

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

Browse other questions tagged or ask your own question.