I compared the properties in the files using Acrobat Reader DC.  The only 
difference I can see between the files is the latest version has "Creation of 
Template Pages"  set to Not Allowed.    In the draft versions of the document 
it was set to Allowed.   Not sure if this is the issue but the rest of the 
Security setting are the same.  The draft versions of the PDF file worked 
great.    

      From: Rodney Kite <[email protected]>
 To: "[email protected]" <[email protected]> 
 Sent: Tuesday, September 29, 2015 12:52 PM
 Subject: Re: trouble decrypting pdf when using loadNonSeq
   
I do not believe the file is encrypted. I am getting my output in the PDF 
except I get the error and the PDF is not editable.   I tried loadNonSeq with a 
blank password and no password but it did not help.   PDFBox worked great on 
the draft versions of the document but for some reason the final version of the 
document has the error.   

   I can open the  document with Acrobat Reader edit the fields and save it 
with no issues.  If I fill it out with my application using PDFBox I get the 
error and the document becomes un-editable.    

      From: Andreas Lehmkuehler <[email protected]>


 To: [email protected] 
 Sent: Tuesday, September 29, 2015 12:14 PM
 Subject: Re: trouble decrypting pdf when using loadNonSeq
  
Am 29.09.2015 um 18:08 schrieb Gilad Denneboom:
> If you don't know the password then obviously you can't decrypt the file...
> That's the point of the security policy that was applied to it.
Are you able to open the pdf using any other pdf reader? If the answer is yes, 
the password is most likely "". I agree with Gilad, if the answer is no.

BR
Andreas

>
> On Tue, Sep 29, 2015 at 5:58 PM, Rodney Kite <[email protected]>
> wrote:
>
>> No,  Where would I get the password?  Its a government document.
>>
>>        From: Andreas Lehmkuehler <[email protected]>
>>  To: [email protected]
>>  Sent: Tuesday, September 29, 2015 11:48 AM
>>  Subject: Re: trouble decrypting pdf when using loadNonSeq
>>
>> Hi,
>>
>> Am 29.09.2015 um 13:17 schrieb Toel Hartmann:
>>> Hi,
>>>
>>> I am trying to decrypt a pdf from a customer using pdfbox and loadNonSeq:
>>
>> Did you ever try to pass the password by using
>>
>> loadNonSeq(File file, RandomAccess scratchFile, String password)
>>
>> BR
>> Andreas
>>
>>
>>
>>>
>>> In Acrobat the pfd (I could send a private link to the file) is reported
>> as “Password Security”:
>>> Security Method: Password Security
>>> Document Open Password: No
>>> Permissions Password: Yes
>>> Printing: High Resolution
>>> Changing the Document: Not Allowed
>>> Commenting: Not Allowed
>>> Form Field Fill-in or Signing: Not Allowed
>>> Document Assembly: Not Allowed
>>> Content Copying: Allowed
>>> Content Accessibility Enabled: Allowed
>>> Page Extraction: Not Allowed
>>> Encryption Level: High (128-bit AES)
>>>
>>> but when using the code:
>>>
>>>            File scratchFile = File.createTempFile("m3_", null);
>>>          FileInputStream fis = null;
>>>          PDDocument doc = null;
>>>          try {
>>>
>>>              RandomAccessFile scratch = new
>> RandomAccessFile(scratchFile, "rw");
>>>              fis = new FileInputStream("build/test/file02.pdf");
>>>              doc = PDDocument.loadNonSeq(fis, scratch);
>>>              if (doc.isEncrypted()) {
>>>                  System.out.println("Pdf is encrypted!!!");
>>>                  StandardDecryptionMaterial sdm = new
>> StandardDecryptionMaterial(THEPASSWORD);
>>>                  doc.openProtection(sdm);
>>>                  doc.save("build/test/file02_decrypted.pdf");
>>>              }
>>>          } catch (Exception e) {
>>>              e.printStackTrace(System.err);
>>>          } finally {
>>>              if (doc!=null) doc.close();
>>>              if (fis!=null) fis.close();
>>>              scratchFile.delete();
>>>          }
>>>
>>> using pdfbox 1.8.10 on osx running java 1.8.0_31 I got:
>>>
>>>
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:372)
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:476)
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:434)
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:404)
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:222)
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
>>>      at
>> org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1609)
>>> ...
>>> Caused by: javax.crypto.IllegalBlockSizeException: Input length must be
>> multiple of 16 when decrypting with padded cipher
>>>      at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:913)
>>>      at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:824)
>>>      at
>> com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:436)
>>>      at javax.crypto.Cipher.doFinal(Cipher.java:2004)
>>>      at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:352)
>>>      ... 32 more
>>>
>>>
>>> If I change to  doc = PDDocument.load(fis);
>>> similar to the code found in Decrypt.java then it is working fine.
>>>
>>>
>>> /Toël
>>>
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]


>>
>>
>>
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





  

Reply via email to