Class PreflightParser
java.lang.Object
org.apache.pdfbox.pdfparser.BaseParser
org.apache.pdfbox.pdfparser.COSParser
org.apache.pdfbox.pdfparser.PDFParser
org.apache.pdfbox.preflight.parser.PreflightParser
- All Implemented Interfaces:
org.apache.pdfbox.cos.ICOSParser
public class PreflightParser
extends org.apache.pdfbox.pdfparser.PDFParser
-
Field Summary
Fields inherited from class org.apache.pdfbox.pdfparser.COSParser
EOF_MARKER, fileLen, initialParseDone, OBJ_MARKER, securityHandler, SYSPROP_EOFLOOKUPRANGE, xrefTrailerResolverFields inherited from class org.apache.pdfbox.pdfparser.BaseParser
A, ASCII_CR, ASCII_LF, B, D, DEF, document, E, ENDOBJ_STRING, ENDSTREAM_STRING, J, M, N, O, R, S, source, STREAM_STRING, T -
Constructor Summary
ConstructorsConstructorDescriptionPreflightParser(File file) Constructor.PreflightParser(String filename) Constructor.PreflightParser(org.apache.pdfbox.io.RandomAccessRead rar) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.pdfbox.pdmodel.PDDocumentprotected voidprotected intlastIndexOf(char[] pattern, byte[] buf, int endOff) org.apache.pdfbox.pdmodel.PDDocumentparse()org.apache.pdfbox.pdmodel.PDDocumentParse the given file and check if it is a confirming file according to the given format.org.apache.pdfbox.pdmodel.PDDocumentparse(Format format, PreflightConfiguration config) Parse the given file and check if it is a confirming file according to the given format.protected org.apache.pdfbox.cos.COSArrayprotected org.apache.pdfbox.cos.COSNameprotected org.apache.pdfbox.cos.COSStreamparseCOSStream(org.apache.pdfbox.cos.COSDictionary dic) Wraps theCOSParser.parseCOSStream(COSDictionary)to check rules on 'stream' and 'endstream' keywords.protected org.apache.pdfbox.cos.COSStringCheck that the hexa string contains only an even number of Hexadecimal characters.protected org.apache.pdfbox.cos.COSBaseCallBaseParser.parseDirObject()check limit range for Float, Integer and number of Dictionary entries.protected org.apache.pdfbox.cos.COSBaseparseObjectDynamically(org.apache.pdfbox.cos.COSObjectKey objKey, boolean requireExistingNotCompressedObj) protected booleanparseXrefTable(long startByteOffset) Same method than the COSParser.parseXrefTable(long) with additional controls : - EOL mandatory after the 'xref' keyword - Cross reference subsection header uses single white space as separator - and so onprotected booleanstatic ValidationResultLoad and validate the given file.Methods inherited from class org.apache.pdfbox.pdfparser.PDFParser
load, load, parseMethods inherited from class org.apache.pdfbox.pdfparser.COSParser
checkPages, createRandomAccessReadView, dereferenceCOSObject, getAccessPermission, getEncryption, isLenient, isString, parseFDFHeader, parseObjectStreamObject, parsePDFHeader, prepareDecryption, retrieveTrailer, setEOFLookupRange, setLenientMethods inherited from class org.apache.pdfbox.pdfparser.BaseParser
getObjectKey, isClosing, isClosing, isDigit, isDigit, isEndOfName, isEOF, isEOL, isEOL, isSpace, isSpace, isWhitespace, isWhitespace, parseCOSDictionary, readExpectedChar, readExpectedString, readGenerationNumber, readInt, readLine, readLong, readObjectNumber, readString, readString, readStringNumber, skipLinebreak, skipSpaces, skipWhiteSpaces
-
Constructor Details
-
PreflightParser
Constructor.- Parameters:
file-- Throws:
IOException- if there is a reading error.
-
PreflightParser
Constructor.- Parameters:
rar- input source- Throws:
IOException- if there is a reading error.
-
PreflightParser
Constructor.- Parameters:
filename-- Throws:
IOException- if there is a reading error.
-
-
Method Details
-
parse
- Overrides:
parsein classorg.apache.pdfbox.pdfparser.PDFParser- Throws:
IOException
-
parse
Parse the given file and check if it is a confirming file according to the given format.- Parameters:
format- format that the document should follow (defaultFormat.PDF_A1B)- Returns:
- the parsed document.
- Throws:
IOException
-
parse
public org.apache.pdfbox.pdmodel.PDDocument parse(Format format, PreflightConfiguration config) throws IOException Parse the given file and check if it is a confirming file according to the given format.- Parameters:
format- format that the document should follow (defaultFormat.PDF_A1B)config- Configuration bean that will be used by the PreflightDocument. If null the format is used to determine the default configuration.- Returns:
- the parsed document.
- Throws:
IOException
-
createDocument
- Overrides:
createDocumentin classorg.apache.pdfbox.pdfparser.PDFParser- Throws:
IOException
-
initialParse
- Overrides:
initialParsein classorg.apache.pdfbox.pdfparser.PDFParser- Throws:
IOException
-
resetTrailerResolver
protected boolean resetTrailerResolver()- Overrides:
resetTrailerResolverin classorg.apache.pdfbox.pdfparser.COSParser
-
parseXrefTable
Same method than the COSParser.parseXrefTable(long) with additional controls : - EOL mandatory after the 'xref' keyword - Cross reference subsection header uses single white space as separator - and so on- Overrides:
parseXrefTablein classorg.apache.pdfbox.pdfparser.COSParser- Parameters:
startByteOffset- the offset to start at- Returns:
- false on parsing error
- Throws:
IOException- If an IO error occurs.
-
parseCOSStream
protected org.apache.pdfbox.cos.COSStream parseCOSStream(org.apache.pdfbox.cos.COSDictionary dic) throws IOException Wraps theCOSParser.parseCOSStream(COSDictionary)to check rules on 'stream' and 'endstream' keywords.checkStreamKeyWord()andcheckEndstreamKeyWord(org.apache.pdfbox.cos.COSDictionary, long)- Overrides:
parseCOSStreamin classorg.apache.pdfbox.pdfparser.COSParser- Parameters:
dic- dictionary that goes with this stream.- Returns:
- parsed pdf stream.
- Throws:
IOException- if an error occurred reading the stream, like problems with reading length attribute, stream does not end with 'endstream' after data read, stream too short etc.
-
parseCOSArray
- Overrides:
parseCOSArrayin classorg.apache.pdfbox.pdfparser.BaseParser- Throws:
IOException
-
parseCOSName
- Overrides:
parseCOSNamein classorg.apache.pdfbox.pdfparser.BaseParser- Throws:
IOException
-
parseCOSString
Check that the hexa string contains only an even number of Hexadecimal characters. Once it is done, reset the offset at the beginning of the string and callBaseParser.parseCOSString()- Overrides:
parseCOSStringin classorg.apache.pdfbox.pdfparser.BaseParser- Returns:
- The parsed PDF string.
- Throws:
IOException- If there is an error reading from the stream.
-
parseDirObject
CallBaseParser.parseDirObject()check limit range for Float, Integer and number of Dictionary entries.- Overrides:
parseDirObjectin classorg.apache.pdfbox.pdfparser.BaseParser- Returns:
- The parsed object.
- Throws:
IOException- if there is an error during parsing.
-
parseObjectDynamically
protected org.apache.pdfbox.cos.COSBase parseObjectDynamically(org.apache.pdfbox.cos.COSObjectKey objKey, boolean requireExistingNotCompressedObj) throws IOException - Overrides:
parseObjectDynamicallyin classorg.apache.pdfbox.pdfparser.COSParser- Throws:
IOException
-
lastIndexOf
protected int lastIndexOf(char[] pattern, byte[] buf, int endOff) - Overrides:
lastIndexOfin classorg.apache.pdfbox.pdfparser.COSParser
-
validate
Load and validate the given file. Returns the validation result and closes the read pdf.- Parameters:
file- thew file to be read and validated- Returns:
- the validation result
- Throws:
IOException- in case of a file reading or parsing error
-