pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1635903 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: pdfparser/NonSequentialPDFParser.java pdmodel/fdf/FDFDocument.java
Date Sat, 01 Nov 2014 09:08:19 GMT
Author: lehmi
Date: Sat Nov  1 09:08:19 2014
New Revision: 1635903

URL: http://svn.apache.org/r1635903
Log:
PDFBOX-2468: switch FDFDocument to NonSequentialParser, enable FDF support within NonSequentialParser

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java

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=1635903&r1=1635902&r2=1635903&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
Sat Nov  1 09:08:19 2014
@@ -441,10 +441,20 @@ public class NonSequentialPDFParser exte
             throw new IOException("Missing root object specification in trailer.");
         }
 
-        parseObjectDynamically(root, false);
+        COSBase rootObject = parseObjectDynamically(root, false);
 
-        // ---- resolve all objects (including pages)
-        if (!parseMinimalCatalog)
+        // ---- resolve all objects
+        if (isFDFDocment)
+        {
+        	// A FDF doesn't have a catalog, all FDF fields are within the root object
+            if (rootObject instanceof COSDictionary)
+            {
+                parseDictObjects((COSDictionary) rootObject, (COSName[]) null);
+                allPagesParsed = true;
+                document.setDecrypted();
+            }
+        }
+        else if(!parseMinimalCatalog)
         {
             COSObject catalogObj = document.getCatalog();
             if (catalogObj != null)
@@ -903,18 +913,21 @@ public class NonSequentialPDFParser exte
                 initialParse();
             }
 
-            final int pageCount = getPageNumber();
-
-            if (!allPagesParsed)
+            // a FDF doesn't have any pages
+            if (!isFDFDocment)
             {
-                for (int pNr = 0; pNr < pageCount; pNr++)
-                {
-                    getPage(pNr);
-                }
-                allPagesParsed = true;
-                document.setDecrypted();
+	            final int pageCount = getPageNumber();
+	
+	            if (!allPagesParsed)
+	            {
+	                for (int pNr = 0; pNr < pageCount; pNr++)
+	                {
+	                    getPage(pNr);
+	                }
+	                allPagesParsed = true;
+	                document.setDecrypted();
+	            }
             }
-
             exceptionOccurred = false;
         }
         finally

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java?rev=1635903&r1=1635902&r2=1635903&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fdf/FDFDocument.java Sat Nov
 1 09:08:19 2014
@@ -31,11 +31,8 @@ import java.io.Writer;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSDocument;
 import org.apache.pdfbox.cos.COSName;
-
-import org.apache.pdfbox.pdfparser.PDFParser;
-
+import org.apache.pdfbox.pdfparser.NonSequentialPDFParser;
 import org.apache.pdfbox.pdfwriter.COSWriter;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -43,8 +40,7 @@ import org.w3c.dom.Element;
  * This is the in-memory representation of the FDF document.  You need to call
  * close() on this object when you are done using it!!
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.6 $
+ * @author Ben Litchfield
  */
 public class FDFDocument implements Closeable
 {
@@ -199,7 +195,7 @@ public class FDFDocument implements Clos
      */
     public static FDFDocument load( InputStream input ) throws IOException
     {
-        PDFParser parser = new PDFParser( input );
+        NonSequentialPDFParser parser = new NonSequentialPDFParser(input, false);
         parser.parse();
         return parser.getFDFDocument();
     }



Mime
View raw message