You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil> on 2016/04/08 15:09:19 UTC

RE: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

"That means you bypassed the problem instead of confronting and solving it."
True..

I did as you suggested:
"PDDocument doc = PDDocument.loadNonSeq(new File(...));"

It did not work on the file below.

https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc

The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.

Try the one in the link.

Thank you for your help.

Mark....


-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Thursday, April 07, 2016 12:39 PM
To: users@pdfbox.apache.org
Subject: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
> Hello all,
>
> I hacked my way around it. Used my old software to save the pdf with security removed.
> Then did the explorer save to adobe trick.

That means you bypassed the problem instead of confronting and solving it.


Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.

Tilman

>
> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>
>
> public void setValue(String optionValue) throws IOException
>      {
>      	//TODO - in the instance where an option list doesn't have a default option
>          //We need to allow for the case where no selection was made.
>          //When reading a blank form, the value returned to us is null. The current code
>          //does not handle the possibility of a choice field not being set.
>          if(optionValue==null||optionValue.equalsIgnoreCase(""))
>          {
>              super.setValue("");
>              return;
>          }
>          
>          int indexSelected = -1;
>          COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>          int fieldFlags = getFieldFlags();
>          boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
> (FLAG_EDIT & fieldFlags) != 0;
>
>          if (options.size() == 0 && !isEditable)
>          {
>              throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>          }
>          else
>          {
>              // YXJ: Changed the order of the loops. Acrobat produces PDF's
>              // where sometimes there is 1 string and the rest arrays.
>              // This code works either way.
>              for (int i = 0; i < options.size() && indexSelected == -1; i++)
>              {
>                  COSBase option = options.getObject(i);
>                  if (option instanceof COSArray)
>                  {
>                      COSArray keyValuePair = (COSArray) option;
>                      COSString key = (COSString) keyValuePair.getObject(0);
>                      COSString value = (COSString) keyValuePair.getObject(1);
>                      if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>                      {
>                          // have the parent draw the appearance stream with the value
>                          if ((FLAG_COMBO & fieldFlags) != 0)
>                          {
>                              super.setValue(value.getString());
>                          }
>                          else
>                          {
>                              COSArray indexEntries = new COSArray();
>                              indexEntries.add(COSInteger.get((long) i));
>                              getDictionary().setItem(COSName.I, indexEntries);
>                              setListboxValue(value.getString());
>                          }
>                          // but then use the key as the V entry
>                          getDictionary().setItem(COSName.V, key);
>                          indexSelected = i;
>
>                      }
>                  }
>                  else
>                  {
>                      COSString value = (COSString) option;
>                      if (optionValue.equals(value.getString()))
>                      {
>                          super.setValue(optionValue);
>                          indexSelected = i;
>                      }
>                  }
>              }
>          }
>          if (indexSelected == -1 && isEditable)
>          {
>              super.setValue(optionValue);
>          }
>          else if (indexSelected == -1)
>          {
>              throw new IOException("Error: '" + optionValue + "' was not an available option.");
>          }
>          else
>          {
>              COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>              if (indexArray != null)
>              {
>                  indexArray.clear();
>                  indexArray.add(COSInteger.get(indexSelected));
>              }
>          }
>      }
>
>
> V/R,
> Mark Strein
>
> TRAC-FLVN
> Wargaming and Simulations Directorate
> Analytic Tools Division - Paving Crew
> Keeper of the Codes
> 913-684-9309
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil>.
Tilman,
" If you use loadNonSeq there is no need to call openProtection()."
That did the trick. 
Thanks

Mark....

-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Saturday, April 09, 2016 1:22 AM
To: users@pdfbox.apache.org
Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
> Ok,
> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
>
> This is what I get:
> With pdfbox 1.8.11
> Apr 08, 2016 12:46:59 PM 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: 
> ./Forms/A3161_Blank.pdf
> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
> 	at 
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
> ityHandler.java:348)
>
>
> And you are using:
> File originalPDF = new File(pdfFileName);
>              	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                  pdDocument = PDDocument.loadNonSeq(originalPDF, 
> raFile);
>
>                  boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                  if (isOriginalDocEncrypted)
>                  {
>                  	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                  }
>                  pdDocumentCatalog = pdDocument.getDocumentCatalog();
>                  
>                  pdAcroForm = pdDocumentCatalog.getAcroForm();
>
> Yes?

If you use loadNonSeq there is no need to call openProtection().

And I didn't use a scratch file at all.


>
> Tilman,
> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also.
> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields.
> As it stands now, I am not getting any further than:
> pdDocument.openProtection(new StandardDecryptionMaterial(""));

I'm using PDFReader because I have the source code. So if I can work with PDFReader it means that some source code exists to open the file.

With 1.8.11 it works with both normal and nonSeq parser.
With 1.8.10 only the nonSeq parser works.

Tilman

>
> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
>
> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
> javax.crypto.IllegalBlockSizeException: Input length must be multiple 
> of 16 when decrypting with padded cipher
>
> Mark....
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Friday, April 08, 2016 12:22 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: 
> org.apache.pdfbox.exceptions.WrappedIOException
>
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>
>
>
>
> ----
>
> I just tried it with 1.8.10 and it works fine:
>
>   >java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
> Apr 08, 2016 7:19:27 PM
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM 
> org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 
> PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 
> PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: EMC
>
> and the file is displayed.
>
> Maybe you still have the old files in your classpath.
> And the current  version is 1.8.11. Not 1.8.10.
>
> Tilman
>
> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Tilman interesting,
>>
>> This is what I get:
>>
>> Apr 08, 2016 11:42:31 AM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file:
>> ./Forms/A3161_Blank.pdf 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)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secu
>> r
>> ityHandler.java:352)
>>
>> Here is my code when using pdfbox-1.8.10-src:
>>               	File originalPDF = new File(pdfFileName);
>>               	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>                   pdDocument = PDDocument.loadNonSeq(originalPDF,
>> raFile);
>>
>>                   boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>                   if (isOriginalDocEncrypted)
>>                   {
>>                   	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>                   }
>>                   pdDocumentCatalog = 
>> pdDocument.getDocumentCatalog();
>>                   
>>                   pdAcroForm = pdDocumentCatalog.getAcroForm();
>>
>>
>>
>>
>> You used Java 1.7.0
>> With
>> Pdfbox-1.8.6(source),
>> bcmail-jdk15-1.44.jar,
>> bcprov-jdk15-1.44.jar,
>> commons-logging-1.1.2.jar,
>> fontbox-1.8.6.jar,
>> jempbox-1.8.6.jar
>>
>> the above code base opens this file:
>>     Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>>
>>
>> The code base below will not open it:
>> Java 8,
>> pdfbox-1.8.10-src
>> bcmail-jdk16-1.46.jar
>> bcprov-jdk16-1.46.jar
>> commons-logging-1.1.2.jar
>> fontbox-1.8.10.jar
>> jempbox-1.8.10.jar
>> icu4j.jar
>>
>>
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 10:52 AM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update:
>> org.apache.pdfbox.exceptions.WrappedIOException
>>
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>>
>>
>>
>>
>> ----
>>
>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>>
>> Tilman
>>
>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> "That means you bypassed the problem instead of confronting and solving it."
>>> True..
>>>
>>> I did as you suggested:
>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>>
>>> It did not work on the file below.
>>>
>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3
>>> c
>>> xaHczWXc
>>>
>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>>
>>> Try the one in the link.
>>>
>>> Thank you for your help.
>>>
>>> Mark....
>>>
>>>
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>>> Sent: Thursday, April 07, 2016 12:39 PM
>>> To: users@pdfbox.apache.org
>>> Subject: [Non-DoD Source] Re: Update:
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>>
>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> Hello all,
>>>>
>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>> Then did the explorer save to adobe trick.
>>> That means you bypassed the problem instead of confronting and solving it.
>>>
>>>
>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>>
>>> Tilman
>>>
>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>>
>>>>
>>>> public void setValue(String optionValue) throws IOException
>>>>         {
>>>>         	//TODO - in the instance where an option list doesn't have a default option
>>>>             //We need to allow for the case where no selection was made.
>>>>             //When reading a blank form, the value returned to us is null. The current code
>>>>             //does not handle the possibility of a choice field not being set.
>>>>             if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>             {
>>>>                 super.setValue("");
>>>>                 return;
>>>>             }
>>>>             
>>>>             int indexSelected = -1;
>>>>             COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>             int fieldFlags = getFieldFlags();
>>>>             boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>>
>>>>             if (options.size() == 0 && !isEditable)
>>>>             {
>>>>                 throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>             }
>>>>             else
>>>>             {
>>>>                 // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>                 // where sometimes there is 1 string and the rest arrays.
>>>>                 // This code works either way.
>>>>                 for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>                 {
>>>>                     COSBase option = options.getObject(i);
>>>>                     if (option instanceof COSArray)
>>>>                     {
>>>>                         COSArray keyValuePair = (COSArray) option;
>>>>                         COSString key = (COSString) keyValuePair.getObject(0);
>>>>                         COSString value = (COSString) keyValuePair.getObject(1);
>>>>                         if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>                         {
>>>>                             // have the parent draw the appearance stream with the value
>>>>                             if ((FLAG_COMBO & fieldFlags) != 0)
>>>>                             {
>>>>                                 super.setValue(value.getString());
>>>>                             }
>>>>                             else
>>>>                             {
>>>>                                 COSArray indexEntries = new COSArray();
>>>>                                 indexEntries.add(COSInteger.get((long) i));
>>>>                                 getDictionary().setItem(COSName.I, indexEntries);
>>>>                                 setListboxValue(value.getString());
>>>>                             }
>>>>                             // but then use the key as the V entry
>>>>                             getDictionary().setItem(COSName.V, key);
>>>>                             indexSelected = i;
>>>>
>>>>                         }
>>>>                     }
>>>>                     else
>>>>                     {
>>>>                         COSString value = (COSString) option;
>>>>                         if (optionValue.equals(value.getString()))
>>>>                         {
>>>>                             super.setValue(optionValue);
>>>>                             indexSelected = i;
>>>>                         }
>>>>                     }
>>>>                 }
>>>>             }
>>>>             if (indexSelected == -1 && isEditable)
>>>>             {
>>>>                 super.setValue(optionValue);
>>>>             }
>>>>             else if (indexSelected == -1)
>>>>             {
>>>>                 throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>             }
>>>>             else
>>>>             {
>>>>                 COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>                 if (indexArray != null)
>>>>                 {
>>>>                     indexArray.clear();
>>>>                     indexArray.add(COSInteger.get(indexSelected));
>>>>                 }
>>>>             }
>>>>         }
>>>>
>>>>
>>>> V/R,
>>>> Mark Strein
>>>>
>>>> TRAC-FLVN
>>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>>> Paving Crew Keeper of the Codes
>>>> 913-684-9309
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> -
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil>.
Tilman,

Ah....
"If you use loadNonSeq there is no need to call openProtection()."
Ok, I will give that a try.
Thanks.

Mark.....

-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Saturday, April 09, 2016 1:22 AM
To: users@pdfbox.apache.org
Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
> Ok,
> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
>
> This is what I get:
> With pdfbox 1.8.11
> Apr 08, 2016 12:46:59 PM 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: 
> ./Forms/A3161_Blank.pdf
> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
> 	at 
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
> ityHandler.java:348)
>
>
> And you are using:
> File originalPDF = new File(pdfFileName);
>              	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                  pdDocument = PDDocument.loadNonSeq(originalPDF, 
> raFile);
>
>                  boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                  if (isOriginalDocEncrypted)
>                  {
>                  	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                  }
>                  pdDocumentCatalog = pdDocument.getDocumentCatalog();
>                  
>                  pdAcroForm = pdDocumentCatalog.getAcroForm();
>
> Yes?

