Julien,

Unfortunately the documents are from a business partner of a client; had I
created them myself I most certainly would not have protected them :) I've
looked in my keychain and I have no related credentials.  When viewing the
file in both Preview and Skim, a password is not prompted for, the document
is displayed in its entirety, and the document's properties show "Encrypted"
as "Yes".

If I attempt to just go ahead and strip the text out using PDFTextStripper,
ie catch-and-ignore any exceptions arising from decryption, I still get

Caused by: org.apache.pdfbox.exceptions.WrappedIOException: Error decrypting
document, details:
at
org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:250)
at org.apache.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:184)
... 24 more
Caused by: org.apache.pdfbox.exceptions.CryptographyException: Error: The
supplied password does not match either the owner or user password in the
document.
at
org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:231)
at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1111)
at org.apache.pdfbox.pdmodel.PDDocument.decrypt(PDDocument.java:591)
at
org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:246)
... 25 more

The encryption dictionary is as follows (I omitted the user and owner
strings):
132 0 obj<</R 4/Length 128/Filter/Standard/O(...)/P -1324/U(...)/V
4/CF<</StdCF<</Length
16/CFM/V2/AuthEvent/DocOpen>>>>/StmF/StdCF/StrF/StdCF/EncryptMetadata
false>>
endobj

Thanks again,

Gary

On Fri, Aug 27, 2010 at 2:45 PM, Julien Plée <[email protected]> wrote:

> Hello Gary,
>
> You may try to open it in an other free reader not based on the MacOS
> library.
> Either I would think that:
> 1) you stored the password in keychain
> Or 2) you didn't protect the documents
>
> Regards,
>
> Julien
>
>
>
>
>  Hello all,
>>
>> I have a collection of PDFs I'm extracting text from programmatically, and
>> some of them are encrypted.  All of them can be opened in OS X's Preview
>> without supplying a password, but when decrypting with PDFBox, a small
>> portion of result in an exception on decryption:
>>
>> Exception in thread "main"
>> org.apache.pdfbox.exceptions.CryptographyException: Error: The supplied
>> password does not match either the owner or user password in the document.
>> at
>>
>> org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:231)
>> at
>> org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1111)
>> ...
>>
>> This happens both with
>>
>> doc.openProtection(new StandardDecryptionMaterial(""));
>>
>> and
>>
>> doc.decrypt("");
>>
>> (not that I'm sure there's a difference).  Is there some magic that
>> Preview
>> is doing to decrypt the document, or am I just hosed?  Any help would be
>> greatly appreciated.  Thanks!
>>
>> Gary LosHuertos
>> Arc90
>>
>

Reply via email to