Package org.apache.pdfbox.pdfparser
Class PDFStreamParser
java.lang.Object
org.apache.pdfbox.pdfparser.BaseParser
org.apache.pdfbox.pdfparser.PDFStreamParser
This will parse a PDF byte stream and extract operands and such.
- Author:
- Ben Litchfield
-
Field Summary
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, N, O, R, S, STREAM_STRING, T
-
Constructor Summary
ConstructorsConstructorDescriptionPDFStreamParser
(byte[] bytes) Constructor.PDFStreamParser
(PDContentStream contentStream) Constructor.PDFStreamParser
(COSStream stream) Deprecated.PDFStreamParser
(PDStream stream) Deprecated.UsePDFStreamParser(PDContentStream)
instead. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the underlying resource.This will get the tokens that were parsed from the stream by theparse()
method.void
parse()
This will parse all the tokens in the stream.This will parse the next token in the stream.protected String
This will read an operator from the stream.Methods inherited from class org.apache.pdfbox.pdfparser.BaseParser
isClosing, isClosing, isDigit, isDigit, isEndOfName, isEOL, isEOL, isSpace, isSpace, isWhitespace, isWhitespace, parseBoolean, parseCOSArray, parseCOSDictionary, parseCOSName, parseCOSString, parseDirObject, readExpectedChar, readExpectedString, readExpectedString, readGenerationNumber, readInt, readLine, readLong, readObjectNumber, readString, readString, readStringNumber, skipSpaces, skipWhiteSpaces
-
Constructor Details
-
PDFStreamParser
Deprecated.UsePDFStreamParser(PDContentStream)
instead.Constructor.- Parameters:
stream
- The stream to parse.- Throws:
IOException
- If there is an error initializing the stream.
-
PDFStreamParser
Deprecated.UsePDFStreamParser(PDContentStream)
instead.Constructor.- Parameters:
stream
- The stream to parse.- Throws:
IOException
- If there is an error initializing the stream.
-
PDFStreamParser
Constructor.- Parameters:
contentStream
- The content stream to parse.- Throws:
IOException
- If there is an error initializing the stream.
-
PDFStreamParser
public PDFStreamParser(byte[] bytes) Constructor.- Parameters:
bytes
- the bytes to parse.
-
-
Method Details
-
parse
This will parse all the tokens in the stream. This will close the stream when it is finished parsing. You can then access these withgetTokens()
.- Throws:
IOException
- If there is an error while parsing the stream.
-
getTokens
This will get the tokens that were parsed from the stream by theparse()
method.- Returns:
- All of the tokens in the stream.
-
parseNextToken
This will parse the next token in the stream.- Returns:
- The next token in the stream or null if there are no more tokens in the stream.
- Throws:
IOException
- If an io error occurs while parsing the stream.
-
readOperator
This will read an operator from the stream.- Returns:
- The operator that was read from the stream.
- Throws:
IOException
- If there is an error reading from the stream.
-
close
Close the underlying resource.- Throws:
IOException
- if something went wrong
-
PDFStreamParser(PDContentStream)
instead.