If you use loadNonSeq there is no need to call openProtection().

And I didn't use a scratch file at all.


>
> Tilman,
> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also.
> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields.
> As it stands now, I am not getting any further than:
> pdDocument.openProtection(new StandardDecryptionMaterial(""));

I'm using PDFReader because I have the source code. So if I can work with PDFReader it means that some source code exists to open the file.

With 1.8.11 it works with both normal and nonSeq parser.
With 1.8.10 only the nonSeq parser works.

Tilman

>
> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
>
> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
> javax.crypto.IllegalBlockSizeException: Input length must be multiple 
> of 16 when decrypting with padded cipher
>
> Mark....
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Friday, April 08, 2016 12:22 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: 
> org.apache.pdfbox.exceptions.WrappedIOException
>
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>
>
>
>
> ----
>
> I just tried it with 1.8.10 and it works fine:
>
>   >java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
> Apr 08, 2016 7:19:27 PM
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM 
> org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 
> PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 
> PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: EMC
>
> and the file is displayed.
>
> Maybe you still have the old files in your classpath.
> And the current  version is 1.8.11. Not 1.8.10.
>
> Tilman
>
> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Tilman interesting,
>>
>> This is what I get:
>>
>> Apr 08, 2016 11:42:31 AM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file:
>> ./Forms/A3161_Blank.pdf 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)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secu
>> r
>> ityHandler.java:352)
>>
>> Here is my code when using pdfbox-1.8.10-src:
>>               	File originalPDF = new File(pdfFileName);
>>               	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>                   pdDocument = PDDocument.loadNonSeq(originalPDF,
>> raFile);
>>
>>                   boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>                   if (isOriginalDocEncrypted)
>>                   {
>>                   	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>                   }
>>                   pdDocumentCatalog = 
>> pdDocument.getDocumentCatalog();
>>                   
>>                   pdAcroForm = pdDocumentCatalog.getAcroForm();
>>
>>
>>
>>
>> You used Java 1.7.0
>> With
>> Pdfbox-1.8.6(source),
>> bcmail-jdk15-1.44.jar,
>> bcprov-jdk15-1.44.jar,
>> commons-logging-1.1.2.jar,
>> fontbox-1.8.6.jar,
>> jempbox-1.8.6.jar
>>
>> the above code base opens this file:
>>     Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>>
>>
>> The code base below will not open it:
>> Java 8,
>> pdfbox-1.8.10-src
>> bcmail-jdk16-1.46.jar
>> bcprov-jdk16-1.46.jar
>> commons-logging-1.1.2.jar
>> fontbox-1.8.10.jar
>> jempbox-1.8.10.jar
>> icu4j.jar
>>
>>
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 10:52 AM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update:
>> org.apache.pdfbox.exceptions.WrappedIOException
>>
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>>
>>
>>
>>
>> ----
>>
>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>>
>> Tilman
>>
>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> "That means you bypassed the problem instead of confronting and solving it."
>>> True..
>>>
>>> I did as you suggested:
>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>>
>>> It did not work on the file below.
>>>
>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3
>>> c
>>> xaHczWXc
>>>
>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>>
>>> Try the one in the link.
>>>
>>> Thank you for your help.
>>>
>>> Mark....
>>>
>>>
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>>> Sent: Thursday, April 07, 2016 12:39 PM
>>> To: users@pdfbox.apache.org
>>> Subject: [Non-DoD Source] Re: Update:
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>>
>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> Hello all,
>>>>
>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>> Then did the explorer save to adobe trick.
>>> That means you bypassed the problem instead of confronting and solving it.
>>>
>>>
>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>>
>>> Tilman
>>>
>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>>
>>>>
>>>> public void setValue(String optionValue) throws IOException
>>>>         {
>>>>         	//TODO - in the instance where an option list doesn't have a default option
>>>>             //We need to allow for the case where no selection was made.
>>>>             //When reading a blank form, the value returned to us is null. The current code
>>>>             //does not handle the possibility of a choice field not being set.
>>>>             if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>             {
>>>>                 super.setValue("");
>>>>                 return;
>>>>             }
>>>>             
>>>>             int indexSelected = -1;
>>>>             COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>             int fieldFlags = getFieldFlags();
>>>>             boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>>
>>>>             if (options.size() == 0 && !isEditable)
>>>>             {
>>>>                 throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>             }
>>>>             else
>>>>             {
>>>>                 // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>                 // where sometimes there is 1 string and the rest arrays.
>>>>                 // This code works either way.
>>>>                 for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>                 {
>>>>                     COSBase option = options.getObject(i);
>>>>                     if (option instanceof COSArray)
>>>>                     {
>>>>                         COSArray keyValuePair = (COSArray) option;
>>>>                         COSString key = (COSString) keyValuePair.getObject(0);
>>>>                         COSString value = (COSString) keyValuePair.getObject(1);
>>>>                         if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>                         {
>>>>                             // have the parent draw the appearance stream with the value
>>>>                             if ((FLAG_COMBO & fieldFlags) != 0)
>>>>                             {
>>>>                                 super.setValue(value.getString());
>>>>                             }
>>>>                             else
>>>>                             {
>>>>                                 COSArray indexEntries = new COSArray();
>>>>                                 indexEntries.add(COSInteger.get((long) i));
>>>>                                 getDictionary().setItem(COSName.I, indexEntries);
>>>>                                 setListboxValue(value.getString());
>>>>                             }
>>>>                             // but then use the key as the V entry
>>>>                             getDictionary().setItem(COSName.V, key);
>>>>                             indexSelected = i;
>>>>
>>>>                         }
>>>>                     }
>>>>                     else
>>>>                     {
>>>>                         COSString value = (COSString) option;
>>>>                         if (optionValue.equals(value.getString()))
>>>>                         {
>>>>                             super.setValue(optionValue);
>>>>                             indexSelected = i;
>>>>                         }
>>>>                     }
>>>>                 }
>>>>             }
>>>>             if (indexSelected == -1 && isEditable)
>>>>             {
>>>>                 super.setValue(optionValue);
>>>>             }
>>>>             else if (indexSelected == -1)
>>>>             {
>>>>                 throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>             }
>>>>             else
>>>>             {
>>>>                 COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>                 if (indexArray != null)
>>>>                 {
>>>>                     indexArray.clear();
>>>>                     indexArray.add(COSInteger.get(indexSelected));
>>>>                 }
>>>>             }
>>>>         }
>>>>
>>>>
>>>> V/R,
>>>> Mark Strein
>>>>
>>>> TRAC-FLVN
>>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>>> Paving Crew Keeper of the Codes
>>>> 913-684-9309
>>>>
>>>>
>>>>
>>>> -------------------------------------------------------------------
>>>> -
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS 
CTR (US):
> Ok,
> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
>
> This is what I get:
> With pdfbox 1.8.11
> Apr 08, 2016 12:46:59 PM org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: ./Forms/A3161_Blank.pdf
> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source)
> 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:2048)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:348)
>
>
> And you are using:
> File originalPDF = new File(pdfFileName);
>              	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                  pdDocument = PDDocument.loadNonSeq(originalPDF, raFile);
>
>                  boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                  if (isOriginalDocEncrypted)
>                  {
>                  	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                  }
>                  pdDocumentCatalog = pdDocument.getDocumentCatalog();
>                  
>                  pdAcroForm = pdDocumentCatalog.getAcroForm();
>
> Yes?

If you use loadNonSeq there is no need to call openProtection().

And I didn't use a scratch file at all.


>
> Tilman,
> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also.
> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields.
> As it stands now, I am not getting any further than:
> pdDocument.openProtection(new StandardDecryptionMaterial(""));

I'm using PDFReader because I have the source code. So if I can work 
with PDFReader it means that some source code exists to open the file.

With 1.8.11 it works with both normal and nonSeq parser.
With 1.8.10 only the nonSeq parser works.

Tilman

>
> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
>
> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
> javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
>
> Mark....
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Friday, April 08, 2016 12:22 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException
>
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>
>
>
>
> ----
>
> I just tried it with 1.8.10 and it works fine:
>
>   >java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
> Apr 08, 2016 7:19:27 PM
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: EMC
>
> and the file is displayed.
>
> Maybe you still have the old files in your classpath.
> And the current  version is 1.8.11. Not 1.8.10.
>
> Tilman
>
> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Tilman interesting,
>>
>> This is what I get:
>>
>> Apr 08, 2016 11:42:31 AM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file:
>> ./Forms/A3161_Blank.pdf 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)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
>> ityHandler.java:352)
>>
>> Here is my code when using pdfbox-1.8.10-src:
>>               	File originalPDF = new File(pdfFileName);
>>               	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>                   pdDocument = PDDocument.loadNonSeq(originalPDF,
>> raFile);
>>
>>                   boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>                   if (isOriginalDocEncrypted)
>>                   {
>>                   	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>                   }
>>                   pdDocumentCatalog = pdDocument.getDocumentCatalog();
>>                   
>>                   pdAcroForm = pdDocumentCatalog.getAcroForm();
>>
>>
>>
>>
>> You used Java 1.7.0
>> With
>> Pdfbox-1.8.6(source),
>> bcmail-jdk15-1.44.jar,
>> bcprov-jdk15-1.44.jar,
>> commons-logging-1.1.2.jar,
>> fontbox-1.8.6.jar,
>> jempbox-1.8.6.jar
>>
>> the above code base opens this file:
>>     Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>>
>>
>> The code base below will not open it:
>> Java 8,
>> pdfbox-1.8.10-src
>> bcmail-jdk16-1.46.jar
>> bcprov-jdk16-1.46.jar
>> commons-logging-1.1.2.jar
>> fontbox-1.8.10.jar
>> jempbox-1.8.10.jar
>> icu4j.jar
>>
>>
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 10:52 AM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update:
>> org.apache.pdfbox.exceptions.WrappedIOException
>>
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>>
>>
>>
>>
>> ----
>>
>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>>
>> Tilman
>>
>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> "That means you bypassed the problem instead of confronting and solving it."
>>> True..
>>>
>>> I did as you suggested:
>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>>
>>> It did not work on the file below.
>>>
>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3c
>>> xaHczWXc
>>>
>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>>
>>> Try the one in the link.
>>>
>>> Thank you for your help.
>>>
>>> Mark....
>>>
>>>
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>>> Sent: Thursday, April 07, 2016 12:39 PM
>>> To: users@pdfbox.apache.org
>>> Subject: [Non-DoD Source] Re: Update:
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>>
>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> Hello all,
>>>>
>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>> Then did the explorer save to adobe trick.
>>> That means you bypassed the problem instead of confronting and solving it.
>>>
>>>
>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>>
>>> Tilman
>>>
>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>>
>>>>
>>>> public void setValue(String optionValue) throws IOException
>>>>         {
>>>>         	//TODO - in the instance where an option list doesn't have a default option
>>>>             //We need to allow for the case where no selection was made.
>>>>             //When reading a blank form, the value returned to us is null. The current code
>>>>             //does not handle the possibility of a choice field not being set.
>>>>             if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>             {
>>>>                 super.setValue("");
>>>>                 return;
>>>>             }
>>>>             
>>>>             int indexSelected = -1;
>>>>             COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>             int fieldFlags = getFieldFlags();
>>>>             boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 &&
>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>>
>>>>             if (options.size() == 0 && !isEditable)
>>>>             {
>>>>                 throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>             }
>>>>             else
>>>>             {
>>>>                 // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>                 // where sometimes there is 1 string and the rest arrays.
>>>>                 // This code works either way.
>>>>                 for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>                 {
>>>>                     COSBase option = options.getObject(i);
>>>>                     if (option instanceof COSArray)
>>>>                     {
>>>>                         COSArray keyValuePair = (COSArray) option;
>>>>                         COSString key = (COSString) keyValuePair.getObject(0);
>>>>                         COSString value = (COSString) keyValuePair.getObject(1);
>>>>                         if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>                         {
>>>>                             // have the parent draw the appearance stream with the value
>>>>                             if ((FLAG_COMBO & fieldFlags) != 0)
>>>>                             {
>>>>                                 super.setValue(value.getString());
>>>>                             }
>>>>                             else
>>>>                             {
>>>>                                 COSArray indexEntries = new COSArray();
>>>>                                 indexEntries.add(COSInteger.get((long) i));
>>>>                                 getDictionary().setItem(COSName.I, indexEntries);
>>>>                                 setListboxValue(value.getString());
>>>>                             }
>>>>                             // but then use the key as the V entry
>>>>                             getDictionary().setItem(COSName.V, key);
>>>>                             indexSelected = i;
>>>>
>>>>                         }
>>>>                     }
>>>>                     else
>>>>                     {
>>>>                         COSString value = (COSString) option;
>>>>                         if (optionValue.equals(value.getString()))
>>>>                         {
>>>>                             super.setValue(optionValue);
>>>>                             indexSelected = i;
>>>>                         }
>>>>                     }
>>>>                 }
>>>>             }
>>>>             if (indexSelected == -1 && isEditable)
>>>>             {
>>>>                 super.setValue(optionValue);
>>>>             }
>>>>             else if (indexSelected == -1)
>>>>             {
>>>>                 throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>             }
>>>>             else
>>>>             {
>>>>                 COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>                 if (indexArray != null)
>>>>                 {
>>>>                     indexArray.clear();
>>>>                     indexArray.add(COSInteger.get(indexSelected));
>>>>                 }
>>>>             }
>>>>         }
>>>>
>>>>
>>>> V/R,
>>>> Mark Strein
>>>>
>>>> TRAC-FLVN
>>>> Wargaming and Simulations Directorate Analytic Tools Division -
>>>> Paving Crew Keeper of the Codes
>>>> 913-684-9309
>>>>
>>>>
>>>>
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: [Non-DoD Source] Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil>.
Hello Maruan,
I will attempt to setup the latest pdfbox to run with 1.7, but in the meantime, here is the old pdfbox running with 1.8 java.

