pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1709894 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java
Date Wed, 21 Oct 2015 18:19:40 GMT
Author: tilman
Date: Wed Oct 21 18:19:40 2015
New Revision: 1709894

URL: http://svn.apache.org/viewvc?rev=1709894&view=rev
Log:
PDFBOX-3041: correct treatment of first /W element 0, as suggested by Andrea Vacondio

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java?rev=1709894&r1=1709893&r2=1709894&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFXrefStreamParser.java
Wed Oct 21 18:19:40 2015
@@ -113,14 +113,24 @@ public class PDFXrefStreamParser extends
                 byte[] currLine = new byte[lineSize];
                 pdfSource.read(currLine);
 
-                int type = 0;
-                /*
-                 * Grabs the number of bytes specified for the first column in
-                 * the W array and stores it.
-                 */
-                for(int i = 0; i < w0; i++)
+                int type;
+                if (w0 == 0)
                 {
-                    type += (currLine[i] & 0x00ff) << ((w0 - i - 1)* 8);
+                    // "If the first element is zero, 
+                    // the type field shall not be present, and shall default to type 1"
+                    type = 1;
+                }
+                else
+                {
+                    type = 0;
+                    /*
+                     * Grabs the number of bytes specified for the first column in
+                     * the W array and stores it.
+                     */
+                    for (int i = 0; i < w0; i++)
+                    {
+                        type += (currLine[i] & 0x00ff) << ((w0 - i - 1) * 8);
+                    }
                 }
                 //Need to remember the current objID
                 Integer objID = objIter.next();



Mime
View raw message