Top Description Fields Constructors Methods
org.apache.pdfbox.pdfparser

public Class COSParser

extends BaseParser
implements ICOSParser
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.cos.ICOSParser
Known Direct Subclasses
org.apache.pdfbox.pdfparser.FDFParser, org.apache.pdfbox.pdfparser.PDFParser, org.apache.pdfbox.pdfparser.BruteForceParser
Imports
java.io.IOException, .InputStream, java.nio.charset.StandardCharsets, java.security.GeneralSecurityException, .KeyStore, java.util.HashMap, .HashSet, .List, .Map, .Optional, .Map.Entry, .Set, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.cos.COSArray, .COSBase, .COSDictionary, .COSDocument, .COSName, .COSNull, .COSNumber, .COSObject, .COSObjectKey, .COSStream, .ICOSParser, org.apache.pdfbox.io.IOUtils, .RandomAccessRead, .RandomAccessReadView, .RandomAccessStreamCache.StreamCacheCreateFunction, org.apache.pdfbox.pdfparser.XrefTrailerResolver.XRefType, org.apache.pdfbox.pdmodel.encryption.AccessPermission, .DecryptionMaterial, .InvalidPasswordException, .PDEncryption, .ProtectionPolicy, .PublicKeyDecryptionMaterial, .SecurityHandler, .StandardDecryptionMaterial, org.apache.pdfbox.util.StringUtil

COS-Parser which first reads startxref and xref tables in order to know valid objects and parse only these objects. This class is a much enhanced version of QuickParser presented in PDFBOX-1104 by Jeremy Villalobos.

Field Summary

Modifier and TypeField and Description
private AccessPermission
private BruteForceParser
private final Map<Long, Map<COSObjectKey, COSBase>>
decompressedObjects

Intermediate cache.

private static final int
DEFAULT_TRAIL_BYTECOUNT

How many trailing bytes to read for EOF marker.

private PDEncryption
private static final byte[]
private static final byte[]
protected static final char[]
EOF_MARKER

EOF-marker.

private static final String
private static final String
protected long
fileLen

file length.

protected boolean
private boolean
isLenient

is parser using auto healing capacity ?

private String
private InputStream
private static final Log
private static final long
protected static final char[]
OBJ_MARKER

obj-marker.

private String
private static final String
private static final String
private int
readTrailBytes

how many trailing bytes to read for EOF marker.

protected SecurityHandler<? extends ProtectionPolicy>
securityHandler

The security handler.

private static final char[]
private final byte[]
private static final int
public static final String
SYSPROP_EOFLOOKUPRANGE

The range within the %%EOF marker will be searched.

private boolean
private static final int
X

private static final char[]
protected XrefTrailerResolver
xrefTrailerResolver

Collects all Xref/trailer objects and resolves them into single object using startxref reference.

Inherited from org.apache.pdfbox.pdfparser.BaseParser:
AASCII_CRASCII_LFBDDEFdocumentEENDOBJ_STRINGENDSTREAM_STRINGJMMAX_LENGTH_LONGNORSsourceSTREAM_STRINGT

Constructor Summary

AccessConstructor and Description
public
COSParser(RandomAccessRead
input representing the pdf.
source
)

Default constructor.

public
COSParser(RandomAccessRead
input representing the pdf.
source
,
String
password to be used for decryption.
password
,
InputStream
key store to be used for decryption when using public key security
keyStore
,
String
alias to be used for decryption when using public key security
keyAlias
)

Constructor for encrypted pdfs.

public
COSParser(RandomAccessRead
input representing the pdf.
source
,
String
password to be used for decryption.
password
,
InputStream
key store to be used for decryption when using public key security
keyStore
,
String
alias to be used for decryption when using public key security
keyAlias
,
RandomAccessStreamCache.StreamCacheCreateFunction
a function to create an instance of the stream cache
streamCacheCreateFunction
)

Constructor for encrypted pdfs.

Method Summary

Modifier and TypeMethod and Description
private long

Returns:

the fixed offset
calculateXRefFixedOffset
(long
the given offset where to look at
objectOffset
)

Try to find a fixed offset for the given xref table/stream.

protected void
checkPages(COSDictionary
the root dictionary of the pdf
root
)

Check if all entries of the pages dictionary are present.

private int
private long

Returns:

the revised offset
checkXRefOffset
(long startXRefOffset)