>>> Java 1.8 (with old pdfbox)
>>> Pdfbox-1.8.6(source),
>>> bcmail-jdk15-1.44.jar,
>>> bcprov-jdk15-1.44.jar,
>>> commons-logging-1.1.2.jar,
>>> fontbox-1.8.6.jar,
>>> jempbox-1.8.6.jar

Error occured when trying to load the PDF file: ./Forms/A3161_Blank.pdf
java.io.IOException: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher
	at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:121)
	at javax.crypto.CipherInputStream.read(CipherInputStream.java:239)
	at javax.crypto.CipherInputStream.read(CipherInputStream.java:215)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:312)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:413)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:386)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:361)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:192)
	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1600)
	at org.apache.pdfbox.pdmodel.PDDocument.decrypt(PDDocument.java:946)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:890)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:110)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:74)
	at src.utility.DA3161.<init>(DA3161.java:51)
	at src.utility.PDF3161.<init>(PDF3161.java:23)
	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1929)
	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2011)
	at src.application.Main$19.actionPerformed(Main.java:897)

Mark....

-----Original Message-----
From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
Sent: Saturday, April 09, 2016 1:16 AM
To: users@pdfbox.apache.org
Subject: Re: [Non-DoD Source] Update: org.apache.pdfbox.exceptions.WrappedIOException

Hello Mark,

> Am 08.04.2016 um 21:57 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) <ma...@mail.mil>:
> 
> Hello Maruan,
> 
> "did you try 1.8.11 with Java 1.8?" Yes that is the last trace I posted.
> 
> "What's the result you get trying 1.8.11 with 1.7? " I am losing the ability to use 1.7, thus me needing to upgrade.

understood. Just wanted to ask you if it's possible to test PDFBox 1.8.11 with 1.7 on your setup to check if the issue is somehow related to the Java VM. The target being that it shall work with 1.8.

BR
Maruan 

> The following is what is used with my software currently and it works. I can open all DA pdf forms, interrogate them for field names, and read and write to them.
>>> Java 1.7.0
>>> Pdfbox-1.8.6(source),
>>> bcmail-jdk15-1.44.jar,
>>> bcprov-jdk15-1.44.jar,
>>> commons-logging-1.1.2.jar,
>>> fontbox-1.8.6.jar,
>>> jempbox-1.8.6.jar
> 
> 
> " Which patch version of Java 1.8 are you using?  Which OS?"
> 
> PDFBOX 1.8.11
> Java 1.8.0_66
> 
> OS Name	Microsoft Windows 7 Enterprise
> Version	6.1.7601 Service Pack 1 Build 7601
> 
> Eclipse IDE for Java Developers
> Version: Luna Service Release 2 (4.4.2) Build id: 20150219-0600
> 
> Mark.....
> 
> 
> -----Original Message-----
> From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de]
> Sent: Friday, April 08, 2016 1:48 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: 
> org.apache.pdfbox.exceptions.WrappedIOException
> 
> Hi,
> 
>> Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) <ma...@mail.mil>:
>> 
>> Ok,
>> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
>> 
>> This is what I get:
>> With pdfbox 1.8.11
>> Apr 08, 2016 12:46:59 PM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file: 
>> ./Forms/A3161_Blank.pdf
>> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
>> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
>> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secu
>> r
>> ityHandler.java:348)
>> 
>> 
>> And you are using:
>> File originalPDF = new File(pdfFileName); 
>>           	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>               pdDocument = PDDocument.loadNonSeq(originalPDF,
>> raFile);
>> 
>>               boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>               if (isOriginalDocEncrypted) 
>>               {
>>               	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>               }
>>               pdDocumentCatalog = pdDocument.getDocumentCatalog();    
>> 
>>               pdAcroForm = pdDocumentCatalog.getAcroForm();
>> 
>> Yes?
>> 
>> Tilman,
>> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also. 
>> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields. 
>> As it stands now, I am not getting any further than:
>> pdDocument.openProtection(new StandardDecryptionMaterial(""));
>> 
>> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
>> 
>> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
>> javax.crypto.IllegalBlockSizeException: Input length must be multiple 
>> of 16 when decrypting with padded cipher
> 
> 
> did you try 1.8.11 with Java 1.8? What's the result you get trying 1.8.11 with 1.7? Which patch version of Java 1.8 are you using? Which OS?
> 
> BR
> Maruan
> 
>> 
>> Mark....
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 12:22 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update: 
>> org.apache.pdfbox.exceptions.WrappedIOException
>> 
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.  
>> 
>> 
>> 
>> 
>> ----
>> 
>> I just tried it with 1.8.10 and it works fine:
>> 
>>> java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
>> Apr 08, 2016 7:19:27 PM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
>> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 
>> PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 
>> PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 
>> PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: EMC
>> 
>> and the file is displayed.
>> 
>> Maybe you still have the old files in your classpath.
>> And the current  version is 1.8.11. Not 1.8.10.
>> 
>> Tilman
>> 
>> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> Tilman interesting,
>>> 
>>> This is what I get:
>>> 
>>> Apr 08, 2016 11:42:31 AM
>>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>>> Error occured when trying to load the PDF file: 
>>> ./Forms/A3161_Blank.pdf 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)
>>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>> 	at java.awt.Component.processEvent(Unknown Source)
>>> 	at java.awt.Container.processEvent(Unknown Source)
>>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.EventQueue.access$500(Unknown Source)
>>> 	at java.awt.EventQueue$3.run(Unknown Source)
>>> 	at java.awt.EventQueue$3.run(Unknown Source)
>>> 	at java.security.AccessController.doPrivileged(Native Method)
>>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>>> 	at java.awt.EventQueue$4.run(Unknown Source)
>>> 	at java.awt.EventQueue$4.run(Unknown Source)
>>> 	at java.security.AccessController.doPrivileged(Native Method)
>>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>>> 	at
>>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Sec
>>> u
>>> r
>>> ityHandler.java:352)
>>> 
>>> Here is my code when using pdfbox-1.8.10-src:
>>>            	File originalPDF = new File(pdfFileName);
>>>            	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>>                pdDocument = PDDocument.loadNonSeq(originalPDF,
>>> raFile);
>>> 
>>>                boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>>                if (isOriginalDocEncrypted)
>>>                {
>>>                	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>>                }
>>>                pdDocumentCatalog = pdDocument.getDocumentCatalog();
>>> 
>>>                pdAcroForm = pdDocumentCatalog.getAcroForm();
>>> 
>>> 
>>> 
>>> 
>>> You used Java 1.7.0
>>> With
>>> Pdfbox-1.8.6(source),
>>> bcmail-jdk15-1.44.jar,
>>> bcprov-jdk15-1.44.jar,
>>> commons-logging-1.1.2.jar,
>>> fontbox-1.8.6.jar,
>>> jempbox-1.8.6.jar
>>> 
>>> the above code base opens this file:
>>>  Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>>> 
>>> 
>>> The code base below will not open it:
>>> Java 8,
>>> pdfbox-1.8.10-src
>>> bcmail-jdk16-1.46.jar
>>> bcprov-jdk16-1.46.jar
>>> commons-logging-1.1.2.jar
>>> fontbox-1.8.10.jar
>>> jempbox-1.8.10.jar
>>> icu4j.jar
>>> 
>>> 
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>>> Sent: Friday, April 08, 2016 10:52 AM
>>> To: users@pdfbox.apache.org
>>> Subject: Re: [Non-DoD Source] Re: Update: 
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>> 
>>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>>> 
>>> 
>>> 
>>> 
>>> ----
>>> 
>>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>>> 
>>> Tilman
>>> 
>>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> "That means you bypassed the problem instead of confronting and solving it."
>>>> True..
>>>> 
>>>> I did as you suggested:
>>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>>> 
>>>> It did not work on the file below.
>>>> 
>>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S
>>>> 3
>>>> c
>>>> xaHczWXc
>>>> 
>>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>>> 
>>>> Try the one in the link.
>>>> 
>>>> Thank you for your help.
>>>> 
>>>> Mark....
>>>> 
>>>> 
>>>> -----Original Message-----
>>>> From: Tilman Hausherr 
>>>> [Caution-Caution-mailto:THausherr@t-online.de]
>>>> Sent: Thursday, April 07, 2016 12:39 PM
>>>> To: users@pdfbox.apache.org
>>>> Subject: [Non-DoD Source] Re: Update:
>>>> org.apache.pdfbox.exceptions.WrappedIOException
>>>> 
>>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>>> Hello all,
>>>>> 
>>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>>> Then did the explorer save to adobe trick.
>>>> That means you bypassed the problem instead of confronting and solving it.
>>>> 
>>>> 
>>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>>> 
>>>> Tilman
>>>> 
>>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>>> 
>>>>> 
>>>>> public void setValue(String optionValue) throws IOException
>>>>>      {
>>>>>      	//TODO - in the instance where an option list doesn't have a default option
>>>>>          //We need to allow for the case where no selection was made.
>>>>>          //When reading a blank form, the value returned to us is null. The current code
>>>>>          //does not handle the possibility of a choice field not being set.
>>>>>          if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>>          {
>>>>>              super.setValue("");
>>>>>              return;
>>>>>          }
>>>>> 
>>>>>          int indexSelected = -1;
>>>>>          COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>>          int fieldFlags = getFieldFlags();
>>>>>          boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>>> 
>>>>>          if (options.size() == 0 && !isEditable)
>>>>>          {
>>>>>              throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>>          }
>>>>>          else
>>>>>          {
>>>>>              // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>>              // where sometimes there is 1 string and the rest arrays.
>>>>>              // This code works either way.
>>>>>              for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>>              {
>>>>>                  COSBase option = options.getObject(i);
>>>>>                  if (option instanceof COSArray)
>>>>>                  {
>>>>>                      COSArray keyValuePair = (COSArray) option;
>>>>>                      COSString key = (COSString) keyValuePair.getObject(0);
>>>>>                      COSString value = (COSString) keyValuePair.getObject(1);
>>>>>                      if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>>                      {
>>>>>                          // have the parent draw the appearance stream with the value
>>>>>                          if ((FLAG_COMBO & fieldFlags) != 0)
>>>>>                          {
>>>>>                              super.setValue(value.getString());
>>>>>                          }
>>>>>                          else
>>>>>                          {
>>>>>                              COSArray indexEntries = new COSArray();
>>>>>                              indexEntries.add(COSInteger.get((long) i));
>>>>>                              getDictionary().setItem(COSName.I, indexEntries);
>>>>>                              setListboxValue(value.getString());
>>>>>                          }
>>>>>                          // but then use the key as the V entry
>>>>>                          getDictionary().setItem(COSName.V, key);
>>>>>                          indexSelected = i;
>>>>> 
>>>>>                      }
>>>>>                  }
>>>>>                  else
>>>>>                  {
>>>>>                      COSString value = (COSString) option;
>>>>>                      if (optionValue.equals(value.getString()))
>>>>>                      {
>>>>>                          super.setValue(optionValue);
>>>>>                          indexSelected = i;
>>>>>                      }
>>>>>                  }
>>>>>              }
>>>>>          }
>>>>>          if (indexSelected == -1 && isEditable)
>>>>>          {
>>>>>              super.setValue(optionValue);
>>>>>          }
>>>>>          else if (indexSelected == -1)
>>>>>          {
>>>>>              throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>>          }
>>>>>          else
>>>>>          {
>>>>>              COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>>              if (indexArray != null)
>>>>>              {
>>>>>                  indexArray.clear();
>>>>>                  indexArray.add(COSInteger.get(indexSelected));
>>>>>              }
>>>>>          }
>>>>>      }
>>>>> 
>>>>> 
>>>>> V/R,
>>>>> Mark Strein
>>>>> 
>>>>> TRAC-FLVN
>>>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>>>> Paving Crew Keeper of the Codes
>>>>> 913-684-9309
>>>>> 
>>>>> 
>>>>> 
>>>>> ------------------------------------------------------------------
>>>>> -
>>>>> -
>>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>> 
>>>> -------------------------------------------------------------------
>>>> -
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>>> 
>>>> -------------------------------------------------------------------
>>>> -
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: [Non-DoD Source] Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hello Mark,

