Package org.apache.pdfbox.pdfparser
Class PDFObjectStreamParser
- java.lang.Object
-
- org.apache.pdfbox.pdfparser.BaseParser
-
- org.apache.pdfbox.pdfparser.PDFObjectStreamParser
-
public class PDFObjectStreamParser extends BaseParser
This will parse a PDF 1.5 object stream and extract the object with given object number from the stream.
-
-
Field Summary
Fields Modifier and Type Field Description private intfirstObjectprivate intnumberOfObjects-
Fields inherited from class org.apache.pdfbox.pdfparser.BaseParser
A, ASCII_CR, ASCII_LF, B, D, DEF, document, E, ENDOBJ_STRING, ENDSTREAM_STRING, J, M, MAX_LENGTH_LONG, N, O, R, S, source, STREAM_STRING, T
-
-
Constructor Summary
Constructors Constructor Description PDFObjectStreamParser(COSStream stream, COSDocument document)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<COSObjectKey,COSBase>parseAllObjects()Parse all compressed objects.COSBaseparseObject(long objectNumber)Search for/parse the object with the given object number.private java.util.Map<java.lang.Long,java.lang.Integer>privateReadObjectNumbers()private java.util.Map<java.lang.Integer,java.lang.Long>privateReadObjectOffsets()java.util.Map<java.lang.Long,java.lang.Integer>readObjectNumbers()Read all object numbers from the compressed object stream.-
Methods inherited from class org.apache.pdfbox.pdfparser.BaseParser
getObjectKey, isClosing, isClosing, isDigit, isDigit, isEndOfName, isEOF, isEOL, isEOL, isSpace, isSpace, isWhitespace, isWhitespace, parseCOSArray, parseCOSDictionary, parseCOSName, parseCOSString, parseDirObject, readExpectedChar, readExpectedString, readGenerationNumber, readInt, readLine, readLong, readObjectNumber, readString, readString, readStringNumber, skipLinebreak, skipSpaces, skipWhiteSpaces
-
-
-
-
Constructor Detail
-
PDFObjectStreamParser
public PDFObjectStreamParser(COSStream stream, COSDocument document) throws java.io.IOException
Constructor.- Parameters:
stream- The stream to parse.document- The document for the current parsing.- Throws:
java.io.IOException- If there is an error initializing the stream.
-
-
Method Detail
-
parseObject
public COSBase parseObject(long objectNumber) throws java.io.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- the number of the object to b e parsed- Returns:
- the parsed object or null if the object with the given number can't be found
- Throws:
java.io.IOException- if there is an error while parsing the stream
-
parseAllObjects
public java.util.Map<COSObjectKey,COSBase> parseAllObjects() throws java.io.IOException
Parse all compressed objects. The stream is closed after parsing.- Returns:
- a map containing all parsed objects using the object number as key
- Throws:
java.io.IOException- if there is an error while parsing the stream
-
privateReadObjectNumbers
private java.util.Map<java.lang.Long,java.lang.Integer> privateReadObjectNumbers() throws java.io.IOException- Throws:
java.io.IOException
-
privateReadObjectOffsets
private java.util.Map<java.lang.Integer,java.lang.Long> privateReadObjectOffsets() throws java.io.IOException- Throws:
java.io.IOException
-
readObjectNumbers
public java.util.Map<java.lang.Long,java.lang.Integer> readObjectNumbers() throws java.io.IOExceptionRead all object numbers from the compressed object stream. The stream is closed after reading the object numbers.- Returns:
- a map off all object numbers and the corresponding offset within the object stream.
- Throws:
java.io.IOException- if there is an error while parsing the stream
-
-