Check if the cross reference table/stream can be found at the current offset.

private void
checkXrefOffsets()

Check the XRef table by dereferencing all objects and fixing the offset if necessary.

private boolean

Returns:

the revised offset
checkXRefStreamOffset
(long
the expected start offset of the XRef stream
startXRefOffset
)

Check if the cross reference stream can be found at the current offset.

public RandomAccessReadView
createRandomAccessReadView(long
start position within the underlying random access read
startPosition
,
long
stream length
streamLength
)

Implements org.apache.pdfbox.cos.ICOSParser.createRandomAccessReadView.

Creates a random access read view starting at the given position with the given length.

public COSBase
dereferenceCOSObject(COSObject
the COSObject which references the COSBase object to be dereferenced.
obj
)

Implements org.apache.pdfbox.cos.ICOSParser.dereferenceCOSObject.

Dereference the COSBase object which is referenced by the given COSObject.

private COSObjectKey

Returns:

returns the found/fixed object key
findObjectKey
(COSObjectKey
the key of object we are looking for
objectKey
,
long
the offset where to look
offset
,
Map<COSObjectKey, Long>
a map with with all known xref entries
xrefOffset
)

Check if the given object can be found at the given offset.

protected AccessPermission

Returns:

The access permission of document that was parsed.
getAccessPermission
()

This will get the AccessPermission.

private BruteForceParser
protected PDEncryption

Returns:

The encryption dictionary of the document that was parsed.
getEncryption
()

This will get the encryption dictionary.

private COSNumber
getLength(final COSBase lengthBaseObj)

Returns length value referred to or defined in given object.

private Long
getObjectOffset(COSObjectKey objKey, boolean requireExistingNotCompressedObj)

private long

Returns:

the offset of StartXref
getStartxrefOffset
()

Looks for and parses startxref.

private void
public boolean

Returns:

true if parser is lenient
isLenient
()

Return true if parser is lenient.

private boolean

Returns:

true if the bytes are in place, false if not
isString
(byte[]
the bytes of the string to look for
string
)

Checks if the given string can be found at the current offset.

protected boolean

Returns:

true if the bytes are in place, false if not
isString
(char[]
the bytes of the string to look for
string
)

Checks if the given string can be found at the current offset.

protected int

Returns:

start offset of pattern within buffer or -1 if pattern could not be found
lastIndexOf
(final char[]
pattern to search for
pattern
,
final byte[]
buffer to search pattern in
buf
,
final int
offset (exclusive) where lookup starts at
endOff
)

Searches last appearance of pattern within buffer.

protected COSStream

Returns:

parsed pdf stream.
parseCOSStream
(COSDictionary
dictionary that goes with this stream.
dic
)

This will read a COSStream from the input stream using length attribute within dictionary.

protected boolean

Returns:

true if a FDF header was found
parseFDFHeader
()

Parse the header of a fdf.

private COSBase
parseFileObject(Long objOffset, final COSObjectKey objKey)

private boolean
parseHeader(String headerMarker, String defaultVersion)

protected synchronized COSBase

Returns:

the parsed object (which is also added to document object)
parseObjectDynamically
(COSObjectKey
key of object to be parsed
objKey
,
boolean
if true the object to be parsed must be defined in xref (comment: null objects may be missing from xref) and it must not be a compressed object within object stream (this is used to circumvent being stuck in a loop in a malicious PDF)
requireExistingNotCompressedObj
)

Parse the object for the given object key.

protected COSBase

Returns:

the parsed object
parseObjectStreamObject
(long
the number of the offset stream
objstmObjNr
,
COSObjectKey
the key of the object to be parsed
key
)

Parse the object with the given key from the object stream with the given number.

protected boolean

Returns:

true if a PDF header was found
parsePDFHeader
()

Parse the header of a pdf.

private long

Returns:

the startxref value or -1 on parsing error
parseStartXref
()

This will parse the startxref section from the stream.

private boolean

Returns:

false on parsing error
parseTrailer
()

This will parse the trailer from the stream and add it to the state.

private COSDictionary

Returns:

the trailer dictionary
parseXref
(long
start offset of the first table
startXRefOffset
)

Parses cross reference tables.

private long

Returns:

value of PREV item in dictionary or -1 if no such item exists
parseXrefObjStream
(long objByteOffset, boolean isStandalone)

