iText 8.0.4 API
iText.IO.Source.PdfTokenizer Class Reference
Inheritance diagram for iText.IO.Source.PdfTokenizer:

Public Types

enum   TokenType {
  Number, String, Name, Comment,
  StartArray, EndArray, StartDic, EndDic,
  Ref, Obj, EndObj, Other,
  EndOfFile
}
 

Public Member Functions

  PdfTokenizer (RandomAccessFileOrArray file)
  Creates a PdfTokenizer for the specified RandomAccessFileOrArray. More...
 
virtual void  Seek (long pos)
 
virtual void  ReadFully (byte[] bytes)
 
virtual long  GetPosition ()
 
virtual void  Close ()
 
virtual long  Length ()
 
virtual int  Read ()
 
virtual String  ReadString (int size)
 
virtual PdfTokenizer.TokenType  GetTokenType ()
 
virtual byte[]  GetByteContent ()
 
virtual String  GetStringValue ()
 
virtual byte[]  GetDecodedStringContent ()
 
virtual bool  TokenValueEqualsTo (byte[] cmp)
 
virtual int  GetObjNr ()
 
virtual int  GetGenNr ()
 
virtual void  BackOnePosition (int ch)
 
virtual int  GetHeaderOffset ()
 
virtual String  CheckPdfHeader ()
 
virtual void  CheckFdfHeader ()
 
virtual long  GetStartxref ()
 
virtual long  GetNextEof ()
  Gets next %EOF marker in current PDF file. More...
 
virtual void  NextValidToken ()
 
virtual bool  NextToken ()
 
virtual long  GetLongValue ()
 
virtual int  GetIntValue ()
 
virtual bool  IsHexString ()
 
virtual bool  IsCloseStream ()
 
virtual void  SetCloseStream (bool closeStream)
 
virtual RandomAccessFileOrArray  GetSafeFile ()
 
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 bool[]  delims
 
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")
 

Constructor & Destructor Documentation

◆ PdfTokenizer()

iText.IO.Source.PdfTokenizer.PdfTokenizer ( RandomAccessFileOrArray  file )
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

Parameters
file the source

Member Function Documentation

◆ CheckObjectStart()

static int [] iText.IO.Source.PdfTokenizer.CheckObjectStart ( PdfTokenizer  lineTokenizer )
inlinestatic

Check whether line starts with object declaration.

Parameters
lineTokenizer tokenizer, built by single line.
Returns
object number and generation if check is successful, otherwise - null.

◆ CheckTrailer()

static bool iText.IO.Source.PdfTokenizer.CheckTrailer ( ByteBuffer  line )
inlinestatic

Checks whether line equals to 'trailer'.

Parameters
line for check
Returns
true, if line is equals to 'trailer', otherwise false

◆ DecodeStringContent()

static byte [] iText.IO.Source.PdfTokenizer.DecodeStringContent ( byte[]  content,
bool  hexWriting 
)
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.

Parameters
content string bytes to be decoded
hexWriting true if given string is hex-encoded, e.g. '<69546578…>'. False otherwise, e.g. '((iText( some version)…)'
Returns
byte[] for decrypting or for creating System.String.

◆ GetNextEof()

virtual long iText.IO.Source.PdfTokenizer.GetNextEof ( )
inlinevirtual

Gets next %EOF marker in current PDF file.

Returns
next %EOF marker position

◆ IsWhitespace()

static bool iText.IO.Source.PdfTokenizer.IsWhitespace ( int  ch )
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).

Parameters
ch int
Returns
boolean

◆ ReadLineSegment() [1/2]

virtual bool iText.IO.Source.PdfTokenizer.ReadLineSegment ( ByteBuffer  buffer )
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).

Parameters
buffer a ByteBuffer to which the result of reading will be saved
Returns
true, if something was read or if the end of the input stream is not reached

◆ ReadLineSegment() [2/2]

virtual bool iText.IO.Source.PdfTokenizer.ReadLineSegment ( ByteBuffer  buffer,
bool  isNullWhitespace 
)
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.

Parameters
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)
Returns
true, if something was read or if the end of the input stream is not reached

◆ ThrowError()

virtual void iText.IO.Source.PdfTokenizer.ThrowError ( String  error,
params Object[]  messageParams 
)
inlinevirtual

Helper method to handle content errors.

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

Parameters
error message.
messageParams error params.

Member Data Documentation

◆ delims

readonly bool [] iText.IO.Source.PdfTokenizer.delims
static
Initial value:
= new bool[] { true, true, false, false, false, false, false, false,
false, false, true, true, false, true, true, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, true, false, false, false, false, true
, false, false, true, true, false, false, false, false, false, true, false, false, false, false, false
, false, false, false, false, false, false, false, true, false, true, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, true, false, true, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
, false, false, false, false, false, false, false, false }