Hi,

Am 30.12.2014 um 10:08 schrieb Tilman Hausherr:
Hi,

Please try loadNonSeq(file,null).

Nevertheless you are correct, it doesn't work with the "old" parser. What's even
weirder is that there seem to be several of these i-9 forms. The first one from
PDFBOX-2469 works, the one you attached (it landed in moderation) doesn't.

And then there's the second one in PDFBOX-2469, that doesn't work either. The
text at the end of PDFBOX-2469 is somewhat unclear, but it seems we didn't solve
them all.
The fix in PDFBOX-2469 is limited to the non-sequential parser and IMO the comments are clear about that.

Tilman


BR
Andreas Lehmkühler



Am 30.12.2014 um 03:15 schrieb Barry Zhao [Zhao]:
Hi team,

I see that the PDFBox has staged out new release 1.8.8, so I just try to use
the new version.
When I decrypt a PDF file which is decrypted, I got the exception bellow:

org.apache.pdfbox.exceptions.WrappedIOException
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:375)

at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptString(SecurityHandler.java:577)

at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:429)

at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptDictionary(SecurityHandler.java:530)

at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:437)

at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:403)

at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:221)

at
org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)

at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1601)
at Testpdf10.main(Testpdf10.java:44)
Caused by: javax.crypto.BadPaddingException: Given final block not properly
padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:1969)
at
org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:351)

... 9 more

And my code is :
PDDocument doc = PDDocument.load(originFile);
if (doc.isEncrypted())
{
try
{
DecryptionMaterial dm = new StandardDecryptionMaterial("");
doc.openProtection(dm);
doc.setAllSecurityToBeRemoved(true);
}
catch (Exception cre) {
cre.printStackTrace();
}
}

I use the attachment file to do the operation.


I found this
http://stackoverflow.com/questions/26963718/badpaddingexception-when-decrypting-with-pdfbox
in stackoverflow.
I tried by the advices and it still not work.
So I post this email to you. Hope to get your answer.

Best wishes,
Barry



Reply via email to