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.

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

Located in /Zend/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.
Class Constant Summary
Variable Summary
Method Summary
 Zend_Pdf_FileParser __construct (Zend_Pdf_FileParserDataSource $dataSource)
 void __destruct ()
 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.

  • access: public
  • throws: Zend_Pdf_Exception
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
isBitSet (line 328)

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.

  • access: public
  • throws: Zend_Pdf_Exception
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.

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

Redefined in descendants as:
readBytes (line 188)

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

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

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.

  • access: public
  • throws: Zend_Pdf_Exception
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 221)

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.

  • access: public
  • throws: Zend_Pdf_Exception
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 429)

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.

  • access: public
  • throws: Zend_Pdf_Exception
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 459)

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.

  • access: public
  • throws: Zend_Pdf_Exception
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 389)

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.

  • access: public
  • throws: Zend_Pdf_Exception
  • todo: Consider changing $byteCount to a character count. They are not always equivalent (in the case of surrogates).
  • todo: Make $byteOrder optional if there is a byte-order mark (BOM) in the string being extracted.
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 294)

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!

  • access: public
  • throws: Zend_Pdf_Exception
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.

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

Redefined in descendants as:
skipBytes (line 199)

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

  • access: public
  • throws: Zend_Pdf_Exception
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 Thu, 18 Jan 2007 09:53:34 -0800 by phpDocumentor 1.3.1