Parses an xref object stream starting with indirect object id.

protected boolean

Returns:

false on parsing error
parseXrefTable
(long
the offset to start at
startByteOffset
)

This will parse the xref table from the stream and add it to the state The XrefTable contents are ignored.

protected void
prepareDecryption()

Prepare for decryption.

private long
readUntilEndStream(final EndstreamFilterStream
stream we write out to.
out
)

This method will read through the current stream object until we find the keyword "endstream" meaning we're at the end of this object.

protected boolean

Returns:

true if the xref trailer resolver should be reset
resetTrailerResolver
()

Indicates whether the xref trailer resolver should be reset or not.

protected COSDictionary

Returns:

a COSDictionary containing the trailer information
retrieveTrailer
()

Read the trailer information and provide a COSDictionary containing the trailer information.

public void
setEOFLookupRange(int
number of trailing bytes
byteCount
)

Sets how many trailing bytes of PDF file are searched for EOF marker and 'startxref' marker.

protected void
setLenient(boolean
try to handle malformed PDFs.
lenient
)

Change the parser leniency flag.

private boolean
validateStreamLength(long streamLength)

private boolean
Inherited from org.apache.pdfbox.pdfparser.BaseParser:
getObjectKeyisClosingisClosingisDigitisDigitisEndOfNameisEOFisEOLisEOLisSpaceisSpaceisWhitespaceisWhitespaceparseCOSArrayparseCOSDictionaryparseCOSNameparseCOSStringparseDirObjectreadExpectedCharreadExpectedStringreadGenerationNumberreadIntreadLinereadLongreadObjectNumberreadStringreadStringreadStringNumberskipSpacesskipWhiteSpaces

Field Detail

accessPermissionback to summary
private AccessPermission accessPermission
bruteForceParserback to summary
private BruteForceParser bruteForceParser
decompressedObjectsback to summary
private final Map<Long, Map<COSObjectKey, COSBase>> decompressedObjects

Intermediate cache. Contains all objects of already read compressed object streams. Objects are removed after dereferencing them.

DEFAULT_TRAIL_BYTECOUNTback to summary
private static final int DEFAULT_TRAIL_BYTECOUNT

How many trailing bytes to read for EOF marker.

encryptionback to summary
private PDEncryption encryption
ENDOBJback to summary
private static final byte[] ENDOBJ
ENDSTREAMback to summary
private static final byte[] ENDSTREAM
EOF_MARKERback to summary
protected static final char[] EOF_MARKER

EOF-marker.

FDF_DEFAULT_VERSIONback to summary
private static final String FDF_DEFAULT_VERSION
FDF_HEADERback to summary
private static final String FDF_HEADER
fileLenback to summary
protected long fileLen

file length.

initialParseDoneback to summary
protected boolean initialParseDone
isLenientback to summary
private boolean isLenient

is parser using auto healing capacity ?

keyAliasback to summary
private String keyAlias
keyStoreInputStreamback to summary
private InputStream keyStoreInputStream
LOGback to summary
private static final Log LOG

Hides org.apache.pdfbox.pdfparser.BaseParser.LOG.

MINIMUM_SEARCH_OFFSETback to summary
private static final long MINIMUM_SEARCH_OFFSET
OBJ_MARKERback to summary
protected static final char[] OBJ_MARKER

obj-marker.

passwordback to summary
private String password
Annotations
@SuppressWarnings:squid:S2068
PDF_DEFAULT_VERSIONback to summary
private static final String PDF_DEFAULT_VERSION
PDF_HEADERback to summary
private static final String PDF_HEADER
readTrailBytesback to summary
private int readTrailBytes

how many trailing bytes to read for EOF marker.

securityHandlerback to summary
protected SecurityHandler<? extends ProtectionPolicy> securityHandler

The security handler.

STARTXREFback to summary
private static final char[] STARTXREF
strmBufback to summary
private final byte[] strmBuf
STRMBUFLENback to summary
private static final int STRMBUFLEN
SYSPROP_EOFLOOKUPRANGEback to summary
public static final String SYSPROP_EOFLOOKUPRANGE

The range within the %%EOF marker will be searched. Useful if there are additional characters after %%EOF within the PDF.

