You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Beard, Brian" <Br...@mybir.com> on 2008/11/10 17:33:38 UTC

extract text from encrypted document with extract perrmissions

I have a pdf file I'm able to view through acrobat viewer but not
extract the text of through pdfBox.

 

It is encrypted, but the permission to extractContent is enabled.

 

It gives the following error:

org.pdfbox.exceptions.CryptographyException: Error: The supplied
password does not match either the owner or user password in the
document.

      at
org.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(St
andardSecurityHandler.java:230)

      at
org.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:907)

      at org.pdfbox.ExtractText.main(ExtractText.java:205)

 

 

In extractText, this happens in the openProtection call. 

 

                //document.print();

                if( document.isEncrypted() )

                {

                    StandardDecryptionMaterial sdm = new
StandardDecryptionMaterial( password );                    

                    document.openProtection( sdm );

                    AccessPermission ap =
document.getCurrentAccessPermission();

                    

                    if( ! ap.canExtractContent() ) 

                    {

                        throw new IOException( "You do not have
permission to extract text" );

                    }

                }

                if( toConsole )

 

Can anyone shed some light on this? Should the document need to be
decrypted if permissions are set to extract the content? (At least when
I view the properties through the acrobat viewer they are set to content
extraction enabled).