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

public Class PDFObjectStreamParser

extends BaseParser
Class Inheritance
Imports
java.io.IOException, java.util.HashMap, .Map, .Map.Entry, .TreeMap, org.apache.pdfbox.cos.COSBase, .COSDocument, .COSName, .COSObjectKey, .COSStream

This will parse a PDF 1.5 object stream and extract the object with given object number from the stream.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
private final int
private final int
Inherited from org.apache.pdfbox.pdfparser.BaseParser:
AASCII_CRASCII_LFBDDEFdocumentEENDOBJ_STRINGENDSTREAM_STRINGJMMAX_LENGTH_LONGNORSsourceSTREAM_STRINGT

Constructor Summary

AccessConstructor and Description
public
PDFObjectStreamParser(COSStream
The stream to parse.
stream
,
COSDocument
The document for the current parsing.
document
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public Map<COSObjectKey, COSBase>

Returns:

a map containing all parsed objects using the object number as key
parseAllObjects
()

Parse all compressed objects.

public COSBase

Returns:

the parsed object or null if the object with the given number can't be found
parseObject
(long
the number of the object to b e parsed
objectNumber
)

Search for/parse the object with the given object number.

private Map<Long, Integer>
private Map<Integer, Long>
public Map<Long, Integer>

Returns:

a map off all object numbers and the corresponding offset within the object stream.
readObjectNumbers
()

Read all object numbers from the compressed object stream.

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

Field Detail

firstObjectback to summary
private final int firstObject
numberOfObjectsback to summary
private final int numberOfObjects

Constructor Detail

PDFObjectStreamParserback to summary
public PDFObjectStreamParser(COSStream stream, COSDocument document) throws IOException

Constructor.

Parameters
stream:COSStream

The stream to parse.

document:COSDocument

The document for the current parsing.

Exceptions
IOException:
If there is an error initializing the stream.

Method Detail

parseAllObjectsback to summary
public Map<COSObjectKey, COSBase> parseAllObjects() throws IOException

Parse all compressed objects. The stream is closed after parsing.

Returns:Map<COSObjectKey, COSBase>

a map containing all parsed objects using the object number as key

Exceptions
IOException:
if there is an error while parsing the stream
parseObjectback to summary
public COSBase parseObject(long objectNumber) throws IOException

Search for/parse the object with the given object number. The stream is closed after parsing the object with the given number.

Parameters
objectNumber:long

the number of the object to b e parsed

Returns:COSBase

the parsed object or null if the object with the given number can't be found

Exceptions
IOException:
if there is an error while parsing the stream
privateReadObjectNumbersback to summary
private Map<Long, Integer> privateReadObjectNumbers() throws IOException
privateReadObjectOffsetsback to summary
private Map<Integer, Long> privateReadObjectOffsets() throws IOException
readObjectNumbersback to summary
public Map<Long, Integer> readObjectNumbers() throws IOException

Read all object numbers from the compressed object stream. The stream is closed after reading the object numbers.

Returns:Map<Long, Integer>

a map off all object numbers and the corresponding offset within the object stream.

Exceptions
IOException:
if there is an error while parsing the stream