pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1652833 - /pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Date Sun, 18 Jan 2015 19:09:00 GMT
Author: lehmi
Date: Sun Jan 18 19:09:00 2015
New Revision: 1652833

URL: http://svn.apache.org/r1652833
Log:
PDFBOX-2600: use pdfSource instead of pdfFile

Modified:
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1652833&r1=1652832&r2=1652833&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Sun Jan 18 19:09:00 2015
@@ -73,6 +73,7 @@ import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.pdfparser.BaseParser;
 import org.apache.pdfbox.pdfparser.NonSequentialPDFParser;
 import org.apache.pdfbox.pdfparser.PDFObjectStreamParser;
+import org.apache.pdfbox.pdfparser.PDFParser;
 import org.apache.pdfbox.pdfparser.XrefTrailerResolver.XRefType;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.persistence.util.COSObjectKey;
@@ -85,7 +86,7 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
 
-public class PreflightParser extends NonSequentialPDFParser
+public class PreflightParser extends PDFParser
 {
     /**
      * Define a one byte encoding that hasn't specific encoding in UTF-8 charset. Avoid unexpected
error when the
@@ -266,18 +267,16 @@ public class PreflightParser extends Non
      */
     protected void checkPdfHeader()
     {
-        BufferedReader reader = null;
         try
         {
-            reader = new BufferedReader(new InputStreamReader(new FileInputStream(getPdfFile()),
encoding));
-            String firstLine = reader.readLine();
+            pdfSource.seek(0);
+            String firstLine = readLine();
             if (firstLine == null || !firstLine.matches("%PDF-1\\.[1-9]"))
             {
                 addValidationError(new ValidationError(PreflightConstants.ERROR_SYNTAX_HEADER,
                         "First line must match %PDF-1.\\d"));
             }
-
-            String secondLine = reader.readLine();
+            String secondLine = readLine();
             if (secondLine != null)
             {
                 byte[] secondLineAsBytes = secondLine.getBytes(encoding.name());
@@ -306,16 +305,13 @@ public class PreflightParser extends Non
                             "Second line must contains at least 4 bytes greater than 127"));
                 }
             }
+            pdfSource.seek(0);
         }
         catch (IOException e)
         {
             addValidationError(new ValidationError(PreflightConstants.ERROR_SYNTAX_HEADER,
                     "Unable to read the PDF file : " + e.getMessage(), e));
         }
-        finally
-        {
-            IOUtils.closeQuietly(reader);
-        }
     }
 
     /**



Mime
View raw message