You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ta...@apache.org on 2017/05/01 18:26:18 UTC
svn commit: r1793390 - in /pdfbox/branches/2.0/pdfbox/src:
main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java
Author: tallison
Date: Mon May 1 18:26:18 2017
New Revision: 1793390
URL: http://svn.apache.org/viewvc?rev=1793390&view=rev
Log:
PDFBOX-3772 -- return null for COSBoolean in PDDocumentCatalog's getOpenAction
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java?rev=1793390&r1=1793389&r2=1793390&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocumentCatalog.java Mon May 1 18:26:18 2017
@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.pdfbox.cos.COSArray;
import org.apache.pdfbox.cos.COSBase;
+import org.apache.pdfbox.cos.COSBoolean;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSObject;
@@ -248,6 +249,17 @@ public class PDDocumentCatalog implement
{
return null;
}
+ else if (openAction instanceof COSBoolean)
+ {
+ if (((COSBoolean) openAction).getValue() == false)
+ {
+ return null;
+ }
+ else
+ {
+ throw new IOException("Can't create OpenAction from COSBoolean");
+ }
+ }
else if (openAction instanceof COSDictionary)
{
return PDActionFactory.createAction((COSDictionary)openAction);
Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java?rev=1793390&r1=1793389&r2=1793390&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDDocumentCatalog.java Mon May 1 18:26:18 2017
@@ -20,9 +20,11 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.List;
+import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@@ -189,4 +191,13 @@ public class TestPDDocumentCatalog
}
}
}
+
+ @Test
+ public void handleBooleanInOpenAction() throws IOException
+ {
+ //PDFBOX-3772 -- allow for COSBoolean
+ PDDocument doc = new PDDocument();
+ doc.getDocumentCatalog().getCOSObject().setBoolean(COSName.OPEN_ACTION, false);
+ assertNull(doc.getDocumentCatalog().getOpenAction());
+ }
}