Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pdftk can't open pdf file

5,533 views
Skip to first unread message

firsttimelinux

unread,
Feb 22, 2009, 3:37:46 AM2/22/09
to
I've been using pdftk from the command line to remove the password
protection on some pdfs, just to stop kpdf from asking for the password
every time I want to open it. And this works fine. Now I've been given
some different pdfs, also password protected, but my pdftk trick doesn't
work here, it just says this:
pdftk blah.pdf input_pw blah output blah2.pdf
Error: Failed to open PDF file:
blah.pdf
Errors encountered. No output created.
Done. Input errors, so no output created.

Note that this ISN'T the same error it gives when I get the password
wrong - on the files where this command works, if I get the password
wrong it says "OWNER PASSWORD REQUIRED, but not given (or incorrect)" -
so that isn't the problem with these files. And as I said I can open
the pdf in kpdf without problems, so I know the password is correct.

I also tried pdf2ps, but just got an "unrecoverable error":
pdf2ps -sPDFPassword=blah blah.pdf
Error: /ioerror in --.reusablestreamdecode--
Additional information: (\2113B\267\\'\006\b|'\006\b\fW\005\b\370\002)
Operand stack:
... and then a load of other stuff from the internals of ghostscript?

I saw a report where pdftk has a problem with umlauts in the filenames,
but this isn't the case here - I really did rename it to blah.pdf and
there are no funny characters in the path.

System: Mandriva linux, pdftk 1.41

Any clues? Thanks!

Bruno Lowagie

unread,
Feb 22, 2009, 4:18:34 AM2/22/09
to
firsttimelinux wrote:
> I've been using pdftk from the command line to remove the password
> protection on some pdfs, just to stop kpdf from asking for the password
> every time I want to open it. And this works fine. Now I've been given
> some different pdfs, also password protected, but my pdftk trick doesn't
> work here, it just says this:
> pdftk blah.pdf input_pw blah output blah2.pdf
> Error: Failed to open PDF file:
> blah.pdf
> Errors encountered. No output created.
> Done. Input errors, so no output created.
>
> Note that this ISN'T the same error it gives when I get the password
> wrong - on the files where this command works, if I get the password
> wrong it says "OWNER PASSWORD REQUIRED, but not given (or incorrect)" -
> so that isn't the problem with these files. And as I said I can open
> the pdf in kpdf without problems, so I know the password is correct.

You (should) know that Pdftk is nothing more than a very old version of
iText (a Java-PDF library) compiled with GCJ and extended with some
command line functionality.

The keywords in the above statement are "VERY OLD". The iText version
that was used to create Pdftk only supported standard encryption
(Alleged RC4); it didn't support AES encryption (yet).

Maybe the PDFs causing you trouble are encrypted using the AES
algorithm. That would explain why you can open them with newer tools,
but not with the (discontinued?) Pdftk tool.

Why do I think Pdftk is discontinued? The last thing I heard from Sid
Steward (the developer responsible for Pdftk) is that he had inherited
his father's business and that he wouldn't work on Pdftk anymore.
As Pdftk has a huge dependency on iText, all other companies who'd like
to continue developing business using Pdftk should be in touch with
iText Software LLC: http://itextsoftware.com/
And iText Software LLC has no business relationship with any other
company with respect to Pdftk, so I assume there are no other companies
working on Pdftk.

Bruno Lowagie

unread,
Feb 22, 2009, 4:18:56 AM2/22/09
to
firsttimelinux wrote:
> I've been using pdftk from the command line to remove the password
> protection on some pdfs, just to stop kpdf from asking for the password
> every time I want to open it. And this works fine. Now I've been given
> some different pdfs, also password protected, but my pdftk trick doesn't
> work here, it just says this:
> pdftk blah.pdf input_pw blah output blah2.pdf
> Error: Failed to open PDF file:
> blah.pdf
> Errors encountered. No output created.
> Done. Input errors, so no output created.
>
> Note that this ISN'T the same error it gives when I get the password
> wrong - on the files where this command works, if I get the password
> wrong it says "OWNER PASSWORD REQUIRED, but not given (or incorrect)" -
> so that isn't the problem with these files. And as I said I can open
> the pdf in kpdf without problems, so I know the password is correct.

You (should) know that Pdftk is nothing more than a very old version of

firsttimelinux

unread,
Feb 22, 2009, 6:22:37 AM2/22/09
to
Thanks for the reply!
Two more questions then - how do I check whether my files are encrypted
with AES (to see whether that really is the problem) ? And is there any
other tool which _can_ deal with such pdfs, which can remove the
password protection?


Bruno Lowagie wrote:
> ... The iText version

Bruno Lowagie

