pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1560474 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/COSDocument.java pdfparser/NonSequentialPDFParser.java
Date Wed, 22 Jan 2014 19:01:18 GMT
Author: lehmi
Date: Wed Jan 22 19:01:18 2014
New Revision: 1560474

URL: http://svn.apache.org/r1560474
Log:
PDFBOX-1822: don't rely on the trailer dictionary to determine if the pdf has a xref table
or a xref stream

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1560474&r1=1560473&r2=1560474&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Wed Jan 22 19:01:18
2014
@@ -95,6 +95,8 @@ public class COSDocument extends COSBase
     
     private boolean closed = false;
 
+    private boolean isXRefStream;
+    
     /**
      * Flag to skip malformed or otherwise unparseable input where possible.
      */
@@ -757,16 +759,22 @@ public class COSDocument extends COSBase
     }
 
     /**
-     * Determines it the trailer is a XRef stream or not.
+     * Determines if the trailer is a XRef stream or not.
      * 
      * @return true if the trailer is a XRef stream
      */
     public boolean isXRefStream()
     {
-        if (trailer != null)
-        {
-            return COSName.XREF.equals(trailer.getItem(COSName.TYPE));
-        }
-        return false;
+        return isXRefStream;
+    }
+    
+    /**
+     * Sets isXRefStream to the given value.
+     * 
+     * @param isXRefStreamValue the new value for isXRefStream
+     */
+    public void setIsXRefStream(boolean isXRefStreamValue)
+    {
+        isXRefStream = isXRefStreamValue;
     }
 }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1560474&r1=1560473&r2=1560474&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
Wed Jan 22 19:01:18 2014
@@ -353,6 +353,7 @@ public class NonSequentialPDFParser exte
             // -- parse xref
             if (pdfSource.peek() == X)
             {
+                document.setIsXRefStream(false);
                 // xref table and trailer
                 // use existing parser to parse xref table
                 parseXrefTable(prev);
@@ -376,6 +377,7 @@ public class NonSequentialPDFParser exte
             }
             else
             {
+                document.setIsXRefStream(true);
                 // parse xref stream
                 prev = parseXrefObjStream(prev);
                 if (isLenient && prev > -1)



Mime
View raw message