|
iText 9.8.0 API
|
Tokenizes PDF syntax from a random-access byte source. More...
Public Types |
|
| enum | TokenType { Number, String, Name, Comment, StartArray, EndArray, StartDic, EndDic, Ref, Obj, EndObj, Other, EndOfFile } |
| Token types recognized by this tokenizer. More... |
|
Public Member Functions |
|
| PdfTokenizer (RandomAccessFileOrArray file) | |
| Creates a PdfTokenizer for the specified RandomAccessFileOrArray. More... |
|
| virtual void | Seek (long pos) |
| Sets the position from which the next byte is read. More... |
|
| virtual void | ReadFully (byte[] bytes) |
| Reads enough bytes to fill a destination array. More... |
|
| virtual long | GetPosition () |
| Gets the current source position. More... |
|
| virtual void | Close () |
| Closes the underlying source when closing is enabled. More... |
|
| virtual long | Length () |
| Gets the length of the underlying source. More... |
|
| virtual int | Read () |
| Reads one byte and advances the source position. More... |
|
| virtual int | Peek () |
| Gets the next byte of pdf source without moving source position. More... |
|
| virtual int | Peek (byte[] buffer) |
Gets the next buffer.length bytes of pdf source without moving source position. More... |
|
| virtual String | ReadString (int size) |
| Reads up to a requested number of bytes as character values. More... |
|
| virtual PdfTokenizer.TokenType | GetTokenType () |
| Gets the type of the most recently parsed token. More... |
|
| virtual byte[] | GetByteContent () |
| Copies the bytes of the most recently parsed token. More... |
|
| virtual String | GetStringValue () |
| Converts the current token bytes to a string using the platform default charset. More... |
|
| virtual byte[] | GetDecodedStringContent () |
| Decodes the current PDF string token. More... |
|
| virtual bool | TokenValueEqualsTo (byte[] cmp) |
| Tests whether the current token bytes equal a candidate byte sequence. More... |
|
| virtual int | GetObjNr () |
| Gets the object number parsed from the current indirect reference. More... |
|
| virtual int | GetGenNr () |
| Gets the generation number parsed from the current indirect reference. More... |
|
| virtual void | BackOnePosition (int ch) |
| Pushes a read byte back so it becomes the next byte read. More... |
|
| virtual int | GetHeaderOffset () |
| Finds a PDF or FDF header in the first kilobyte of the source. More... |
|
| virtual String | CheckPdfHeader () |
| Validates a PDF header at offset zero and returns its version text. More... |
|
| virtual void | CheckFdfHeader () |
| Validates that an FDF header begins at offset zero. More... |
|
| virtual long | GetStartxref () |
Locates the final startxref marker near the end of the source. More... |
|
| virtual long | GetNextEof () |
| Gets next %EOF marker in current PDF file. More... |
|
| virtual void | NextValidToken () |
| Reads the next non-comment token and recognizes indirect references and object declarations. More... |
|
| virtual bool | NextToken () |
| Parses the next PDF token into this tokenizer's mutable token state. More... |
|
| virtual long | GetLongValue () |
Parses the current token value as a long. More... |
|
| virtual int | GetIntValue () |
Parses the current token value as an int. More... |
|
| virtual bool | IsHexString () |
| Tests whether the current string token uses hexadecimal notation. More... |
|
| virtual bool | IsCloseStream () |
| Tests whether Close() closes the underlying source. More... |
|
| virtual void | SetCloseStream (bool closeStream) |
| Configures whether Close() closes the underlying source. More... |
|
| virtual RandomAccessFileOrArray | GetSafeFile () |
| Creates an independent view of the underlying source. More... |
|
| virtual void | ThrowError (String error, params Object[] messageParams) |
| Helper method to handle content errors. More... |
|
| virtual bool | ReadLineSegment (ByteBuffer buffer) |
| Reads data into the provided byte[]. More... |
|
| virtual bool | ReadLineSegment (ByteBuffer buffer, bool isNullWhitespace) |
| Reads data into the provided byte[]. More... |
|
Static Public Member Functions |
|
| static byte[] | DecodeStringContent (byte[] content, bool hexWriting) |
| Resolve escape symbols or hexadecimal symbols. More... |
|
| static bool | IsWhitespace (int ch) |
| Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'. More... |
|
| static bool | CheckTrailer (ByteBuffer line) |
| Checks whether line equals to 'trailer'. More... |
|
| static int[] | CheckObjectStart (PdfTokenizer lineTokenizer) |
| Check whether line starts with object declaration. More... |
|
Static Public Attributes |
|
| static readonly byte[] | Obj = ByteUtils.GetIsoBytes("obj") |
| static readonly byte[] | R = ByteUtils.GetIsoBytes("R") |
| static readonly byte[] | Xref = ByteUtils.GetIsoBytes("xref") |
| static readonly byte[] | Startxref = ByteUtils.GetIsoBytes("startxref") |
| static readonly byte[] | Stream = ByteUtils.GetIsoBytes("stream") |
| static readonly byte[] | Trailer = ByteUtils.GetIsoBytes("trailer") |
| static readonly byte[] | N = ByteUtils.GetIsoBytes("n") |
| static readonly byte[] | F = ByteUtils.GetIsoBytes("f") |
| static readonly byte[] | Null = ByteUtils.GetIsoBytes("null") |
| static readonly byte[] | True = ByteUtils.GetIsoBytes("true") |
| static readonly byte[] | False = ByteUtils.GetIsoBytes("false") |
Static Package Functions |
|
| static byte[] | DecodeStringContent (byte[] content, int from, int to, bool hexWriting) |
| Resolve escape symbols or hexadecimal symbols. More... |
|
| static bool | IsWhitespace (int ch, bool isWhitespace) |
| Checks whether a character is a whitespace. More... |
|
| static bool | IsDelimiter (int ch) |
| Tests whether a character is a PDF delimiter. More... |
|
| static bool | IsDelimiterWhitespace (int ch) |
| Tests whether a character is a PDF delimiter or whitespace character. More... |
|
Package Attributes |
|
| PdfTokenizer.TokenType | type |
| The type of the most recently parsed token. More... |
|
| int | reference |
| The object number parsed for the current indirect reference. More... |
|
| int | generation |
| The generation number parsed for the current indirect reference. More... |
|
| bool | hexString |
| Whether the current string token uses hexadecimal notation. More... |
|
| ByteBuffer | outBuf |
| The mutable bytes of the most recently parsed token. More... |
|
Tokenizes PDF syntax from a random-access byte source.
Tokenizes PDF syntax from a random-access byte source.
Instances maintain a mutable stream position and token state and are not thread-safe.
|
strong |
Token types recognized by this tokenizer.
|
inline |
Creates a PdfTokenizer for the specified RandomAccessFileOrArray.
Creates a PdfTokenizer for the specified RandomAccessFileOrArray. The beginning of the file is read to determine the location of the header, and the data source is adjusted as necessary to account for any junk that occurs in the byte source before the header
| file | the source |
|
inlinevirtual |
Pushes a read byte back so it becomes the next byte read.
| ch | the byte value to push back; -1 is ignored |
|
inlinevirtual |
Validates that an FDF header begins at offset zero.
|
inlinestatic |
Check whether line starts with object declaration.
| lineTokenizer | tokenizer, built by single line. |
|
inlinevirtual |
Validates a PDF header at offset zero and returns its version text.
|
inlinestatic |
Checks whether line equals to 'trailer'.
| line | for check |
|
inlinevirtual |
Closes the underlying source when closing is enabled.
|
inlinestatic |
Resolve escape symbols or hexadecimal symbols.
Resolve escape symbols or hexadecimal symbols.
NOTE Due to PdfReference 1.7 part 3.2.3 String value contain ASCII characters, so we can convert it directly to byte array.
| content | string bytes to be decoded |
| hexWriting | true if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)' |
|
inlinestaticpackage |
Resolve escape symbols or hexadecimal symbols.
Resolve escape symbols or hexadecimal symbols.
NOTE Due to PdfReference 1.7 part 3.2.3 String value contain ASCII characters, so we can convert it directly to byte array.
| content | string bytes to be decoded |
| from | given start index |
| to | given end index |
| hexWriting | true if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)' |
|
inlinevirtual |
Copies the bytes of the most recently parsed token.
|
inlinevirtual |
Decodes the current PDF string token.
|
inlinevirtual |
Gets the generation number parsed from the current indirect reference.
|
inlinevirtual |
Finds a PDF or FDF header in the first kilobyte of the source.
|
inlinevirtual |
Parses the current token value as an int.
|
inlinevirtual |
Parses the current token value as a long.
|
inlinevirtual |
Gets next %EOF marker in current PDF file.
|
inlinevirtual |
Gets the object number parsed from the current indirect reference.
|
inlinevirtual |
Gets the current source position.
|
inlinevirtual |
Creates an independent view of the underlying source.
|
inlinevirtual |
Locates the final startxref marker near the end of the source.
|
inlinevirtual |
Converts the current token bytes to a string using the platform default charset.
|
inlinevirtual |
Gets the type of the most recently parsed token.
|
inlinevirtual |
Tests whether Close() closes the underlying source.
true if this tokenizer owns closing the source
|
inlinestaticpackage |
Tests whether a character is a PDF delimiter.
| ch | the character value to test |
true when ch is a PDF delimiter
|
inlinestaticpackage |
Tests whether a character is a PDF delimiter or whitespace character.
| ch | the character value to test |
true when ch is a delimiter or configured whitespace value
|
inlinevirtual |
Tests whether the current string token uses hexadecimal notation.
true for a hexadecimal string token
|
inlinestatic |
Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'.
Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'.
The same as calling isWhiteSpace(ch, true).
| ch | int |
|
inlinestaticpackage |
Checks whether a character is a whitespace.
Checks whether a character is a whitespace. Currently checks on the following: '0', '9', '10', '12', '13', '32'.
| ch | int |
| isWhitespace | boolean |
|
inlinevirtual |
Gets the length of the underlying source.
|
inlinevirtual |
Parses the next PDF token into this tokenizer's mutable token state.
true when a token was read, or false at EOF
|
inlinevirtual |
Reads the next non-comment token and recognizes indirect references and object declarations.
Reads the next non-comment token and recognizes indirect references and object declarations.
The source position and current token state are advanced to the recognized token.
|
inlinevirtual |
Gets the next byte of pdf source without moving source position.
|
inlinevirtual |
Gets the next buffer.length bytes of pdf source without moving source position.
| buffer | buffer to store read bytes |
buffer.length it means EOF has been reached
|
inlinevirtual |
Reads one byte and advances the source position.
-1 at EOF
|
inlinevirtual |
Reads enough bytes to fill a destination array.
| bytes | the destination array |
|
inlinevirtual |
Reads data into the provided byte[].
Reads data into the provided byte[]. Checks on leading whitespace. See isWhiteSpace(int) or isWhiteSpace(int, boolean) for a list of whitespace characters.
The same as calling readLineSegment(input, true).
| buffer | a ByteBuffer to which the result of reading will be saved |
|
inlinevirtual |
Reads data into the provided byte[].
Reads data into the provided byte[]. Checks on leading whitespace. See isWhiteSpace(int) or isWhiteSpace(int, boolean) for a list of whitespace characters.
| buffer | a ByteBuffer to which the result of reading will be saved |
| isNullWhitespace | boolean to indicate whether '0' is whitespace or not. If in doubt, use true or overloaded method readLineSegment(input) |
|
inlinevirtual |
Reads up to a requested number of bytes as character values.
| size | the maximum number of bytes to read |
|
inlinevirtual |
Sets the position from which the next byte is read.
| pos | the absolute byte offset in the underlying source |
|
inlinevirtual |
Configures whether Close() closes the underlying source.
| closeStream |
true to close the source, false to leave it open
|
inlinevirtual |
Helper method to handle content errors.
Helper method to handle content errors. Add file position to PdfRuntimeException.
| error | message. |
| messageParams | error params. |
|
inlinevirtual |
Tests whether the current token bytes equal a candidate byte sequence.
| cmp | the bytes to compare; null never matches |
true if cmp equals the current token bytes
|
package |
The generation number parsed for the current indirect reference.
|
package |
Whether the current string token uses hexadecimal notation.
|
package |
The mutable bytes of the most recently parsed token.
|
package |
The object number parsed for the current indirect reference.
|
package |
The type of the most recently parsed token.