Table of Contents

Class PdfTokenizer

Namespace
iText.IO.Source
Assembly
itext.io.dll
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 RandomAccessFileOrArray

the 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

int

hexString

protected bool hexString

Field Value

bool

outBuf

protected ByteBuffer outBuf

Field Value

ByteBuffer

reference

protected int reference

Field Value

int

type

protected PdfTokenizer.TokenType type

Field Value

PdfTokenizer.TokenType

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 PdfTokenizer

tokenizer, built by single line.

Returns

int[]

object number and generation if check is successful, otherwise - null.

CheckPdfHeader()

public virtual string CheckPdfHeader()

Returns

string

CheckTrailer(ByteBuffer)

Checks whether line equals to 'trailer'.

public static bool CheckTrailer(ByteBuffer line)

Parameters

line ByteBuffer

for 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 bool

true if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)'

Returns

byte[]

byte[] for decrypting or for creating string.

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 int

given start index

to int

given end index

hexWriting bool

true if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)'

Returns

byte[]

byte[] for decrypting or for creating string.

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

int

GetHeaderOffset()

public virtual int GetHeaderOffset()

Returns

int

GetIntValue()

public virtual int GetIntValue()

Returns

int

GetLongValue()

public virtual long GetLongValue()

Returns

long

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

int

GetPosition()

public virtual long GetPosition()

Returns

long

GetSafeFile()

public virtual RandomAccessFileOrArray GetSafeFile()

Returns

RandomAccessFileOrArray

GetStartxref()

public virtual long GetStartxref()

Returns

long

GetStringValue()

public virtual string GetStringValue()

Returns

string

GetTokenType()

public virtual PdfTokenizer.TokenType GetTokenType()

Returns

PdfTokenizer.TokenType

IsCloseStream()

public virtual bool IsCloseStream()

Returns

bool

IsDelimiter(int)

protected static bool IsDelimiter(int ch)

Parameters

ch int

Returns

bool

IsDelimiterWhitespace(int)

protected static bool IsDelimiterWhitespace(int ch)

Parameters

ch int

Returns

bool

IsHexString()

public virtual bool IsHexString()

Returns

bool

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 int

int

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

ch int

int

isWhitespace bool

boolean

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

long

NextToken()

public virtual bool NextToken()

Returns

bool

NextValidToken()

public virtual void NextValidToken()

Read()

public virtual int Read()

Returns

int

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 ByteBuffer

a 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 ByteBuffer

a ByteBuffer to which the result of reading will be saved

isNullWhitespace bool

boolean 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

string

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

error string

message.

messageParams object[]

error params.

Remarks

Helper method to handle content errors. Add file position to PdfRuntimeException.

TokenValueEqualsTo(byte[])

public virtual bool TokenValueEqualsTo(byte[] cmp)

Parameters

cmp byte[]

Returns

bool