pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barry Zhao [Zhao]" <zhaz...@tibco-support.com>
Subject PDFBOX-2469 still have problem while decrypting a pdf file
Date Tue, 30 Dec 2014 02:15:07 GMT
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

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message