pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1688667 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form: PDButton.java PDRadioButton.java
Date Wed, 01 Jul 2015 15:10:05 GMT
Author: tilman
Date: Wed Jul  1 15:10:05 2015
New Revision: 1688667

URL: http://svn.apache.org/r1688667
Log:
PDFBOX-2849: no need to create appearance if already there

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java?rev=1688667&r1=1688666&r2=1688667&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDButton.java
Wed Jul  1 15:10:05 2015
@@ -221,7 +221,22 @@ public abstract class PDButton extends P
     @Override
     void constructAppearances() throws IOException
     {
-        // TODO: implement appearance generation for buttons
-        throw new UnsupportedOperationException("not implemented");
+        boolean hasAppearance = false;
+        COSBase apBase = dictionary.getDictionaryObject(COSName.AP);
+        if (apBase instanceof COSDictionary)
+        {
+            COSDictionary apDict = (COSDictionary) apBase;
+            COSBase nBase = apDict.getDictionaryObject(COSName.N);
+            if (nBase instanceof COSDictionary)
+            {
+                COSDictionary nDict = (COSDictionary) apBase;
+                hasAppearance = nDict.size() > 0;
+            }            
+        }
+        if (!hasAppearance)
+        {
+            // TODO: implement appearance generation for buttons
+            throw new UnsupportedOperationException("Appearance generation is not implemented
yet, see PDFBOX-2849");
+        }
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java?rev=1688667&r1=1688666&r2=1688667&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDRadioButton.java
Wed Jul  1 15:10:05 2015
@@ -23,6 +23,7 @@ import org.apache.pdfbox.cos.COSDictiona
 import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceEntry;
 
 /**
@@ -197,6 +198,20 @@ public final class PDRadioButton extends
         }
         applyChange();
     }
+    
+    @Override
+    void constructAppearances() throws IOException
+    {
+        for (PDAnnotationWidget widget : getWidgets())
+        {
+            PDAppearanceDictionary appearance = widget.getAppearance();
+            if (appearance == null || appearance.getNormalAppearance() == null)
+            {
+                // TODO: implement appearance generation for radio buttons
+                throw new UnsupportedOperationException("Appearance generation is not implemented
yet, see PDFBOX-2849");
+            }
+        }
+    }  
 
     /**
      * Sets the default value.



Mime
View raw message