You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2017/02/02 19:20:55 UTC
svn commit: r1781456 -
/pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Author: tilman
Date: Thu Feb 2 19:20:55 2017
New Revision: 1781456
URL: http://svn.apache.org/viewvc?rev=1781456&view=rev
Log:
PDFBOX-3675: allow scratch file parameter as suggested by Viktor Ivanov
Modified:
pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
Modified: pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java?rev=1781456&r1=1781455&r2=1781456&view=diff
==============================================================================
--- pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java (original)
+++ pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/parser/PreflightParser.java Thu Feb 2 19:20:55 2017
@@ -46,6 +46,7 @@ import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.cos.COSString;
import org.apache.pdfbox.io.IOUtils;
import org.apache.pdfbox.io.RandomAccessBufferedFileInputStream;
+import org.apache.pdfbox.io.ScratchFile;
import org.apache.pdfbox.pdfparser.PDFObjectStreamParser;
import org.apache.pdfbox.pdfparser.PDFParser;
import org.apache.pdfbox.pdfparser.XrefTrailerResolver.XRefType;
@@ -113,6 +114,21 @@ public class PreflightParser extends PDF
/**
* Constructor.
*
+ * @param file
+ * @param scratch
+ * @throws IOException if there is a reading error.
+ */
+ public PreflightParser(File file, ScratchFile scratch) throws IOException
+ {
+ // TODO move file handling outside of the parser
+ super(new RandomAccessBufferedFileInputStream(file), scratch);
+ this.setLenient(false);
+ this.dataSource = new FileDataSource(file);
+ }
+
+ /**
+ * Constructor.
+ *
* @param filename
* @throws IOException if there is a reading error.
*/
@@ -123,6 +139,19 @@ public class PreflightParser extends PDF
}
/**
+ * Constructor.
+ *
+ * @param filename
+ * @param scratch
+ * @throws IOException if there is a reading error.
+ */
+ public PreflightParser(String filename, ScratchFile scratch) throws IOException
+ {
+ // TODO move file handling outside of the parser
+ this(new File(filename), scratch);
+ }
+
+ /**
* Constructor. This one is slower than the file and the filename constructors, because
* a temporary file will be created.
*
@@ -136,6 +165,22 @@ public class PreflightParser extends PDF
this.setLenient(false);
this.dataSource = dataSource;
}
+
+ /**
+ * Constructor. This one is slower than the file and the filename constructors, because
+ * a temporary file will be created.
+ *
+ * @param dataSource the datasource
+ * @param scratch
+ * @throws IOException if there is a reading error.
+ */
+ public PreflightParser(DataSource dataSource, ScratchFile scratch) throws IOException
+ {
+ // TODO move file handling outside of the parser
+ super(new RandomAccessBufferedFileInputStream(dataSource.getInputStream()), scratch);
+ this.setLenient(false);
+ this.dataSource = dataSource;
+ }
/**
* Create an instance of ValidationResult with a ValidationError(UNKNOWN_ERROR)