trailerWasRebuildback to summary
private boolean trailerWasRebuild
Xback to summary
private static final int X
XREF_TABLEback to summary
private static final char[] XREF_TABLE
xrefTrailerResolverback to summary
protected XrefTrailerResolver xrefTrailerResolver

Collects all Xref/trailer objects and resolves them into single object using startxref reference.

Constructor Detail

COSParserback to summary
public COSParser(RandomAccessRead source) throws IOException

Default constructor.

Parameters
source:RandomAccessRead

input representing the pdf.

Exceptions
IOException:
if something went wrong
COSParserback to summary
public COSParser(RandomAccessRead source, String password, InputStream keyStore, String keyAlias) throws IOException

Constructor for encrypted pdfs.

Parameters
source:RandomAccessRead

input representing the pdf.

password:String

password to be used for decryption.

keyStore:InputStream

key store to be used for decryption when using public key security

keyAlias:String

alias to be used for decryption when using public key security

Exceptions
IOException:
if the source data could not be read
COSParserback to summary
public COSParser(RandomAccessRead source, String password, InputStream keyStore, String keyAlias, RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction) throws IOException

Constructor for encrypted pdfs.

Parameters
source:RandomAccessRead

input representing the pdf.

password:String

password to be used for decryption.

keyStore:InputStream

key store to be used for decryption when using public key security

keyAlias:String

alias to be used for decryption when using public key security

streamCacheCreateFunction:RandomAccessStreamCache.StreamCacheCreateFunction

a function to create an instance of the stream cache

Exceptions
IOException:
if the source data could not be read

Method Detail

calculateXRefFixedOffsetback to summary
private long calculateXRefFixedOffset(long objectOffset) throws IOException

Try to find a fixed offset for the given xref table/stream.

Parameters
objectOffset:long

the given offset where to look at

Returns:long

the fixed offset

Exceptions
IOException:
if something went wrong
checkPagesback to summary
protected void checkPages(COSDictionary root) throws IOException

Check if all entries of the pages dictionary are present. Those which can't be dereferenced are removed.

Parameters
root:COSDictionary

the root dictionary of the pdf

Exceptions
IOException:
if the page tree root is null
checkPagesDictionaryback to summary
private int checkPagesDictionary(COSDictionary pagesDict, Set<COSObject> set)
checkXRefOffsetback to summary
private long checkXRefOffset(long startXRefOffset) throws IOException

Check if the cross reference table/stream can be found at the current offset.

Returns:long

the revised offset

checkXrefOffsetsback to summary
private void checkXrefOffsets() throws IOException

Check the XRef table by dereferencing all objects and fixing the offset if necessary.

Exceptions
IOException:
if something went wrong.
checkXRefStreamOffsetback to summary
private boolean checkXRefStreamOffset(long startXRefOffset) throws IOException

Check if the cross reference stream can be found at the current offset.

Parameters
startXRefOffset:long

the expected start offset of the XRef stream

Returns:boolean

the revised offset

Exceptions
IOException:
if something went wrong
createRandomAccessReadViewback to summary
public RandomAccessReadView createRandomAccessReadView(long startPosition, long streamLength) throws IOException

Implements org.apache.pdfbox.cos.ICOSParser.createRandomAccessReadView.

Doc from org.apache.pdfbox.cos.ICOSParser.createRandomAccessReadView.

Creates a random access read view starting at the given position with the given length.

Parameters
startPosition:long

start position within the underlying random access read

streamLength:long

stream length

Returns:RandomAccessReadView

the random access read view

Annotations
@Override
Exceptions
IOException:
if something went wrong when creating the view for the RandomAccessRead
dereferenceCOSObjectback to summary
public COSBase dereferenceCOSObject(COSObject obj) throws IOException

Implements org.apache.pdfbox.cos.ICOSParser.dereferenceCOSObject.

Doc from org.apache.pdfbox.cos.ICOSParser.dereferenceCOSObject.

Dereference the COSBase object which is referenced by the given COSObject.

Parameters
obj:COSObject

the COSObject which references the COSBase object to be dereferenced.

Returns:COSBase

the referenced object

Annotations
@Override
Exceptions
IOException:
if something went wrong when dereferencing the COSBase object
findObjectKeyback to summary
private COSObjectKey findObjectKey(COSObjectKey objectKey, long offset, Map<COSObjectKey, Long> xrefOffset) throws IOException

