Class PdfTokenizer
public class PdfTokenizer : IDisposable
- Inheritance
-
PdfTokenizer
- Implements
- Inherited Members
Constructors
PdfTokenizer(RandomAccessFileOrArray)
Creates a PdfTokenizer for the specified RandomAccessFileOrArray.
public PdfTokenizer(RandomAccessFileOrArray file)
Parameters
file
RandomAccessFileOrArraythe source
Remarks
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
Fields
F
public static readonly byte[] F
Field Value
- byte[]
False
public static readonly byte[] False
Field Value
- byte[]
N
public static readonly byte[] N
Field Value
- byte[]
Null
public static readonly byte[] Null
Field Value
- byte[]
Obj
public static readonly byte[] Obj
Field Value
- byte[]
R
public static readonly byte[] R
Field Value
- byte[]
Startxref
public static readonly byte[] Startxref
Field Value
- byte[]
Stream
public static readonly byte[] Stream
Field Value
- byte[]
Trailer
public static readonly byte[] Trailer
Field Value
- byte[]
True
public static readonly byte[] True
Field Value
- byte[]
Xref
public static readonly byte[] Xref
Field Value
- byte[]
delims
public static readonly bool[] delims
Field Value
- bool[]
generation
protected int generation
Field Value
hexString
protected bool hexString
Field Value
outBuf
protected ByteBuffer outBuf
Field Value
reference
protected int reference
Field Value
type
protected PdfTokenizer.TokenType type
Field Value
Methods
BackOnePosition(int)
public virtual void BackOnePosition(int ch)
Parameters
ch
int
CheckFdfHeader()
public virtual void CheckFdfHeader()
CheckObjectStart(PdfTokenizer)
Check whether line starts with object declaration.
public static int[] CheckObjectStart(PdfTokenizer lineTokenizer)
Parameters
lineTokenizer
PdfTokenizertokenizer, built by single line.
Returns
- int[]
object number and generation if check is successful, otherwise - null.
CheckPdfHeader()
public virtual string CheckPdfHeader()
Returns
CheckTrailer(ByteBuffer)
Checks whether
line
equals to 'trailer'.
public static bool CheckTrailer(ByteBuffer line)
Parameters
line
ByteBufferfor check
Returns
- bool
true, if line is equals to 'trailer', otherwise false
Close()
public virtual void Close()
DecodeStringContent(byte[], bool)
Resolve escape symbols or hexadecimal symbols.
public static byte[] DecodeStringContent(byte[] content, bool hexWriting)
Parameters
content
byte[]string bytes to be decoded
hexWriting
booltrue if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)'
Returns
Remarks
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.
DecodeStringContent(byte[], int, int, bool)
Resolve escape symbols or hexadecimal symbols.
protected static byte[] DecodeStringContent(byte[] content, int from, int to, bool hexWriting)
Parameters
content
byte[]string bytes to be decoded
from
intgiven start index
to
intgiven end index
hexWriting
booltrue if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)'
Returns
Remarks
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.GetByteContent()
public virtual byte[] GetByteContent()
Returns
- byte[]
GetDecodedStringContent()
public virtual byte[] GetDecodedStringContent()
Returns
- byte[]
GetGenNr()
public virtual int GetGenNr()
Returns
GetHeaderOffset()
public virtual int GetHeaderOffset()
Returns
GetIntValue()
public virtual int GetIntValue()
Returns
GetLongValue()
public virtual long GetLongValue()
Returns
GetNextEof()
Gets next %%EOF marker in current PDF file.
public virtual long GetNextEof()
Returns
- long
next %%EOF marker position
GetObjNr()
public virtual int GetObjNr()
Returns
GetPosition()
public virtual long GetPosition()
Returns
GetSafeFile()
public virtual RandomAccessFileOrArray GetSafeFile()
Returns
GetStartxref()
public virtual long GetStartxref()
Returns
GetStringValue()
public virtual string GetStringValue()
Returns
GetTokenType()
public virtual PdfTokenizer.TokenType GetTokenType()
Returns
IsCloseStream()
public virtual bool IsCloseStream()
Returns
IsDelimiter(int)
protected static bool IsDelimiter(int ch)
Parameters
ch
int
Returns
IsDelimiterWhitespace(int)
protected static bool IsDelimiterWhitespace(int ch)
Parameters
ch
int
Returns
IsHexString()
public virtual bool IsHexString()
Returns
IsWhitespace(int)
Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'.
public static bool IsWhitespace(int ch)
Parameters
ch
intint
Returns
- bool
boolean
Remarks
Is a certain character a whitespace? Currently checks on the following: '0', '9', '10', '12', '13', '32'.
The same as calling
isWhiteSpace(ch, true).
IsWhitespace(int, bool)
Checks whether a character is a whitespace.
protected static bool IsWhitespace(int ch, bool isWhitespace)
Parameters
Returns
- bool
boolean
Remarks
Checks whether a character is a whitespace. Currently checks on the following: '0', '9', '10', '12', '13', '32'.
Length()
public virtual long Length()
Returns
NextToken()
public virtual bool NextToken()
Returns
NextValidToken()
public virtual void NextValidToken()
Read()
public virtual int Read()
Returns
ReadFully(byte[])
public virtual void ReadFully(byte[] bytes)
Parameters
bytes
byte[]
ReadLineSegment(ByteBuffer)
Reads data into the provided byte[].
public virtual bool ReadLineSegment(ByteBuffer buffer)
Parameters
buffer
ByteBuffera ByteBuffer to which the result of reading will be saved
Returns
- bool
true, if something was read or if the end of the input stream is not reached
Remarks
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).
ReadLineSegment(ByteBuffer, bool)
Reads data into the provided byte[].
public virtual bool ReadLineSegment(ByteBuffer buffer, bool isNullWhitespace)
Parameters
buffer
ByteBuffera ByteBuffer to which the result of reading will be saved
isNullWhitespace
boolboolean to indicate whether '0' is whitespace or not. If in doubt, use true or overloaded method readLineSegment(input)
Returns
- bool
true, if something was read or if the end of the input stream is not reached
Remarks
Reads data into the provided byte[]. Checks on leading whitespace. See isWhiteSpace(int) or isWhiteSpace(int, boolean) for a list of whitespace characters.
ReadString(int)
public virtual string ReadString(int size)
Parameters
size
int
Returns
Seek(long)
public virtual void Seek(long pos)
Parameters
pos
long
SetCloseStream(bool)
public virtual void SetCloseStream(bool closeStream)
Parameters
closeStream
bool
ThrowError(string, params object[])
Helper method to handle content errors.
public virtual void ThrowError(string error, params object[] messageParams)
Parameters
Remarks
Helper method to handle content errors. Add file position to
PdfRuntimeException
.
TokenValueEqualsTo(byte[])
public virtual bool TokenValueEqualsTo(byte[] cmp)
Parameters
cmp
byte[]