> Am 08.04.2016 um 21:57 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) <ma...@mail.mil>:
> 
> Hello Maruan,
> 
> "did you try 1.8.11 with Java 1.8?" Yes that is the last trace I posted.
> 
> "What's the result you get trying 1.8.11 with 1.7? " I am losing the ability to use 1.7, thus me needing to upgrade.

understood. Just wanted to ask you if it's possible to test PDFBox 1.8.11 with 1.7 on your setup to check if the issue is somehow related to the Java VM. The target being that it shall work with 1.8.

BR
Maruan 

> The following is what is used with my software currently and it works. I can open all DA pdf forms, interrogate them for field names, and read and write to them.
>>> Java 1.7.0
>>> Pdfbox-1.8.6(source),
>>> bcmail-jdk15-1.44.jar,
>>> bcprov-jdk15-1.44.jar,
>>> commons-logging-1.1.2.jar,
>>> fontbox-1.8.6.jar,
>>> jempbox-1.8.6.jar
> 
> 
> " Which patch version of Java 1.8 are you using?  Which OS?"
> 
> PDFBOX 1.8.11
> Java 1.8.0_66
> 
> OS Name	Microsoft Windows 7 Enterprise
> Version	6.1.7601 Service Pack 1 Build 7601
> 
> Eclipse IDE for Java Developers
> Version: Luna Service Release 2 (4.4.2)
> Build id: 20150219-0600
> 
> Mark.....
> 
> 
> -----Original Message-----
> From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
> Sent: Friday, April 08, 2016 1:48 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException
> 
> Hi,
> 
>> Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) <ma...@mail.mil>:
>> 
>> Ok,
>> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
>> 
>> This is what I get:
>> With pdfbox 1.8.11
>> Apr 08, 2016 12:46:59 PM 
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file: 
>> ./Forms/A3161_Blank.pdf
>> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
>> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
>> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
>> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at 
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
>> ityHandler.java:348)
>> 
>> 
>> And you are using:
>> File originalPDF = new File(pdfFileName); 
>>           	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>               pdDocument = PDDocument.loadNonSeq(originalPDF, 
>> raFile);
>> 
>>               boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>               if (isOriginalDocEncrypted) 
>>               {
>>               	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>               }
>>               pdDocumentCatalog = pdDocument.getDocumentCatalog();    
>> 
>>               pdAcroForm = pdDocumentCatalog.getAcroForm();
>> 
>> Yes?
>> 
>> Tilman,
>> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also. 
>> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields. 
>> As it stands now, I am not getting any further than:
>> pdDocument.openProtection(new StandardDecryptionMaterial(""));
>> 
>> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
>> 
>> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
>> javax.crypto.IllegalBlockSizeException: Input length must be multiple 
>> of 16 when decrypting with padded cipher
> 
> 
> did you try 1.8.11 with Java 1.8? What's the result you get trying 1.8.11 with 1.7? Which patch version of Java 1.8 are you using? Which OS?
> 
> BR
> Maruan
> 
>> 
>> Mark....
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 12:22 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update: 
>> org.apache.pdfbox.exceptions.WrappedIOException
>> 
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.  
>> 
>> 
>> 
>> 
>> ----
>> 
>> I just tried it with 1.8.10 and it works fine:
>> 
>>> java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
>> Apr 08, 2016 7:19:27 PM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
>> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM 
>> org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 
>> PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 
>> PM org.apache.pdfbox.util.PDFStreamEngine
>> processOperator
>> INFORMATION: unsupported/disabled operation: EMC
>> 
>> and the file is displayed.
>> 
>> Maybe you still have the old files in your classpath.
>> And the current  version is 1.8.11. Not 1.8.10.
>> 
>> Tilman
>> 
>> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> Tilman interesting,
>>> 
>>> This is what I get:
>>> 
>>> Apr 08, 2016 11:42:31 AM
>>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>>> Error occured when trying to load the PDF file: 
>>> ./Forms/A3161_Blank.pdf 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)
>>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>> 	at java.awt.Component.processEvent(Unknown Source)
>>> 	at java.awt.Container.processEvent(Unknown Source)
>>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>>> 	at java.awt.EventQueue.access$500(Unknown Source)
>>> 	at java.awt.EventQueue$3.run(Unknown Source)
>>> 	at java.awt.EventQueue$3.run(Unknown Source)
>>> 	at java.security.AccessController.doPrivileged(Native Method)
>>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>>> 	at java.awt.EventQueue$4.run(Unknown Source)
>>> 	at java.awt.EventQueue$4.run(Unknown Source)
>>> 	at java.security.AccessController.doPrivileged(Native Method)
>>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>>> 	at
>>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secu
>>> r
>>> ityHandler.java:352)
>>> 
>>> Here is my code when using pdfbox-1.8.10-src:
>>>            	File originalPDF = new File(pdfFileName);
>>>            	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>>                pdDocument = PDDocument.loadNonSeq(originalPDF,
>>> raFile);
>>> 
>>>                boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>>                if (isOriginalDocEncrypted)
>>>                {
>>>                	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>>                }
>>>                pdDocumentCatalog = pdDocument.getDocumentCatalog();
>>> 
>>>                pdAcroForm = pdDocumentCatalog.getAcroForm();
>>> 
>>> 
>>> 
>>> 
>>> You used Java 1.7.0
>>> With
>>> Pdfbox-1.8.6(source),
>>> bcmail-jdk15-1.44.jar,
>>> bcprov-jdk15-1.44.jar,
>>> commons-logging-1.1.2.jar,
>>> fontbox-1.8.6.jar,
>>> jempbox-1.8.6.jar
>>> 
>>> the above code base opens this file:
>>>  Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>>> 
>>> 
>>> The code base below will not open it:
>>> Java 8,
>>> pdfbox-1.8.10-src
>>> bcmail-jdk16-1.46.jar
>>> bcprov-jdk16-1.46.jar
>>> commons-logging-1.1.2.jar
>>> fontbox-1.8.10.jar
>>> jempbox-1.8.10.jar
>>> icu4j.jar
>>> 
>>> 
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>>> Sent: Friday, April 08, 2016 10:52 AM
>>> To: users@pdfbox.apache.org
>>> Subject: Re: [Non-DoD Source] Re: Update: 
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>> 
>>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>>> 
>>> 
>>> 
>>> 
>>> ----
>>> 
>>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>>> 
>>> Tilman
>>> 
>>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> "That means you bypassed the problem instead of confronting and solving it."
>>>> True..
>>>> 
>>>> I did as you suggested:
>>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>>> 
>>>> It did not work on the file below.
>>>> 
>>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3
>>>> c
>>>> xaHczWXc
>>>> 
>>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>>> 
>>>> Try the one in the link.
>>>> 
>>>> Thank you for your help.
>>>> 
>>>> Mark....
>>>> 
>>>> 
>>>> -----Original Message-----
>>>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>>>> Sent: Thursday, April 07, 2016 12:39 PM
>>>> To: users@pdfbox.apache.org
>>>> Subject: [Non-DoD Source] Re: Update:
>>>> org.apache.pdfbox.exceptions.WrappedIOException
>>>> 
>>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>>> Hello all,
>>>>> 
>>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>>> Then did the explorer save to adobe trick.
>>>> That means you bypassed the problem instead of confronting and solving it.
>>>> 
>>>> 
>>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>>> 
>>>> Tilman
>>>> 
>>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>>> 
>>>>> 
>>>>> public void setValue(String optionValue) throws IOException
>>>>>      {
>>>>>      	//TODO - in the instance where an option list doesn't have a default option
>>>>>          //We need to allow for the case where no selection was made.
>>>>>          //When reading a blank form, the value returned to us is null. The current code
>>>>>          //does not handle the possibility of a choice field not being set.
>>>>>          if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>>          {
>>>>>              super.setValue("");
>>>>>              return;
>>>>>          }
>>>>> 
>>>>>          int indexSelected = -1;
>>>>>          COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>>          int fieldFlags = getFieldFlags();
>>>>>          boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>>> 
>>>>>          if (options.size() == 0 && !isEditable)
>>>>>          {
>>>>>              throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>>          }
>>>>>          else
>>>>>          {
>>>>>              // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>>              // where sometimes there is 1 string and the rest arrays.
>>>>>              // This code works either way.
>>>>>              for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>>              {
>>>>>                  COSBase option = options.getObject(i);
>>>>>                  if (option instanceof COSArray)
>>>>>                  {
>>>>>                      COSArray keyValuePair = (COSArray) option;
>>>>>                      COSString key = (COSString) keyValuePair.getObject(0);
>>>>>                      COSString value = (COSString) keyValuePair.getObject(1);
>>>>>                      if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>>                      {
>>>>>                          // have the parent draw the appearance stream with the value
>>>>>                          if ((FLAG_COMBO & fieldFlags) != 0)
>>>>>                          {
>>>>>                              super.setValue(value.getString());
>>>>>                          }
>>>>>                          else
>>>>>                          {
>>>>>                              COSArray indexEntries = new COSArray();
>>>>>                              indexEntries.add(COSInteger.get((long) i));
>>>>>                              getDictionary().setItem(COSName.I, indexEntries);
>>>>>                              setListboxValue(value.getString());
>>>>>                          }
>>>>>                          // but then use the key as the V entry
>>>>>                          getDictionary().setItem(COSName.V, key);
>>>>>                          indexSelected = i;
>>>>> 
>>>>>                      }
>>>>>                  }
>>>>>                  else
>>>>>                  {
>>>>>                      COSString value = (COSString) option;
>>>>>                      if (optionValue.equals(value.getString()))
>>>>>                      {
>>>>>                          super.setValue(optionValue);
>>>>>                          indexSelected = i;
>>>>>                      }
>>>>>                  }
>>>>>              }
>>>>>          }
>>>>>          if (indexSelected == -1 && isEditable)
>>>>>          {
>>>>>              super.setValue(optionValue);
>>>>>          }
>>>>>          else if (indexSelected == -1)
>>>>>          {
>>>>>              throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>>          }
>>>>>          else
>>>>>          {
>>>>>              COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>>              if (indexArray != null)
>>>>>              {
>>>>>                  indexArray.clear();
>>>>>                  indexArray.add(COSInteger.get(indexSelected));
>>>>>              }
>>>>>          }
>>>>>      }
>>>>> 
>>>>> 
>>>>> V/R,
>>>>> Mark Strein
>>>>> 
>>>>> TRAC-FLVN
>>>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>>>> Paving Crew Keeper of the Codes
>>>>> 913-684-9309
>>>>> 
>>>>> 
>>>>> 
>>>>> -------------------------------------------------------------------
>>>>> -
>>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>> 
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>>> 
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil>.
Hello Maruan,

