Abstract helper class for {@link Zend_Pdf_FileParser} that provides the data source for parsing.

Concrete subclasses allow for parsing of in-memory, filesystem, and other sources through a common API. These subclasses also take care of error handling and other mundane tasks.

Subclasses must implement at minimum __construct(), __destruct(), \readBytes(), and \readAllBytes(). Subclasses should also override \moveToOffset() and __toString() as appropriate.

package Zend_Pdf
subpackage FileParser
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

Object destructor. Closes the data source.

__destruct() 

May also perform cleanup tasks such as deleting temporary files.

Returns a description of the object for debugging purposes.

__toString() : string

Subclasses should override this method to provide a more specific description of the actual object being represented.

Returns

string

Returns the byte offset of the current read position within the data source.

getOffset() : integer

Returns

integer

Returns the total size in bytes of the data source.

getSize() : integer

Returns

integer

Moves the current read position to the specified byte offset.

moveToOffset(integer $offset) 

Throws an exception you attempt to move before the beginning or beyond the end of the data source.

If a subclass needs to perform additional tasks (such as performing a fseek() on a filesystem source), it should do so after calling this parent method.

Parameters

$offset

integer

Destination byte offset.

Exceptions

\Zend_Pdf_Exception

Returns the entire contents of the data source as a string.

readAllBytes() : string

This method may be called at any time and so must preserve the byte offset of the read position, both through $this->_offset and whatever other additional pointers (such as the seek position of a file pointer) that might be used.

Returns

string

Returns the specified number of raw bytes from the data source at the byte offset of the current read position.

readBytes(integer $byteCount) : string

Must advance the read position by the number of bytes read by updating $this->_offset.

Throws an exception if there is insufficient data to completely fulfill the request or if an error occurs.

Parameters

$byteCount

integer

Number of bytes to read.

Exceptions

\Zend_Pdf_Exception

Returns

string

Shifts the current read position within the data source by the specified number of bytes.

skipBytes(integer $byteCount) 

You may move forward (positive numbers) or backward (negative numbers). Throws an exception you attempt to move before the beginning or beyond the end of the data source.

Parameters

$byteCount

integer

Number of bytes to skip.

Exceptions

\Zend_Pdf_Exception

 Properties

 

Byte offset of the current read position within the data source.

$_offset : integer

Default

0
 

Total size in bytes of the data source.

$_size : integer

Default

0