Abstract Class Zend_Pdf_FileParser

Description

Abstract utility class for parsing binary files.

Provides a library of methods to quickly navigate and extract various data types (signed and unsigned integers, floating- and fixed-point numbers, strings, etc.) from the file.

File access is managed via a Zend_Pdf_FileParserDataSource object. This allows the same parser code to work with many different data sources: in-memory objects, filesystem files, etc.

  • copyright: Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  • abstract:
  • license: New BSD License

Located in /Pdf/FileParser.php (line 41)


	
			
Direct descendents
Class Description
Abstract class Zend_Pdf_FileParser_Font Abstract helper class for Zend_Pdf_Font that parses font files.
Abstract class Zend_Pdf_FileParser_Image FileParser for Zend_Pdf_Image subclasses.
Class Constant Summary
Variable Summary
Method Summary
 Zend_Pdf_FileParser __construct (Zend_Pdf_FileParserDataSource $dataSource)
 void __destruct ()
 void getOffset ()
 void getSize ()
 boolean isBitSet (integer $bit, integer $bitField)
 boolean isParsed ()
 boolean isScreened ()
 void moveToOffset (integer $offset)
 void parse ()
 string readBytes (integer $byteCount)
 float readFixed (integer $mantissaBits, integer $fractionBits, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN])
 integer readInt (integer $size, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN])
 string readStringMacRoman (integer $byteCount, [string $characterSet = ''])
 string readStringPascal ([string $characterSet = ''], [integer $lengthBytes = 1])
 string readStringUTF16 (integer $byteCount, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN], [string $characterSet = ''])
 integer readUInt (integer $size, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN])
 void screen ()
 void skipBytes (integer $byteCount)
Variables
Zend_Pdf_FileParserDataSource $_dataSource = null (line 76)

Object representing the data source to be parsed.

  • access: protected
boolean $_isParsed = false (line 70)

Flag indicating that the file has been sucessfully parsed.

  • access: protected
boolean $_isScreened = false (line 64)

Flag indicating that the file has passed a cursory validation check.

  • access: protected
Methods
Constructor __construct (line 115)

Object constructor.

Verifies that the data source has been properly initialized.

  • throws: Zend_Pdf_Exception
  • access: public
Zend_Pdf_FileParser __construct (Zend_Pdf_FileParserDataSource $dataSource)

Redefined in descendants as:
Destructor __destruct (line 129)

Object destructor.

Discards the data source object.

  • access: public
void __destruct ()
getDataSource (line 162)

Returns the data source object representing the file being parsed.

  • access: public
getOffset (line 181)
  • access: public
void getOffset ()
getSize (line 185)
  • access: public
void getSize ()
isBitSet (line 336)

Returns true if the specified bit is set in the integer bitfield.

  • access: public
boolean isBitSet (integer $bit, integer $bitField)
  • integer $bit: Bit number to test (i.e. - 0-31)
  • integer $bitField
isParsed (line 152)

Returns true if the file has been successfully parsed.

  • access: public
boolean isParsed ()
isScreened (line 142)

Returns true if the file has passed a cursory validation check.

  • access: public
boolean isScreened ()
moveToOffset (line 176)

Convenience wrapper for the data source object's moveToOffset() method.

  • throws: Zend_Pdf_Exception
  • access: public
void moveToOffset (integer $offset)
  • integer $offset: Destination byte offset.
parse (line 102)

Reads and parses the complete binary file.

Must set $this->_isParsed to true if successful.

  • abstract:
  • throws: Zend_Pdf_Exception
  • access: public
void parse ()

Redefined in descendants as:
readBytes (line 196)

Convenience wrapper for the data source object's readBytes() method.

  • throws: Zend_Pdf_Exception
  • access: public
string readBytes (integer $byteCount)
  • integer $byteCount: Number of bytes to read.
readFixed (line 360)

Reads the signed fixed-point number from the binary file at the current byte offset.

Common fixed-point sizes are 2.14 and 16.16.

Advances the offset by the number of bytes read. Throws an exception if an error occurs.

  • throws: Zend_Pdf_Exception
  • access: public
