NonSequentialPDFParser
public class PDFParser extends BaseParser
Modifier and Type | Field | Description |
---|---|---|
protected boolean |
isFDFDocment |
|
protected XrefTrailerResolver |
xrefTrailerResolver |
Collects all Xref/trailer objects and resolves them into single
object using startxref reference.
|
DEF, document, ENDOBJ, ENDSTREAM, forceParsing, pdfSource, PROP_PUSHBACK_SIZE
Constructor | Description |
---|---|
PDFParser(java.io.InputStream input) |
Constructor.
|
PDFParser(java.io.InputStream input,
RandomAccess rafi) |
Constructor to allow control over RandomAccessFile.
|
PDFParser(java.io.InputStream input,
RandomAccess rafi,
boolean force) |
Constructor to allow control over RandomAccessFile.
|
Modifier and Type | Method | Description |
---|---|---|
void |
clearResources() |
Release all used resources.
|
COSDocument |
getDocument() |
This will get the document that was parsed.
|
FDFDocument |
getFDFDocument() |
This will get the FDF document that was parsed.
|
PDDocument |
getPDDocument() |
This will get the PD document that was parsed.
|
protected boolean |
isContinueOnError(java.lang.Exception e) |
Returns true if parsing should be continued.
|
void |
parse() |
This will parse the stream and populate the COSDocument object.
|
protected void |
parseHeader() |
|
protected boolean |
parseStartXref() |
This will parse the startxref section from the stream.
|
protected boolean |
parseTrailer() |
This will parse the trailer from the stream and add it to the state.
|
void |
parseXrefStream(COSStream stream,
long objByteOffset) |
Fills XRefTrailerResolver with data of given stream.
|
void |
parseXrefStream(COSStream stream,
long objByteOffset,
boolean isStandalone) |
Fills XRefTrailerResolver with data of given stream.
|
protected boolean |
parseXrefTable(long startByteOffset) |
This will parse the xref table from the stream and add it to the state
The XrefTable contents are ignored.
|
protected void |
readVersionInTrailer(COSDictionary parsedTrailer) |
The document catalog can also have a /Version parameter which overrides the version specified
in the header if, and only if it is greater.
|
void |
setTempDirectory(java.io.File tmpDir) |
This is the directory where pdfbox will create a temporary file
for storing pdf document stream in.
|
isClosing, isClosing, isEndOfName, isEOL, isEOL, isWhitespace, isWhitespace, parseBoolean, parseCOSArray, parseCOSDictionary, parseCOSName, parseCOSStream, parseCOSString, parseCOSString, parseDirObject, readExpectedString, readGenerationNumber, readInt, readLine, readLong, readObjectNumber, readString, readString, readStringNumber, readUntilEndStream, setDocument, skipSpaces
protected boolean isFDFDocment
protected XrefTrailerResolver xrefTrailerResolver
public PDFParser(java.io.InputStream input) throws java.io.IOException
input
- The input stream that contains the PDF document.java.io.IOException
- If there is an error initializing the stream.public PDFParser(java.io.InputStream input, RandomAccess rafi) throws java.io.IOException
input
- The input stream that contains the PDF document.rafi
- The RandomAccessFile to be used in internal COSDocumentjava.io.IOException
- If there is an error initializing the stream.public PDFParser(java.io.InputStream input, RandomAccess rafi, boolean force) throws java.io.IOException
input
- The input stream that contains the PDF document.rafi
- The RandomAccessFile to be used in internal COSDocumentforce
- When true, the parser will skip corrupt pdf objects and
will continue parsing at the next object in the filejava.io.IOException
- If there is an error initializing the stream.public void setTempDirectory(java.io.File tmpDir)
tmpDir
- The directory to create scratch files needed to store
pdf document streams.protected boolean isContinueOnError(java.lang.Exception e)
e
- The exception if vailable. Can be null if there is no exception availablepublic void parse() throws java.io.IOException
java.io.IOException
- If there is an error reading from the stream or corrupt data
is found.protected void parseHeader() throws java.io.IOException
java.io.IOException
public COSDocument getDocument() throws java.io.IOException
java.io.IOException
- If there is an error getting the document.public PDDocument getPDDocument() throws java.io.IOException
java.io.IOException
- If there is an error getting the document.public FDFDocument getFDFDocument() throws java.io.IOException
java.io.IOException
- If there is an error getting the document.protected boolean parseStartXref() throws java.io.IOException
java.io.IOException
- If an IO error occurs.protected boolean parseXrefTable(long startByteOffset) throws java.io.IOException
startByteOffset
- the offset to start atjava.io.IOException
- If an IO error occurs.protected boolean parseTrailer() throws java.io.IOException
java.io.IOException
- If an IO error occurs.protected void readVersionInTrailer(COSDictionary parsedTrailer)
parsedTrailer
- the parsed catalog in the trailerpublic void parseXrefStream(COSStream stream, long objByteOffset) throws java.io.IOException
stream
- the stream to be readobjByteOffset
- the offset to start atjava.io.IOException
- if there is an error parsing the streampublic void parseXrefStream(COSStream stream, long objByteOffset, boolean isStandalone) throws java.io.IOException
stream
- the stream to be readobjByteOffset
- the offset to start atisStandalone
- should be set to true if the stream is not part of a hybrid xref tablejava.io.IOException
- if there is an error parsing the streampublic void clearResources()
clearResources
in class BaseParser