unread,
Feb 22, 2009, 12:47:02 PM2/22/09
to
firsttimelinux wrote:
> Thanks for the reply!
> Two more questions then - how do I check whether my files are encrypted
> with AES (to see whether that really is the problem) ? And is there any
> other tool which _can_ deal with such pdfs, which can remove the
> password protection?

This is a copy paste of the encryption dictionary of a PDF encrypted
with AES encryption:
<<
/StrF/StdCF
/CF <<
/StdCF <<
/CFM/AESV2
/AuthEvent/DocOpen
/Length 16
>>
>>
/StmF/StdCF
/U (xxxxxx)
/O (xxxxxx)
>>

This is an example of the encryption dictionary of a PDF encrypted with
the Standard Encryption:
<<
/Length 128
/V 2
/P -1852
/Filter/Standard
/R 3
/U (xxxxxx)
/O (xxxxxx)
>>

Try finding the encryption dictionary in your PDFs.
Normally, you'll find a reference to the Encryption dictionary in the
catalog (root) of the PDF. Something like this: /Encrypt 7 0 R

firsttimelinux

unread,
Feb 22, 2009, 2:04:34 PM2/22/09
to
It looks like you're right - I opened it up in KHexedit and searched for
AES, and found this:
<</CF<</StdCF<</AuthEvent/DocOpen/CFM/AESV2/Length 16>>

But if I do the same with one of the pdfs which work, it doesn't contain
AES at all.

So you're right, it looks like it is the AES causing the problem, now is
there any other tool around which can handle these kinds of pdf?

Thanks!

Bruno Lowagie wrote:
> This is a copy paste of the encryption dictionary of a PDF encrypted
> with AES encryption:

...

Bruno Lowagie

unread,
Feb 23, 2009, 3:05:17 AM2/23/09
to
firsttimelinux wrote:
> It looks like you're right - I opened it up in KHexedit and searched for
> AES, and found this:
> <</CF<</StdCF<</AuthEvent/DocOpen/CFM/AESV2/Length 16>>
>
> But if I do the same with one of the pdfs which work, it doesn't contain
> AES at all.
>
> So you're right, it looks like it is the AES causing the problem, now is
> there any other tool around which can handle these kinds of pdf?

Sorry, I only focus on iText and iText related products.
But you're probably not looking for a Java / C# solution.

Tim Arnold

unread,
Feb 23, 2009, 12:40:09 PM2/23/09
to
"firsttimelinux" <firstti...@yahoo.com> wrote in message
news:gns7k3$3u2$1...@news.motzarella.org...

You might try multivalent:
http://multivalent.sourceforge.net/Tools/pdf/Decrypt.html

--Tim Arnold


John Whitington

unread,
Feb 24, 2009, 3:44:48 AM2/24/09
to
Hi.

On Feb 22, 7:04 pm, firsttimelinux <firsttimeli...@yahoo.com> wrote:
> It looks like you're right - I opened it up in KHexedit and searched for
> AES, and found this:
> <</CF<</StdCF<</AuthEvent/DocOpen/CFM/AESV2/Length 16>>
>
> But if I do the same with one of the pdfs which work, it doesn't contain
> AES at all.
>
> So you're right, it looks like it is the AES causing the problem, now is
> there any other tool around which can handle these kinds of pdf?

Not free: http://www.coherentpdf.com/

cpdf in.pdf owner=mypassword -o out.pdf

I normally recommend pdftk for free stuff, so I've not looked further
than that.

ghostscript should be able to do it, though, by specifying the output
device as PDF and giving the password on the command line. Try "man
gs".

firsttimelinux

unread,
Feb 24, 2009, 4:09:37 AM2/24/09
to
Thanks for the tip!

That Decrypt works for the ones which pdftk can handle, but fails for
the AES ones with the message: "invalid OWNER password". I hadn't quite
appreciated the difference between the owner and user passwords before.
I know the password for kpdf so I can read it, but it looks like I
don't know the owner password.

I also tried the "Merge" to join pdfs together (as I have done with
pdftk) but that fails for both kinds of pdf.

Oh well. :/

firsttimelinux

unread,
Feb 24, 2009, 5:53:55 AM2/24/09
to
Thanks!
I tried man gs but I couldn't find any way to enter the password - the
command line just fails with "invalidfileaccess in pdf_process_Encrypt"
without giving me a chance to enter the password - and there's no
mention of passwords in the man page.

Anyway, fortunately I found the (or an) answer - and it was much easier
than I thought! I just opened the pdfs in kpdf, entered the password,
and then printed them to a new pdf file. Simple!
From then on the new file is unprotected so I can use pdftk to merge
them / whatever.

Problem solved! :)

0 new messages