Pdf/FileParser.php
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Pdf
- Subpackage
- FileParser
- Version
- $Id$
\Zend_Pdf_FileParser
- Children
- \Zend_Pdf_FileParser_Image
- \Zend_Pdf_FileParser_Font
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties

\Zend_Pdf_FileParserDataSource $_dataSource = nullnullDetails
boolean $_isParsed = falsefalseDetails- Type
- boolean
Methods

__construct(\Zend_Pdf_FileParserDataSource $dataSource) : voidObject constructor.
| Name | Type | Description |
|---|---|---|
| $dataSource | \Zend_Pdf_FileParserDataSource |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

getDataSource() : \Zend_Pdf_FileParserDataSourceReturns the data source object representing the file being parsed.
| Type | Description |
|---|---|
| \Zend_Pdf_FileParserDataSource |

isBitSet(integer $bit, integer $bitField) : booleanReturns true if the specified bit is set in the integer bitfield.
| Name | Type | Description |
|---|---|---|
| $bit | integer | Bit number to test (i.e. - 0-31) |
| $bitField | integer |
| Type | Description |
|---|---|
| boolean |

isParsed() : booleanReturns true if the file has been successfully parsed.
| Type | Description |
|---|---|
| boolean |

isScreened() : booleanReturns true if the file has passed a cursory validation check.
| Type | Description |
|---|---|
| boolean |

moveToOffset(integer $offset) : voidConvenience wrapper for the data source object's moveToOffset() method.
| Name | Type | Description |
|---|---|---|
| $offset | integer | Destination byte offset. |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

parse() : voidReads and parses the complete binary file.
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readBytes(integer $byteCount) : stringConvenience wrapper for the data source object's readBytes() method.
| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes to read. |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readFixed(integer $mantissaBits, integer $fractionBits, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) : floatReads the signed fixed-point number from the binary file at the current byte offset.
| Name | Type | Description |
|---|---|---|
| $mantissaBits | integer | Number of bits in the mantissa |
| $fractionBits | integer | Number of bits in the fraction |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| Type | Description |
|---|---|
| float |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readInt(integer $size, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) : integerReads the signed integer value from the binary file at the current byte offset.
| Name | Type | Description |
|---|---|---|
| $size | integer | Size of integer in bytes: 1-4 |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| Type | Description |
|---|---|
| integer |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readStringMacRoman(integer $byteCount, string $characterSet = '') : stringReads the Mac Roman-encoded string from the binary file at the current byte offset.
| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes (characters) to return. |
| $characterSet | string | (optional) Desired resulting character set. You may use any character set supported by {@link iconv()}. If omitted, uses 'current locale'. |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readStringPascal(string $characterSet = '', integer $lengthBytes = 1) : stringReads the Pascal string from the binary file at the current byte offset.
| Name | Type | Description |
|---|---|---|
| $characterSet | string | (optional) Desired resulting character set. You may use any character set supported by {@link iconv()}. If omitted, uses 'current locale'. |
| $lengthBytes | integer | (optional) Number of bytes that make up the length. Default is 1. |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

readStringUTF16(integer $byteCount, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN, string $characterSet = '') : stringReads the Unicode UTF-16-encoded string from the binary file at the current byte offset.
| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes (characters * 2) to return. |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| $characterSet | string | (optional) Desired resulting character set. You may use any character set supported by {@link iconv()}. If omitted, uses 'current locale'. |
| Type | Description |
|---|---|
| string |
| Exception | Description |
|---|---|
| \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.

readUInt(integer $size, integer $byteOrder = \Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) : integerReads the unsigned integer value from the binary file at the current byte offset.
| Name | Type | Description |
|---|---|---|
| $size | integer | Size of integer in bytes: 1-4 |
| $byteOrder | integer | (optional) Big- or little-endian byte order. Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If omitted, uses big-endian. |
| Type | Description |
|---|---|
| integer |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

screen() : voidPerforms a cursory check to verify that the binary file is in the expected format. Intended to quickly weed out obviously bogus files.
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |

skipBytes(integer $byteCount) : voidConvenience wrapper for the data source object's skipBytes() method.
| Name | Type | Description |
|---|---|---|
| $byteCount | integer | Number of bytes to skip. |
| Exception | Description |
|---|---|
| \Zend_Pdf_Exception |