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

Classes

class   ReusableRandomAccessSource
 

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 RandomAccessFileOrArrayThe 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 More...
 
virtual void  Seek (long pos)
 
Exceptions
System.IO.IOException

 
virtual void  ReadFully (byte[] bytes)
 
Exceptions
System.IO.IOException

 
virtual long  GetPosition ()
 
Exceptions
System.IO.IOException

 
virtual void  Close ()
 
Exceptions
System.IO.IOException

 
virtual long  Length ()
 
Exceptions
System.IO.IOException

 
virtual int  Read ()
 
Exceptions
System.IO.IOException

 
virtual String  ReadString (int size)
 
Exceptions
System.IO.IOException

 
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 ()
 
Exceptions
System.IO.IOException

 
virtual String  CheckPdfHeader ()
 
Exceptions
System.IO.IOException

 
virtual void  CheckFdfHeader ()
 
Exceptions
System.IO.IOException

 
virtual long  GetStartxref ()
 
Exceptions
System.IO.IOException

 
virtual void  NextValidToken ()
 
Exceptions
System.IO.IOException

 
virtual bool  NextToken ()
 
Exceptions
System.IO.IOException

 
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 (iText.IO.Source.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 RandomAccessFileOrArrayThe 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 ( iText.IO.Source.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 tio '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
Parameters
hexWriting
Returns
byte[] for decrypting or for creating System.String

◆ 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

ByteBuffer

Returns
boolean
Exceptions
System.IO.IOException

◆ 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

ByteBuffer

Parameters
isNullWhitespace boolean to indicate whether '0' is whitespace or not. If in doubt, use true or overloaded method readLineSegment(input)
Returns
boolean
Exceptions
System.IO.IOException

◆ 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.
Exceptions
iText.IO.IOException wrap error message into PdfRuntimeException and add position in file.

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 }