"did you try 1.8.11 with Java 1.8?" Yes that is the last trace I posted.

"What's the result you get trying 1.8.11 with 1.7? " I am losing the ability to use 1.7, thus me needing to upgrade.
The following is what is used with my software currently and it works. I can open all DA pdf forms, interrogate them for field names, and read and write to them.
>> Java 1.7.0
>> Pdfbox-1.8.6(source),
>> bcmail-jdk15-1.44.jar,
>> bcprov-jdk15-1.44.jar,
>> commons-logging-1.1.2.jar,
>> fontbox-1.8.6.jar,
>> jempbox-1.8.6.jar


" Which patch version of Java 1.8 are you using?  Which OS?"

PDFBOX 1.8.11
Java 1.8.0_66

OS Name	Microsoft Windows 7 Enterprise
Version	6.1.7601 Service Pack 1 Build 7601

Eclipse IDE for Java Developers
Version: Luna Service Release 2 (4.4.2)
Build id: 20150219-0600

Mark.....


-----Original Message-----
From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de] 
Sent: Friday, April 08, 2016 1:48 PM
To: users@pdfbox.apache.org
Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Hi,

> Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) <ma...@mail.mil>:
> 
> Ok,
> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
> 
> This is what I get:
> With pdfbox 1.8.11
> Apr 08, 2016 12:46:59 PM 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: 
> ./Forms/A3161_Blank.pdf
> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
> 	at 
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
> ityHandler.java:348)
> 
> 
> And you are using:
> File originalPDF = new File(pdfFileName); 
>            	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                pdDocument = PDDocument.loadNonSeq(originalPDF, 
> raFile);
> 
>                boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                if (isOriginalDocEncrypted) 
>                {
>                	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                }
>                pdDocumentCatalog = pdDocument.getDocumentCatalog();    
> 
>                pdAcroForm = pdDocumentCatalog.getAcroForm();
> 
> Yes?
> 
> Tilman,
> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also. 
> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields. 
> As it stands now, I am not getting any further than:
> pdDocument.openProtection(new StandardDecryptionMaterial(""));
> 
> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
> 
> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
> javax.crypto.IllegalBlockSizeException: Input length must be multiple 
> of 16 when decrypting with padded cipher


did you try 1.8.11 with Java 1.8? What's the result you get trying 1.8.11 with 1.7? Which patch version of Java 1.8 are you using? Which OS?

BR
Maruan

> 
> Mark....
> 
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Friday, April 08, 2016 12:22 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: 
> org.apache.pdfbox.exceptions.WrappedIOException
> 
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.  
> 
> 
> 
> 
> ----
> 
> I just tried it with 1.8.10 and it works fine:
> 
>> java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
> Apr 08, 2016 7:19:27 PM
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM 
> org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 
> PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 
> PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: EMC
> 
> and the file is displayed.
> 
> Maybe you still have the old files in your classpath.
> And the current  version is 1.8.11. Not 1.8.10.
> 
> Tilman
> 
> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Tilman interesting,
>> 
>> This is what I get:
>> 
>> Apr 08, 2016 11:42:31 AM
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file: 
>> ./Forms/A3161_Blank.pdf 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)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secu
>> r
>> ityHandler.java:352)
>> 
>> Here is my code when using pdfbox-1.8.10-src:
>>             	File originalPDF = new File(pdfFileName);
>>             	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>                 pdDocument = PDDocument.loadNonSeq(originalPDF,
>> raFile);
>> 
>>                 boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>                 if (isOriginalDocEncrypted)
>>                 {
>>                 	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>                 }
>>                 pdDocumentCatalog = pdDocument.getDocumentCatalog();
>> 
>>                 pdAcroForm = pdDocumentCatalog.getAcroForm();
>> 
>> 
>> 
>> 
>> You used Java 1.7.0
>> With
>> Pdfbox-1.8.6(source),
>> bcmail-jdk15-1.44.jar,
>> bcprov-jdk15-1.44.jar,
>> commons-logging-1.1.2.jar,
>> fontbox-1.8.6.jar,
>> jempbox-1.8.6.jar
>> 
>> the above code base opens this file:
>>   Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>> 
>> 
>> The code base below will not open it:
>> Java 8,
>> pdfbox-1.8.10-src
>> bcmail-jdk16-1.46.jar
>> bcprov-jdk16-1.46.jar
>> commons-logging-1.1.2.jar
>> fontbox-1.8.10.jar
>> jempbox-1.8.10.jar
>> icu4j.jar
>> 
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 10:52 AM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update: 
>> org.apache.pdfbox.exceptions.WrappedIOException
>> 
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>> 
>> 
>> 
>> 
>> ----
>> 
>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>> 
>> Tilman
>> 
>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> "That means you bypassed the problem instead of confronting and solving it."
>>> True..
>>> 
>>> I did as you suggested:
>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>> 
>>> It did not work on the file below.
>>> 
>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3
>>> c
>>> xaHczWXc
>>> 
>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>> 
>>> Try the one in the link.
>>> 
>>> Thank you for your help.
>>> 
>>> Mark....
>>> 
>>> 
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>>> Sent: Thursday, April 07, 2016 12:39 PM
>>> To: users@pdfbox.apache.org
>>> Subject: [Non-DoD Source] Re: Update:
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>> 
>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> Hello all,
>>>> 
>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>> Then did the explorer save to adobe trick.
>>> That means you bypassed the problem instead of confronting and solving it.
>>> 
>>> 
>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>> 
>>> Tilman
>>> 
>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>> 
>>>> 
>>>> public void setValue(String optionValue) throws IOException
>>>>       {
>>>>       	//TODO - in the instance where an option list doesn't have a default option
>>>>           //We need to allow for the case where no selection was made.
>>>>           //When reading a blank form, the value returned to us is null. The current code
>>>>           //does not handle the possibility of a choice field not being set.
>>>>           if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>           {
>>>>               super.setValue("");
>>>>               return;
>>>>           }
>>>> 
>>>>           int indexSelected = -1;
>>>>           COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>           int fieldFlags = getFieldFlags();
>>>>           boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>> 
>>>>           if (options.size() == 0 && !isEditable)
>>>>           {
>>>>               throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>           }
>>>>           else
>>>>           {
>>>>               // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>               // where sometimes there is 1 string and the rest arrays.
>>>>               // This code works either way.
>>>>               for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>               {
>>>>                   COSBase option = options.getObject(i);
>>>>                   if (option instanceof COSArray)
>>>>                   {
>>>>                       COSArray keyValuePair = (COSArray) option;
>>>>                       COSString key = (COSString) keyValuePair.getObject(0);
>>>>                       COSString value = (COSString) keyValuePair.getObject(1);
>>>>                       if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>                       {
>>>>                           // have the parent draw the appearance stream with the value
>>>>                           if ((FLAG_COMBO & fieldFlags) != 0)
>>>>                           {
>>>>                               super.setValue(value.getString());
>>>>                           }
>>>>                           else
>>>>                           {
>>>>                               COSArray indexEntries = new COSArray();
>>>>                               indexEntries.add(COSInteger.get((long) i));
>>>>                               getDictionary().setItem(COSName.I, indexEntries);
>>>>                               setListboxValue(value.getString());
>>>>                           }
>>>>                           // but then use the key as the V entry
>>>>                           getDictionary().setItem(COSName.V, key);
>>>>                           indexSelected = i;
>>>> 
>>>>                       }
>>>>                   }
>>>>                   else
>>>>                   {
>>>>                       COSString value = (COSString) option;
>>>>                       if (optionValue.equals(value.getString()))
>>>>                       {
>>>>                           super.setValue(optionValue);
>>>>                           indexSelected = i;
>>>>                       }
>>>>                   }
>>>>               }
>>>>           }
>>>>           if (indexSelected == -1 && isEditable)
>>>>           {
>>>>               super.setValue(optionValue);
>>>>           }
>>>>           else if (indexSelected == -1)
>>>>           {
>>>>               throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>           }
>>>>           else
>>>>           {
>>>>               COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>               if (indexArray != null)
>>>>               {
>>>>                   indexArray.clear();
>>>>                   indexArray.add(COSInteger.get(indexSelected));
>>>>               }
>>>>           }
>>>>       }
>>>> 
>>>> 
>>>> V/R,
>>>> Mark Strein
>>>> 
>>>> TRAC-FLVN
>>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>>> Paving Crew Keeper of the Codes
>>>> 913-684-9309
>>>> 
>>>> 
>>>> 
>>>> -------------------------------------------------------------------
>>>> -
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>>> 
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

> Am 08.04.2016 um 20:36 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) <ma...@mail.mil>:
> 
> Ok,
> I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)
> 
> This is what I get:
> With pdfbox 1.8.11
> Apr 08, 2016 12:46:59 PM org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: ./Forms/A3161_Blank.pdf
> org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
> 	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
> 	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source)
> 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:2048)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:348)
> 
> 
> And you are using:
> File originalPDF = new File(pdfFileName); 
>            	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                pdDocument = PDDocument.loadNonSeq(originalPDF, raFile);
> 
>                boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                if (isOriginalDocEncrypted) 
>                {
>                	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                }
>                pdDocumentCatalog = pdDocument.getDocumentCatalog();    
> 
>                pdAcroForm = pdDocumentCatalog.getAcroForm();
> 
> Yes?
> 
> Tilman,
> I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also. 
> I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields. 
> As it stands now, I am not getting any further than:
> pdDocument.openProtection(new StandardDecryptionMaterial(""));
> 
> I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.
> 
> Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
> javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher


did you try 1.8.11 with Java 1.8? What's the result you get trying 1.8.11 with 1.7? Which patch version of Java 1.8 are you using? Which OS?

BR
Maruan

> 
> Mark....
> 
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de] 
> Sent: Friday, April 08, 2016 12:22 PM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException
> 
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.  
> 
> 
> 
> 
> ----
> 
> I just tried it with 1.8.10 and it works fine:
> 
>> java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
> Apr 08, 2016 7:19:27 PM
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
> Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 PM org.apache.pdfbox.util.PDFStreamEngine
> processOperator
> INFORMATION: unsupported/disabled operation: EMC
> 
> and the file is displayed.
> 
> Maybe you still have the old files in your classpath.
> And the current  version is 1.8.11. Not 1.8.10.
> 
> Tilman
> 
> Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Tilman interesting,
>> 
>> This is what I get:
>> 
>> Apr 08, 2016 11:42:31 AM 
>> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
>> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
>> Error occured when trying to load the PDF file: 
>> ./Forms/A3161_Blank.pdf 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)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
>> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
>> 	at src.utility.DA3161.<init>(DA3161.java:51)
>> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
>> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
>> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
>> 	at src.application.Main$19.actionPerformed(Main.java:890)
>> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
>> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>> 	at javax.swing.AbstractButton.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
>> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
>> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
>> 	at java.awt.Component.processMouseEvent(Unknown Source)
>> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
>> 	at java.awt.Component.processEvent(Unknown Source)
>> 	at java.awt.Container.processEvent(Unknown Source)
>> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
>> 	at java.awt.Component.dispatchEvent(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>> 	at java.awt.EventQueue.access$500(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.awt.EventQueue$3.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.awt.EventQueue$4.run(Unknown Source)
>> 	at java.security.AccessController.doPrivileged(Native Method)
>> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
>> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
>> 	at 
>> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
>> ityHandler.java:352)
>> 
>> Here is my code when using pdfbox-1.8.10-src:
>>             	File originalPDF = new File(pdfFileName);
>>             	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>>                 pdDocument = PDDocument.loadNonSeq(originalPDF, 
>> raFile);
>> 
>>                 boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>>                 if (isOriginalDocEncrypted)
>>                 {
>>                 	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>>                 }
>>                 pdDocumentCatalog = pdDocument.getDocumentCatalog();
>> 
>>                 pdAcroForm = pdDocumentCatalog.getAcroForm();
>> 
>> 
>> 
>> 
>> You used Java 1.7.0
>> With
>> Pdfbox-1.8.6(source),
>> bcmail-jdk15-1.44.jar,
>> bcprov-jdk15-1.44.jar,
>> commons-logging-1.1.2.jar,
>> fontbox-1.8.6.jar,
>> jempbox-1.8.6.jar
>> 
>> the above code base opens this file:
>>   Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>> 
>> 
>> The code base below will not open it:
>> Java 8,
>> pdfbox-1.8.10-src
>> bcmail-jdk16-1.46.jar
>> bcprov-jdk16-1.46.jar
>> commons-logging-1.1.2.jar
>> fontbox-1.8.10.jar
>> jempbox-1.8.10.jar
>> icu4j.jar
>> 
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>> Sent: Friday, April 08, 2016 10:52 AM
>> To: users@pdfbox.apache.org
>> Subject: Re: [Non-DoD Source] Re: Update: 
>> org.apache.pdfbox.exceptions.WrappedIOException
>> 
>> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>> 
>> 
>> 
>> 
>> ----
>> 
>> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>> 
>> Tilman
>> 
>> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> "That means you bypassed the problem instead of confronting and solving it."
>>> True..
>>> 
>>> I did as you suggested:
>>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>> 
>>> It did not work on the file below.
>>> 
>>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3c
>>> xaHczWXc
>>> 
>>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>> 
>>> Try the one in the link.
>>> 
>>> Thank you for your help.
>>> 
>>> Mark....
>>> 
>>> 
>>> -----Original Message-----
>>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>>> Sent: Thursday, April 07, 2016 12:39 PM
>>> To: users@pdfbox.apache.org
>>> Subject: [Non-DoD Source] Re: Update:
>>> org.apache.pdfbox.exceptions.WrappedIOException
>>> 
>>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>>> Hello all,
>>>> 
>>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>>> Then did the explorer save to adobe trick.
>>> That means you bypassed the problem instead of confronting and solving it.
>>> 
>>> 
>>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>> 
>>> Tilman
>>> 
>>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>> 
>>>> 
>>>> public void setValue(String optionValue) throws IOException
>>>>       {
>>>>       	//TODO - in the instance where an option list doesn't have a default option
>>>>           //We need to allow for the case where no selection was made.
>>>>           //When reading a blank form, the value returned to us is null. The current code
>>>>           //does not handle the possibility of a choice field not being set.
>>>>           if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>>           {
>>>>               super.setValue("");
>>>>               return;
>>>>           }
>>>> 
>>>>           int indexSelected = -1;
>>>>           COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>>           int fieldFlags = getFieldFlags();
>>>>           boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>>> (FLAG_EDIT & fieldFlags) != 0;
>>>> 
>>>>           if (options.size() == 0 && !isEditable)
>>>>           {
>>>>               throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>>           }
>>>>           else
>>>>           {
>>>>               // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>>               // where sometimes there is 1 string and the rest arrays.
>>>>               // This code works either way.
>>>>               for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>>               {
>>>>                   COSBase option = options.getObject(i);
>>>>                   if (option instanceof COSArray)
>>>>                   {
>>>>                       COSArray keyValuePair = (COSArray) option;
>>>>                       COSString key = (COSString) keyValuePair.getObject(0);
>>>>                       COSString value = (COSString) keyValuePair.getObject(1);
>>>>                       if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>>                       {
>>>>                           // have the parent draw the appearance stream with the value
>>>>                           if ((FLAG_COMBO & fieldFlags) != 0)
>>>>                           {
>>>>                               super.setValue(value.getString());
>>>>                           }
>>>>                           else
>>>>                           {
>>>>                               COSArray indexEntries = new COSArray();
>>>>                               indexEntries.add(COSInteger.get((long) i));
>>>>                               getDictionary().setItem(COSName.I, indexEntries);
>>>>                               setListboxValue(value.getString());
>>>>                           }
>>>>                           // but then use the key as the V entry
>>>>                           getDictionary().setItem(COSName.V, key);
>>>>                           indexSelected = i;
>>>> 
>>>>                       }
>>>>                   }
>>>>                   else
>>>>                   {
>>>>                       COSString value = (COSString) option;
>>>>                       if (optionValue.equals(value.getString()))
>>>>                       {
>>>>                           super.setValue(optionValue);
>>>>                           indexSelected = i;
>>>>                       }
>>>>                   }
>>>>               }
>>>>           }
>>>>           if (indexSelected == -1 && isEditable)
>>>>           {
>>>>               super.setValue(optionValue);
>>>>           }
>>>>           else if (indexSelected == -1)
>>>>           {
>>>>               throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>>           }
>>>>           else
>>>>           {
>>>>               COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>>               if (indexArray != null)
>>>>               {
>>>>                   indexArray.clear();
>>>>                   indexArray.add(COSInteger.get(indexSelected));
>>>>               }
>>>>           }
>>>>       }
>>>> 
>>>> 
>>>> V/R,
>>>> Mark Strein
>>>> 
>>>> TRAC-FLVN
>>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>>> Paving Crew Keeper of the Codes
>>>> 913-684-9309
>>>> 
>>>> 
>>>> 
>>>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil>.
Ok,
I moved to pdfbox 1.8.11 (the only pdfbox in my sandbox)

This is what I get:
With pdfbox 1.8.11
Apr 08, 2016 12:46:59 PM org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
Error occured when trying to load the PDF file: ./Forms/A3161_Blank.pdf
org.apache.pdfbox.exceptions.WrappedIOException: Input length must be multiple of 16 when decrypting with padded cipher
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:368)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptStream(SecurityHandler.java:472)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decrypt(SecurityHandler.java:430)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.decryptObject(SecurityHandler.java:400)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.proceedDecryption(SecurityHandler.java:218)
	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.decryptDocument(StandardSecurityHandler.java:158)
	at org.apache.pdfbox.pdmodel.PDDocument.openProtection(PDDocument.java:1612)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
	at src.utility.DA3161.<init>(DA3161.java:51)
	at src.utility.PDF3161.<init>(PDF3161.java:23)
	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
	at src.application.Main$19.actionPerformed(Main.java:890)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.AbstractButton.doClick(Unknown Source)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
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:2048)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:348)


And you are using:
File originalPDF = new File(pdfFileName); 
            	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
                pdDocument = PDDocument.loadNonSeq(originalPDF, raFile);

                boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
                if (isOriginalDocEncrypted) 
                {
                	pdDocument.openProtection(new StandardDecryptionMaterial(""));
                }
                pdDocumentCatalog = pdDocument.getDocumentCatalog();    
                
                pdAcroForm = pdDocumentCatalog.getAcroForm();

Yes?

Tilman,
I noticed you used PDReader. Never used it, but you said it displayed the pdf, but Adobe can display it also. 
I don't need to display the pdf, I need to get to the pdAcroForm  so I can fill in the fields. 
As it stands now, I am not getting any further than:
pdDocument.openProtection(new StandardDecryptionMaterial(""));

I wouldn't even be bothering to upgrade this software if it wasn't for losing the ability to use Java 1.7.0 at the end of the year.

Just an FYI, but just moving to Java 8 and leaving pdfbox(1.8.6) alone produces this error:
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 16 when decrypting with padded cipher

Mark....

-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Friday, April 08, 2016 12:22 PM
To: users@pdfbox.apache.org
Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.  




----

I just tried it with 1.8.10 and it works fine:

 >java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
Apr 08, 2016 7:19:27 PM
org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting content.
Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
processOperator
INFORMATION: unsupported/disabled operation: i Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
processOperator
INFORMATION: unsupported/disabled operation: ri Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine
processOperator
INFORMATION: unsupported/disabled operation: BDC Apr 08, 2016 7:19:29 PM org.apache.pdfbox.util.PDFStreamEngine
processOperator
INFORMATION: unsupported/disabled operation: EMC

and the file is displayed.

Maybe you still have the old files in your classpath.
And the current  version is 1.8.11. Not 1.8.10.