Check if the given object can be found at the given offset. Returns the provided object key if everything is ok. If the generation number differs it will be fixed and a new object key is returned.

Parameters
objectKey:COSObjectKey

the key of object we are looking for

offset:long

the offset where to look

xrefOffset:Map<COSObjectKey, Long>

a map with with all known xref entries

Returns:COSObjectKey

returns the found/fixed object key

Exceptions
IOException:
if something went wrong
getAccessPermissionback to summary
protected AccessPermission getAccessPermission() throws IOException

This will get the AccessPermission. The document must be parsed before this is called.

Returns:AccessPermission

The access permission of document that was parsed.

Exceptions
IOException:
If there is an error getting the document.
getBruteForceParserback to summary
private BruteForceParser getBruteForceParser() throws IOException
getEncryptionback to summary
protected PDEncryption getEncryption() throws IOException

This will get the encryption dictionary. The document must be parsed before this is called.

Returns:PDEncryption

The encryption dictionary of the document that was parsed.

Exceptions
IOException:
If there is an error getting the document.
getLengthback to summary
private COSNumber getLength(final COSBase lengthBaseObj) throws IOException

Returns length value referred to or defined in given object.

getObjectOffsetback to summary
private Long getObjectOffset(COSObjectKey objKey, boolean requireExistingNotCompressedObj) throws IOException
getStartxrefOffsetback to summary
private long getStartxrefOffset() throws IOException

