pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1762084 - in /pdfbox/trunk/pdfbox/src: main/java/org/apache/pdfbox/pdmodel/PDPage.java test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
Date Fri, 23 Sep 2016 19:31:43 GMT
Author: tilman
Date: Fri Sep 23 19:31:43 2016
New Revision: 1762084

URL: http://svn.apache.org/viewvc?rev=1762084&view=rev
Log:
PDFBOX-3510: return empty input stream if no content stream in a page

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java?rev=1762084&r1=1762083&r2=1762084&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDPage.java Fri Sep 23 19:31:43
2016
@@ -160,7 +160,7 @@ public class PDPage implements COSObject
             }
             return new SequenceInputStream(Collections.enumeration(inputStreams));
         }
-        return null;
+        return new ByteArrayInputStream(new byte[0]);
     }
 
     /**

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java?rev=1762084&r1=1762083&r2=1762084&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/TestPDPageContentStream.java
Fri Sep 23 19:31:43 2016
@@ -17,6 +17,7 @@
 package org.apache.pdfbox.pdmodel;
 
 import java.io.IOException;
+import java.util.List;
 import junit.framework.TestCase;
 import org.apache.pdfbox.contentstream.operator.Operator;
 import org.apache.pdfbox.cos.COSFloat;
@@ -81,4 +82,18 @@ public class TestPDPageContentStream ext
         assertEquals(0.8f, ((COSFloat)pageTokens.get(3)).floatValue());
         assertEquals("K", ((Operator)pageTokens.get(4)).getName());
     }
+
+    /**
+     * PDFBOX-3510: missing content stream should not fail.
+     * 
+     * @throws IOException 
+     */
+    public void testMissingContentStream() throws IOException
+    {
+        PDPage page = new PDPage();
+        PDFStreamParser parser = new PDFStreamParser(page);
+        parser.parse();
+        List<Object> tokens = parser.getTokens();
+        assertEquals(0, tokens.size());
+    }
 }



Mime
View raw message