pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1597548 - in /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser: NonSequentialPDFParser.java PDFParser.java
Date Mon, 26 May 2014 10:04:30 GMT
Author: tilman
Date: Mon May 26 10:04:30 2014
New Revision: 1597548

URL: http://svn.apache.org/r1597548
Log:
PDFBOX-1739: skip extra xref entries in RegisSTAR documents

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

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=1597548&r1=1597547&r2=1597548&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
Mon May 26 10:04:30 2014
@@ -83,15 +83,9 @@ import org.apache.pdfbox.persistence.uti
  */
 public class NonSequentialPDFParser extends PDFParser
 {
-    private static final String PDF_HEADER = "%PDF-";
-    private static final String FDF_HEADER = "%FDF-";
-    
-    private static final String PDF_DEFAULT_VERSION = "1.4";
-    private static final String FDF_DEFAULT_VERSION = "1.0";
-
-	private static final byte[] XREF = new byte[] { 'x', 'r', 'e', 'f' };
+    private static final byte[] XREF = new byte[] { 'x', 'r', 'e', 'f' };
 
-	private static final int E = 'e';
+    private static final int E = 'e';
     private static final int N = 'n';
     private static final int X = 'x';
 
@@ -362,6 +356,17 @@ public class NonSequentialPDFParser exte
                 // use existing parser to parse xref table
                 parseXrefTable(prev);
                 // parse the last trailer.
+                long trailerOffset = pdfSource.getOffset();
+                //PDFBOX-1739 skip extra xref entries in RegisSTAR documents
+                while (isLenient && pdfSource.peek() != 't')
+                {
+                    if (pdfSource.getOffset() == trailerOffset)
+                    {
+                        // warn only the first time
+                        LOG.warn("Expected trailer object at position " + trailerOffset +
", keep trying");
+                    }
+                    readLine();
+                }
                 if (!parseTrailer())
                 {
                     throw new IOException("Expected trailer object at position: " + pdfSource.getOffset());

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=1597548&r1=1597547&r2=1597548&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java (original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java Mon
May 26 10:04:30 2014
@@ -748,6 +748,10 @@ public class PDFParser extends BaseParse
         {
             long currObjID = readObjectNumber(); // first obj id
             long count = readLong(); // the number of objects in the xref table
+            if (count == 0)
+            {
+                LOG.warn("Count in xref table is 0 at offset " + pdfSource.getOffset());
+            }
             skipSpaces();
             for(int i = 0; i < count; i++)
             {



Mime
View raw message