Looks for and parses startxref. We first look for last '%%EOF' marker (within last DEFAULT_TRAIL_BYTECOUNT bytes (or range set via setEOFLookupRange(int)) and go back to find startxref.

Returns:long

the offset of StartXref

Exceptions
IOException:
If something went wrong.
initback to summary
private void init(RandomAccessStreamCache.StreamCacheCreateFunction streamCacheCreateFunction)
isLenientback to summary
public boolean isLenient()

Return true if parser is lenient. Meaning auto healing capacity of the parser are used.

Returns:boolean

true if parser is lenient

isStringback to summary
private boolean isString(byte[] string) throws IOException

Checks if the given string can be found at the current offset.

Parameters
string:byte[]

the bytes of the string to look for

Returns:boolean

true if the bytes are in place, false if not

Exceptions
IOException:
if something went wrong
isStringback to summary
protected boolean isString(char[] string) throws IOException

Checks if the given string can be found at the current offset.

Parameters
string:char[]

the bytes of the string to look for

Returns:boolean

true if the bytes are in place, false if not

Exceptions
IOException:
if something went wrong
lastIndexOfback to summary
protected int lastIndexOf(final char[] pattern, final byte[] buf, final int endOff)

Searches last appearance of pattern within buffer. Lookup before _lastOff and goes back until 0.

Parameters
pattern:char[]

pattern to search for

buf:byte[]

buffer to search pattern in

endOff:int

offset (exclusive) where lookup starts at

Returns:int

start offset of pattern within buffer or -1 if pattern could not be found

parseCOSStreamback to summary
protected COSStream parseCOSStream(COSDictionary dic) throws IOException

This will read a COSStream from the input stream using length attribute within dictionary. If length attribute is a indirect reference it is first resolved to get the stream length. This means we copy stream data without testing for 'endstream' or 'endobj' and thus it is no problem if these keywords occur within stream. We require 'endstream' to be found after stream data is read.

Parameters
dic:COSDictionary

dictionary that goes with this stream.

Returns:COSStream

parsed pdf stream.

Exceptions
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.
parseFDFHeaderback to summary
protected boolean parseFDFHeader() throws IOException

Parse the header of a fdf.

Returns:boolean

true if a FDF header was found

Exceptions
IOException:
if something went wrong
parseFileObjectback to summary
private COSBase parseFileObject(Long objOffset, final COSObjectKey objKey) throws IOException
parseHeaderback to summary
private boolean parseHeader(String headerMarker, String defaultVersion) throws IOException
parseObjectDynamicallyback to summary
protected synchronized COSBase parseObjectDynamically(COSObjectKey objKey, boolean requireExistingNotCompressedObj) throws IOException

Parse the object for the given object key.

Parameters
objKey:COSObjectKey

key of object to be parsed

requireExistingNotCompressedObj:boolean

if true the object to be parsed must be defined in xref (comment: null objects may be missing from xref) and it must not be a compressed object within object stream (this is used to circumvent being stuck in a loop in a malicious PDF)

Returns:COSBase

the parsed object (which is also added to document object)

Exceptions
IOException:
If an IO error occurs.
parseObjectStreamObjectback to summary
protected COSBase parseObjectStreamObject(long objstmObjNr, COSObjectKey key) throws IOException

Parse the object with the given key from the object stream with the given number.

Parameters
objstmObjNr:long

the number of the offset stream

key:COSObjectKey

the key of the object to be parsed

Returns:COSBase

the parsed object

Exceptions
IOException:
if something went wrong when parsing the object
parsePDFHeaderback to summary
protected boolean parsePDFHeader() throws IOException

Parse the header of a pdf.

Returns:boolean

true if a PDF header was found

Exceptions
IOException:
if something went wrong
parseStartXrefback to summary
private long parseStartXref() throws IOException

This will parse the startxref section from the stream. The startxref value is ignored.

Returns:long

the startxref value or -1 on parsing error

Exceptions
IOException:
If an IO error occurs.
parseTrailerback to summary
private boolean parseTrailer() throws IOException

This will parse the trailer from the stream and add it to the state.

Returns:boolean

false on parsing error

Exceptions
IOException:
If an IO error occurs.
parseXrefback to summary
private COSDictionary parseXref(long startXRefOffset) throws IOException

Parses cross reference tables.

Parameters
startXRefOffset:long

start offset of the first table

Returns:COSDictionary

the trailer dictionary

Exceptions
IOException:
if something went wrong
parseXrefObjStreamback to summary
private long parseXrefObjStream(long objByteOffset, boolean isStandalone) throws IOException

Parses an xref object stream starting with indirect object id.

Returns:long

value of PREV item in dictionary or -1 if no such item exists

parseXrefTableback to summary
protected boolean parseXrefTable(long startByteOffset) throws IOException

This will parse the xref table from the stream and add it to the state The XrefTable contents are ignored.

Parameters
startByteOffset:long

the offset to start at

Returns:boolean

false on parsing error

Exceptions
IOException:
If an IO error occurs.
prepareDecryptionback to summary
protected void prepareDecryption() throws IOException

Prepare for decryption.

Exceptions
IOException:
if something went wrong
InvalidPasswordException:
If the password is incorrect.
readUntilEndStreamback to summary
private long readUntilEndStream(final EndstreamFilterStream out) throws IOException

This method will read through the current stream object until we find the keyword "endstream" meaning we're at the end of this object. Some pdf files, however, forget to write some endstream tags and just close off objects with an "endobj" tag so we have to handle this case as well. This method is optimized using buffered IO and reduced number of byte compare operations.

Parameters
out:EndstreamFilterStream

stream we write out to.

Exceptions
IOException:
if something went wrong
resetTrailerResolverback to summary
protected boolean resetTrailerResolver()

Indicates whether the xref trailer resolver should be reset or not. Should be overwritten if the xref trailer resolver is needed after the initial parsing.

Returns:boolean

true if the xref trailer resolver should be reset

retrieveTrailerback to summary
protected COSDictionary retrieveTrailer() throws IOException

Read the trailer information and provide a COSDictionary containing the trailer information.

Returns:COSDictionary

a COSDictionary containing the trailer information

Exceptions
IOException:
if something went wrong
setEOFLookupRangeback to summary
public void setEOFLookupRange(int byteCount)

Sets how many trailing bytes of PDF file are searched for EOF marker and 'startxref' marker. If not set we use default value DEFAULT_TRAIL_BYTECOUNT.

We check that new value is at least 16. However for practical use cases this value should not be lower than 1000; even 2000 was found to not be enough in some cases where some trailing garbage like HTML snippets followed the EOF marker.

In case system property SYSPROP_EOFLOOKUPRANGE is defined this value will be set on initialization but can be overwritten later.

Parameters
byteCount:int

number of trailing bytes

setLenientback to summary
protected void setLenient(boolean lenient)

Change the parser leniency flag. This method can only be called before the parsing of the file.

Parameters
lenient:boolean

try to handle malformed PDFs.

validateStreamLengthback to summary
private boolean validateStreamLength(long streamLength) throws IOException
validateXrefOffsetsback to summary
private boolean validateXrefOffsets(Map<COSObjectKey, Long> xrefOffset) throws IOException