Tilman

Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
> Tilman interesting,
>
> This is what I get:
>
> Apr 08, 2016 11:42:31 AM 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: 
> ./Forms/A3161_Blank.pdf 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)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source) 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:2048)
> 	at 
> org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(Secur
> ityHandler.java:352)
>
> Here is my code when using pdfbox-1.8.10-src:
>              	File originalPDF = new File(pdfFileName);
>              	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                  pdDocument = PDDocument.loadNonSeq(originalPDF, 
> raFile);
>
>                  boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                  if (isOriginalDocEncrypted)
>                  {
>                  	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                  }
>                  pdDocumentCatalog = pdDocument.getDocumentCatalog();
>                  
>                  pdAcroForm = pdDocumentCatalog.getAcroForm();
>
>
>
>
> You used Java 1.7.0
> With
> Pdfbox-1.8.6(source),
> bcmail-jdk15-1.44.jar,
> bcprov-jdk15-1.44.jar,
> commons-logging-1.1.2.jar,
> fontbox-1.8.6.jar,
> jempbox-1.8.6.jar
>
> the above code base opens this file:
>    Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>
>
> The code base below will not open it:
> Java 8,
> pdfbox-1.8.10-src
> bcmail-jdk16-1.46.jar
> bcprov-jdk16-1.46.jar
> commons-logging-1.1.2.jar
> fontbox-1.8.10.jar
> jempbox-1.8.10.jar
> icu4j.jar
>
>
> -----Original Message-----
> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
> Sent: Friday, April 08, 2016 10:52 AM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: 
> org.apache.pdfbox.exceptions.WrappedIOException
>
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>
>
>
>
> ----
>
> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>
> Tilman
>
> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> "That means you bypassed the problem instead of confronting and solving it."
>> True..
>>
>> I did as you suggested:
>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>
>> It did not work on the file below.
>>
>> Caution-Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3c
>> xaHczWXc
>>
>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>
>> Try the one in the link.
>>
>> Thank you for your help.
>>
>> Mark....
>>
>>
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-Caution-mailto:THausherr@t-online.de]
>> Sent: Thursday, April 07, 2016 12:39 PM
>> To: users@pdfbox.apache.org
>> Subject: [Non-DoD Source] Re: Update:
>> org.apache.pdfbox.exceptions.WrappedIOException
>>
>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> Hello all,
>>>
>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>> Then did the explorer save to adobe trick.
>> That means you bypassed the problem instead of confronting and solving it.
>>
>>
>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>
>> Tilman
>>
>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>
>>>
>>> public void setValue(String optionValue) throws IOException
>>>        {
>>>        	//TODO - in the instance where an option list doesn't have a default option
>>>            //We need to allow for the case where no selection was made.
>>>            //When reading a blank form, the value returned to us is null. The current code
>>>            //does not handle the possibility of a choice field not being set.
>>>            if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>            {
>>>                super.setValue("");
>>>                return;
>>>            }
>>>            
>>>            int indexSelected = -1;
>>>            COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>            int fieldFlags = getFieldFlags();
>>>            boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>>> (FLAG_EDIT & fieldFlags) != 0;
>>>
>>>            if (options.size() == 0 && !isEditable)
>>>            {
>>>                throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>            }
>>>            else
>>>            {
>>>                // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>                // where sometimes there is 1 string and the rest arrays.
>>>                // This code works either way.
>>>                for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>                {
>>>                    COSBase option = options.getObject(i);
>>>                    if (option instanceof COSArray)
>>>                    {
>>>                        COSArray keyValuePair = (COSArray) option;
>>>                        COSString key = (COSString) keyValuePair.getObject(0);
>>>                        COSString value = (COSString) keyValuePair.getObject(1);
>>>                        if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>                        {
>>>                            // have the parent draw the appearance stream with the value
>>>                            if ((FLAG_COMBO & fieldFlags) != 0)
>>>                            {
>>>                                super.setValue(value.getString());
>>>                            }
>>>                            else
>>>                            {
>>>                                COSArray indexEntries = new COSArray();
>>>                                indexEntries.add(COSInteger.get((long) i));
>>>                                getDictionary().setItem(COSName.I, indexEntries);
>>>                                setListboxValue(value.getString());
>>>                            }
>>>                            // but then use the key as the V entry
>>>                            getDictionary().setItem(COSName.V, key);
>>>                            indexSelected = i;
>>>
>>>                        }
>>>                    }
>>>                    else
>>>                    {
>>>                        COSString value = (COSString) option;
>>>                        if (optionValue.equals(value.getString()))
>>>                        {
>>>                            super.setValue(optionValue);
>>>                            indexSelected = i;
>>>                        }
>>>                    }
>>>                }
>>>            }
>>>            if (indexSelected == -1 && isEditable)
>>>            {
>>>                super.setValue(optionValue);
>>>            }
>>>            else if (indexSelected == -1)
>>>            {
>>>                throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>            }
>>>            else
>>>            {
>>>                COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>                if (indexArray != null)
>>>                {
>>>                    indexArray.clear();
>>>                    indexArray.add(COSInteger.get(indexSelected));
>>>                }
>>>            }
>>>        }
>>>
>>>
>>> V/R,
>>> Mark Strein
>>>
>>> TRAC-FLVN
>>> Wargaming and Simulations Directorate Analytic Tools Division - 
>>> Paving Crew Keeper of the Codes
>>> 913-684-9309
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> - To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by Tilman Hausherr <TH...@t-online.de>.
I just tried it with 1.8.10 and it works fine:

 >java -jar pdfbox-app-1.8.10.jar PDFReader -nonSeq "XXXXX\A3161_Blank.pdf"
Apr 08, 2016 7:19:27 PM 
org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
WARNUNG: PDF file 'XXXXXX\A3161_Blank.pdf' does not allow extracting 
content.
Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine 
processOperator
INFORMATION: unsupported/disabled operation: i
Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine 
processOperator
INFORMATION: unsupported/disabled operation: ri
Apr 08, 2016 7:19:28 PM org.apache.pdfbox.util.PDFStreamEngine 
processOperator
INFORMATION: unsupported/disabled operation: BDC
Apr 08, 2016 7:19:29 PM org.apache.pdfbox.util.PDFStreamEngine 
processOperator
INFORMATION: unsupported/disabled operation: EMC

and the file is displayed.

Maybe you still have the old files in your classpath.
And the current  version is 1.8.11. Not 1.8.10.

Tilman

Am 08.04.2016 um 19:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS 
CTR (US):
> Tilman interesting,
>
> This is what I get:
>
> Apr 08, 2016 11:42:31 AM org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
> WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
> Error occured when trying to load the PDF file: ./Forms/A3161_Blank.pdf
> 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)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
> 	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
> 	at src.utility.DA3161.<init>(DA3161.java:51)
> 	at src.utility.PDF3161.<init>(PDF3161.java:23)
> 	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
> 	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
> 	at src.application.Main$19.actionPerformed(Main.java:890)
> 	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
> 	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
> 	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
> 	at javax.swing.AbstractButton.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
> 	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
> 	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
> 	at java.awt.Component.processMouseEvent(Unknown Source)
> 	at javax.swing.JComponent.processMouseEvent(Unknown Source)
> 	at java.awt.Component.processEvent(Unknown Source)
> 	at java.awt.Container.processEvent(Unknown Source)
> 	at java.awt.Component.dispatchEventImpl(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
> 	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
> 	at java.awt.Container.dispatchEventImpl(Unknown Source)
> 	at java.awt.Window.dispatchEventImpl(Unknown Source)
> 	at java.awt.Component.dispatchEvent(Unknown Source)
> 	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
> 	at java.awt.EventQueue.access$500(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.awt.EventQueue$3.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.awt.EventQueue$4.run(Unknown Source)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
> 	at java.awt.EventQueue.dispatchEvent(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
> 	at java.awt.EventDispatchThread.run(Unknown Source)
> 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:2048)
> 	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:352)
>
> Here is my code when using pdfbox-1.8.10-src:
>              	File originalPDF = new File(pdfFileName);
>              	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
>                  pdDocument = PDDocument.loadNonSeq(originalPDF, raFile);
>
>                  boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
>                  if (isOriginalDocEncrypted)
>                  {
>                  	pdDocument.openProtection(new StandardDecryptionMaterial(""));
>                  }
>                  pdDocumentCatalog = pdDocument.getDocumentCatalog();
>                  
>                  pdAcroForm = pdDocumentCatalog.getAcroForm();
>
>
>
>
> You used Java 1.7.0
> With
> Pdfbox-1.8.6(source),
> bcmail-jdk15-1.44.jar,
> bcprov-jdk15-1.44.jar,
> commons-logging-1.1.2.jar,
> fontbox-1.8.6.jar,
> jempbox-1.8.6.jar
>
> the above code base opens this file:
>    https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)
>
>
> The code base below will not open it:
> Java 8,
> pdfbox-1.8.10-src
> bcmail-jdk16-1.46.jar
> bcprov-jdk16-1.46.jar
> commons-logging-1.1.2.jar
> fontbox-1.8.10.jar
> jempbox-1.8.10.jar
> icu4j.jar
>
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Friday, April 08, 2016 10:52 AM
> To: users@pdfbox.apache.org
> Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException
>
> All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.
>
>
>
>
> ----
>
> I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.
>
> Tilman
>
> Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> "That means you bypassed the problem instead of confronting and solving it."
>> True..
>>
>> I did as you suggested:
>> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>>
>> It did not work on the file below.
>>
>> Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc
>>
>> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>>
>> Try the one in the link.
>>
>> Thank you for your help.
>>
>> Mark....
>>
>>
>> -----Original Message-----
>> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
>> Sent: Thursday, April 07, 2016 12:39 PM
>> To: users@pdfbox.apache.org
>> Subject: [Non-DoD Source] Re: Update:
>> org.apache.pdfbox.exceptions.WrappedIOException
>>
>> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>>> Hello all,
>>>
>>> I hacked my way around it. Used my old software to save the pdf with security removed.
>>> Then did the explorer save to adobe trick.
>> That means you bypassed the problem instead of confronting and solving it.
>>
>>
>> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>>
>> Tilman
>>
>>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>>
>>>
>>> public void setValue(String optionValue) throws IOException
>>>        {
>>>        	//TODO - in the instance where an option list doesn't have a default option
>>>            //We need to allow for the case where no selection was made.
>>>            //When reading a blank form, the value returned to us is null. The current code
>>>            //does not handle the possibility of a choice field not being set.
>>>            if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>>            {
>>>                super.setValue("");
>>>                return;
>>>            }
>>>            
>>>            int indexSelected = -1;
>>>            COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>>            int fieldFlags = getFieldFlags();
>>>            boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 &&
>>> (FLAG_EDIT & fieldFlags) != 0;
>>>
>>>            if (options.size() == 0 && !isEditable)
>>>            {
>>>                throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>>            }
>>>            else
>>>            {
>>>                // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>>                // where sometimes there is 1 string and the rest arrays.
>>>                // This code works either way.
>>>                for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>>                {
>>>                    COSBase option = options.getObject(i);
>>>                    if (option instanceof COSArray)
>>>                    {
>>>                        COSArray keyValuePair = (COSArray) option;
>>>                        COSString key = (COSString) keyValuePair.getObject(0);
>>>                        COSString value = (COSString) keyValuePair.getObject(1);
>>>                        if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>>                        {
>>>                            // have the parent draw the appearance stream with the value
>>>                            if ((FLAG_COMBO & fieldFlags) != 0)
>>>                            {
>>>                                super.setValue(value.getString());
>>>                            }
>>>                            else
>>>                            {
>>>                                COSArray indexEntries = new COSArray();
>>>                                indexEntries.add(COSInteger.get((long) i));
>>>                                getDictionary().setItem(COSName.I, indexEntries);
>>>                                setListboxValue(value.getString());
>>>                            }
>>>                            // but then use the key as the V entry
>>>                            getDictionary().setItem(COSName.V, key);
>>>                            indexSelected = i;
>>>
>>>                        }
>>>                    }
>>>                    else
>>>                    {
>>>                        COSString value = (COSString) option;
>>>                        if (optionValue.equals(value.getString()))
>>>                        {
>>>                            super.setValue(optionValue);
>>>                            indexSelected = i;
>>>                        }
>>>                    }
>>>                }
>>>            }
>>>            if (indexSelected == -1 && isEditable)
>>>            {
>>>                super.setValue(optionValue);
>>>            }
>>>            else if (indexSelected == -1)
>>>            {
>>>                throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>>            }
>>>            else
>>>            {
>>>                COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>>                if (indexArray != null)
>>>                {
>>>                    indexArray.clear();
>>>                    indexArray.add(COSInteger.get(indexSelected));
>>>                }
>>>            }
>>>        }
>>>
>>>
>>> V/R,
>>> Mark Strein
>>>
>>> TRAC-FLVN
>>> Wargaming and Simulations Directorate Analytic Tools Division -
>>> Paving Crew Keeper of the Codes
>>> 913-684-9309
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by "Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US)" <ma...@mail.mil>.
Tilman interesting,