float readFixed (integer $mantissaBits, integer $fractionBits, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN])
  • integer $mantissaBits: Number of bits in the mantissa
  • integer $fractionBits: Number of bits in the fraction
  • integer $byteOrder: (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in Zend_Pdf_FileParser. If omitted, uses big-endian.
readInt (line 229)

Reads the signed integer value from the binary file at the current byte offset.

Advances the offset by the number of bytes read. Throws an exception if an error occurs.

  • throws: Zend_Pdf_Exception
  • access: public
integer readInt (integer $size, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN])
  • integer $size: Size of integer in bytes: 1-4
  • integer $byteOrder: (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in Zend_Pdf_FileParser. If omitted, uses big-endian.
readStringMacRoman (line 437)

Reads the Mac Roman-encoded string from the binary file at the current byte offset.

You must supply the desired resulting character set.

Advances the offset by the number of bytes read. Throws an exception if an error occurs.

  • throws: Zend_Pdf_Exception
  • access: public
string readStringMacRoman (integer $byteCount, [string $characterSet = ''])
  • integer $byteCount: Number of bytes (characters) to return.
  • string $characterSet: (optional) Desired resulting character set. You may use any character set supported by http://www.php.net/iconv. If omitted, uses 'current locale'.

Redefined in descendants as:
readStringPascal (line 467)

Reads the Pascal string from the binary file at the current byte offset.

The length of the Pascal string is determined by reading the length bytes which preceed the character data. You must supply the desired resulting character set.

Advances the offset by the number of bytes read. Throws an exception if an error occurs.

  • throws: Zend_Pdf_Exception
  • access: public
string readStringPascal ([string $characterSet = ''], [integer $lengthBytes = 1])
  • string $characterSet: (optional) Desired resulting character set. You may use any character set supported by http://www.php.net/iconv. If omitted, uses 'current locale'.
  • integer $lengthBytes: (optional) Number of bytes that make up the length. Default is 1.

Redefined in descendants as:
readStringUTF16 (line 397)

Reads the Unicode UTF-16-encoded string from the binary file at the current byte offset.

The byte order of the UTF-16 string must be specified. You must also supply the desired resulting character set.

Advances the offset by the number of bytes read. Throws an exception if an error occurs.

  • todo: Make $byteOrder optional if there is a byte-order mark (BOM) in the string being extracted.
  • todo: Consider changing $byteCount to a character count. They are not always equivalent (in the case of surrogates).
  • throws: Zend_Pdf_Exception
  • access: public
string readStringUTF16 (integer $byteCount, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN], [string $characterSet = ''])
  • integer $byteCount: Number of bytes (characters * 2) to return.
  • integer $byteOrder: (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in Zend_Pdf_FileParser. If omitted, uses big-endian.
  • string $characterSet: (optional) Desired resulting character set. You may use any character set supported by http://www.php.net/iconv. If omitted, uses 'current locale'.

Redefined in descendants as:
readUInt (line 302)

Reads the unsigned integer value from the binary file at the current byte offset.

Advances the offset by the number of bytes read. Throws an exception if an error occurs.

NOTE: If you ask for a 4-byte unsigned integer on a 32-bit machine, the resulting value WILL BE SIGNED because PHP uses signed integers internally for everything. To guarantee portability, be sure to use bitwise operators operators on large unsigned integers!

  • throws: Zend_Pdf_Exception
  • access: public
integer readUInt (integer $size, [integer $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN])
  • integer $size: Size of integer in bytes: 1-4
  • integer $byteOrder: (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in Zend_Pdf_FileParser. If omitted, uses big-endian.
screen (line 93)

Performs a cursory check to verify that the binary file is in the expected format. Intended to quickly weed out obviously bogus files.

Must set $this->_isScreened to true if successful.

  • abstract:
  • throws: Zend_Pdf_Exception
  • access: public
void screen ()

Redefined in descendants as:
skipBytes (line 207)

Convenience wrapper for the data source object's skipBytes() method.

  • throws: Zend_Pdf_Exception
  • access: public
void skipBytes (integer $byteCount)
  • integer $byteCount: Number of bytes to skip.
Class Constants
BYTE_ORDER_BIG_ENDIAN = 1 (line 53)

Big-endian byte order (0x01 0x02 0x03 0x04).

BYTE_ORDER_LITTLE_ENDIAN = 0 (line 48)

Little-endian byte order (0x04 0x03 0x02 0x01).

Documentation generated on Sun, 27 May 2007 23:23:55 -0700 by phpDocumentor 1.3.2