pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1785686 - in /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel: fdf/FDFField.java interactive/form/PDField.java
Date Mon, 06 Mar 2017 16:49:11 GMT
Author: msahyoun
Date: Mon Mar  6 16:49:11 2017
New Revision: 1785686

URL: http://svn.apache.org/viewvc?rev=1785686&view=rev
Log:
PDFBOX-3596: handle string values from FDF/XFDF import properly; update appearance stream
after value update

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java?rev=1785686&r1=1785685&r2=1785686&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFField.java Mon
Mar  6 16:49:11 2017
@@ -250,6 +250,7 @@ public class FDFField implements COSObje
     public COSBase getCOSValue() throws IOException
     {
         COSBase value = field.getDictionaryObject(COSName.V);
+        
         if (value instanceof COSName)
         {
             return value;
@@ -288,7 +289,7 @@ public class FDFField implements COSObje
         }
         else if (value instanceof String)
         {
-            cos = COSName.getPDFName((String) value);
+            cos = new COSString((String) value);
         }
         else if (value instanceof COSObjectable)
         {

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java?rev=1785686&r1=1785685&r2=1785686&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDField.java
Mon Mar  6 16:49:11 2017
@@ -23,6 +23,9 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.cos.COSStream;
+import org.apache.pdfbox.cos.COSString;
+import org.apache.pdfbox.pdmodel.common.COSArrayList;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.fdf.FDFField;
 import org.apache.pdfbox.pdmodel.interactive.action.PDFormFieldAdditionalActions;
@@ -237,10 +240,37 @@ public abstract class PDField implements
     void importFDF(FDFField fdfField) throws IOException
     {
         COSBase fieldValue = fdfField.getCOSValue();
-        if (fieldValue != null)
+        
+        if (fieldValue != null && this instanceof PDTerminalField)
+        {
+            PDTerminalField currentField = (PDTerminalField) this;
+            
+            if (fieldValue instanceof COSName)
+            {
+                currentField.setValue(((COSName) fieldValue).getName());;
+            }
+            else if (fieldValue instanceof COSString)
+            {
+                currentField.setValue(((COSString) fieldValue).getString());
+            }
+            else if (fieldValue instanceof COSStream)
+            {
+                currentField.setValue(((COSStream) fieldValue).toTextString());
+            }
+            else if (fieldValue instanceof COSArray && this instanceof PDChoice)
+            {
+                ((PDChoice) this).setValue(COSArrayList.convertCOSStringCOSArrayToList((COSArray)
fieldValue));
+            }
+            else if (fieldValue != null)
+            {
+                throw new IOException("Error:Unknown type for field import" + fieldValue);
+            }
+        }
+        else if (fieldValue != null)
         {
             dictionary.setItem(COSName.V, fieldValue);
         }
+        
         Integer ff = fdfField.getFieldFlags();
         if (ff != null)
         {



Mime
View raw message