This is what I get:

Apr 08, 2016 11:42:31 AM org.apache.pdfbox.pdfparser.NonSequentialPDFParser prepareDecryption
WARNING: PDF file '.\Forms\A3161_Blank.pdf' does not allow extracting content.
Error occured when trying to load the PDF file: ./Forms/A3161_Blank.pdf
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)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager$PDFFileManager.<init>(FormFileManager.java:927)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:122)
	at lib.TRACJavaLibrary.io.formFile.FormFileManager.<init>(FormFileManager.java:86)
	at src.utility.DA3161.<init>(DA3161.java:51)
	at src.utility.PDF3161.<init>(PDF3161.java:23)
	at src.userInterface.HRPanel.getDA3161(HRPanel.java:1931)
	at src.userInterface.HRPanel.createDA3161(HRPanel.java:2227)
	at src.application.Main$19.actionPerformed(Main.java:890)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.AbstractButton.doClick(Unknown Source)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.awt.EventQueue.access$500(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.awt.EventQueue$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.awt.EventQueue$4.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
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:2048)
	at org.apache.pdfbox.pdmodel.encryption.SecurityHandler.encryptData(SecurityHandler.java:352)

Here is my code when using pdfbox-1.8.10-src:
            	File originalPDF = new File(pdfFileName); 
            	RandomAccess raFile = new RandomAccessFile(new File("TempFile"),"rw");
                pdDocument = PDDocument.loadNonSeq(originalPDF, raFile);

                boolean isOriginalDocEncrypted = pdDocument.isEncrypted();
                if (isOriginalDocEncrypted) 
                {
                	pdDocument.openProtection(new StandardDecryptionMaterial("")); 
                }
                pdDocumentCatalog = pdDocument.getDocumentCatalog();    
                
                pdAcroForm = pdDocumentCatalog.getAcroForm();




You used Java 1.7.0
With 
Pdfbox-1.8.6(source),
bcmail-jdk15-1.44.jar,
bcprov-jdk15-1.44.jar,
commons-logging-1.1.2.jar,
fontbox-1.8.6.jar,
jempbox-1.8.6.jar

the above code base opens this file:
  https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc    (file name should have been A3161_Blank.pdf)


The code base below will not open it:
Java 8,
pdfbox-1.8.10-src
bcmail-jdk16-1.46.jar
bcprov-jdk16-1.46.jar
commons-logging-1.1.2.jar
fontbox-1.8.10.jar
jempbox-1.8.10.jar
icu4j.jar


-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Friday, April 08, 2016 10:52 AM
To: users@pdfbox.apache.org
Subject: Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

All active links contained in this email were disabled.  Please verify the identity of the sender, and confirm the authenticity of all links contained within the message prior to copying and pasting the address to a Web browser.  




----

I was able to open this file with 2.0, 1.8.11, both classic and nonSeq parser. It failed to open in the 1.8.6 version.

Tilman

Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
> "That means you bypassed the problem instead of confronting and solving it."
> True..
>
> I did as you suggested:
> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>
> It did not work on the file below.
>
> Caution-https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc
>
> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>
> Try the one in the link.
>
> Thank you for your help.
>
> Mark....
>
>
> -----Original Message-----
> From: Tilman Hausherr [Caution-mailto:THausherr@t-online.de]
> Sent: Thursday, April 07, 2016 12:39 PM
> To: users@pdfbox.apache.org
> Subject: [Non-DoD Source] Re: Update: 
> org.apache.pdfbox.exceptions.WrappedIOException
>
> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Hello all,
>>
>> I hacked my way around it. Used my old software to save the pdf with security removed.
>> Then did the explorer save to adobe trick.
> That means you bypassed the problem instead of confronting and solving it.
>
>
> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>
> Tilman
>
>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>
>>
>> public void setValue(String optionValue) throws IOException
>>       {
>>       	//TODO - in the instance where an option list doesn't have a default option
>>           //We need to allow for the case where no selection was made.
>>           //When reading a blank form, the value returned to us is null. The current code
>>           //does not handle the possibility of a choice field not being set.
>>           if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>           {
>>               super.setValue("");
>>               return;
>>           }
>>           
>>           int indexSelected = -1;
>>           COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>           int fieldFlags = getFieldFlags();
>>           boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 && 
>> (FLAG_EDIT & fieldFlags) != 0;
>>
>>           if (options.size() == 0 && !isEditable)
>>           {
>>               throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>           }
>>           else
>>           {
>>               // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>               // where sometimes there is 1 string and the rest arrays.
>>               // This code works either way.
>>               for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>               {
>>                   COSBase option = options.getObject(i);
>>                   if (option instanceof COSArray)
>>                   {
>>                       COSArray keyValuePair = (COSArray) option;
>>                       COSString key = (COSString) keyValuePair.getObject(0);
>>                       COSString value = (COSString) keyValuePair.getObject(1);
>>                       if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>                       {
>>                           // have the parent draw the appearance stream with the value
>>                           if ((FLAG_COMBO & fieldFlags) != 0)
>>                           {
>>                               super.setValue(value.getString());
>>                           }
>>                           else
>>                           {
>>                               COSArray indexEntries = new COSArray();
>>                               indexEntries.add(COSInteger.get((long) i));
>>                               getDictionary().setItem(COSName.I, indexEntries);
>>                               setListboxValue(value.getString());
>>                           }
>>                           // but then use the key as the V entry
>>                           getDictionary().setItem(COSName.V, key);
>>                           indexSelected = i;
>>
>>                       }
>>                   }
>>                   else
>>                   {
>>                       COSString value = (COSString) option;
>>                       if (optionValue.equals(value.getString()))
>>                       {
>>                           super.setValue(optionValue);
>>                           indexSelected = i;
>>                       }
>>                   }
>>               }
>>           }
>>           if (indexSelected == -1 && isEditable)
>>           {
>>               super.setValue(optionValue);
>>           }
>>           else if (indexSelected == -1)
>>           {
>>               throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>           }
>>           else
>>           {
>>               COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>               if (indexArray != null)
>>               {
>>                   indexArray.clear();
>>                   indexArray.add(COSInteger.get(indexSelected));
>>               }
>>           }
>>       }
>>
>>
>> V/R,
>> Mark Strein
>>
>> TRAC-FLVN
>> Wargaming and Simulations Directorate Analytic Tools Division - 
>> Paving Crew Keeper of the Codes
>> 913-684-9309
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException

Posted by Tilman Hausherr <TH...@t-online.de>.
I was able to open this file with 2.0, 1.8.11, both classic and nonSeq 
parser. It failed to open in the 1.8.6 version.

Tilman

Am 08.04.2016 um 15:09 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS 
CTR (US):
> "That means you bypassed the problem instead of confronting and solving it."
> True..
>
> I did as you suggested:
> "PDDocument doc = PDDocument.loadNonSeq(new File(...));"
>
> It did not work on the file below.
>
> https://drive.google.com/open?id=0B6pmrwnJExGzVWQ3S3cxaHczWXc
>
> The pdf I pointed you to yesterday was not a fillable or sign able version that we use here.
>
> Try the one in the link.
>
> Thank you for your help.
>
> Mark....
>
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Thursday, April 07, 2016 12:39 PM
> To: users@pdfbox.apache.org
> Subject: [Non-DoD Source] Re: Update: org.apache.pdfbox.exceptions.WrappedIOException
>
> Am 07.04.2016 um 17:06 schrieb Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US):
>> Hello all,
>>
>> I hacked my way around it. Used my old software to save the pdf with security removed.
>> Then did the explorer save to adobe trick.
> That means you bypassed the problem instead of confronting and solving it.
>
>
> Re your code change suggestion - I can't comment it, I suggest you post a diff patch in JIRA. Don't forget to mention what version this is for.
>
> Tilman
>
>> I would like to make a suggested code change in the PDChoiceField class if I may(see TODO):
>>
>>
>> public void setValue(String optionValue) throws IOException
>>       {
>>       	//TODO - in the instance where an option list doesn't have a default option
>>           //We need to allow for the case where no selection was made.
>>           //When reading a blank form, the value returned to us is null. The current code
>>           //does not handle the possibility of a choice field not being set.
>>           if(optionValue==null||optionValue.equalsIgnoreCase(""))
>>           {
>>               super.setValue("");
>>               return;
>>           }
>>           
>>           int indexSelected = -1;
>>           COSArray options = (COSArray) getDictionary().getDictionaryObject(COSName.OPT);
>>           int fieldFlags = getFieldFlags();
>>           boolean isEditable = (FLAG_COMBO & fieldFlags) != 0 &&
>> (FLAG_EDIT & fieldFlags) != 0;
>>
>>           if (options.size() == 0 && !isEditable)
>>           {
>>               throw new IOException("Error: You cannot set a value for a choice field if there are no options.");
>>           }
>>           else
>>           {
>>               // YXJ: Changed the order of the loops. Acrobat produces PDF's
>>               // where sometimes there is 1 string and the rest arrays.
>>               // This code works either way.
>>               for (int i = 0; i < options.size() && indexSelected == -1; i++)
>>               {
>>                   COSBase option = options.getObject(i);
>>                   if (option instanceof COSArray)
>>                   {
>>                       COSArray keyValuePair = (COSArray) option;
>>                       COSString key = (COSString) keyValuePair.getObject(0);
>>                       COSString value = (COSString) keyValuePair.getObject(1);
>>                       if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
>>                       {
>>                           // have the parent draw the appearance stream with the value
>>                           if ((FLAG_COMBO & fieldFlags) != 0)
>>                           {
>>                               super.setValue(value.getString());
>>                           }
>>                           else
>>                           {
>>                               COSArray indexEntries = new COSArray();
>>                               indexEntries.add(COSInteger.get((long) i));
>>                               getDictionary().setItem(COSName.I, indexEntries);
>>                               setListboxValue(value.getString());
>>                           }
>>                           // but then use the key as the V entry
>>                           getDictionary().setItem(COSName.V, key);
>>                           indexSelected = i;
>>
>>                       }
>>                   }
>>                   else
>>                   {
>>                       COSString value = (COSString) option;
>>                       if (optionValue.equals(value.getString()))
>>                       {
>>                           super.setValue(optionValue);
>>                           indexSelected = i;
>>                       }
>>                   }
>>               }
>>           }
>>           if (indexSelected == -1 && isEditable)
>>           {
>>               super.setValue(optionValue);
>>           }
>>           else if (indexSelected == -1)
>>           {
>>               throw new IOException("Error: '" + optionValue + "' was not an available option.");
>>           }
>>           else
>>           {
>>               COSArray indexArray = (COSArray) getDictionary().getDictionaryObject(COSName.I);
>>               if (indexArray != null)
>>               {
>>                   indexArray.clear();
>>                   indexArray.add(COSInteger.get(indexSelected));
>>               }
>>           }
>>       }
>>
>>
>> V/R,
>> Mark Strein
>>
>> TRAC-FLVN
>> Wargaming and Simulations Directorate
>> Analytic Tools Division - Paving Crew
>> Keeper of the Codes
>> 913-684-9309
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org