You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2014/01/22 21:21:58 UTC

svn commit: r1560498 - in /pdfbox/branches/1.8: ./ pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java

Author: lehmi
Date: Wed Jan 22 20:21:57 2014
New Revision: 1560498

URL: http://svn.apache.org/r1560498
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/branches/1.8/   (props changed)
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java

Propchange: pdfbox/branches/1.8/
------------------------------------------------------------------------------
  Merged /pdfbox/trunk:r1560474

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java?rev=1560498&r1=1560497&r2=1560498&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/cos/COSDocument.java Wed Jan 22 20:21:57 2014
@@ -93,6 +93,8 @@ public class COSDocument extends COSBase
     
     private boolean closed = false;
 
+    private boolean isXRefStream;
+    
     /**
      * Flag to skip malformed or otherwise unparseable input where possible.
      */
@@ -755,16 +757,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/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1560498&r1=1560497&r2=1560498&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java Wed Jan 22 20:21:57 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)