import v1.0.0-RC4 | 2009-05-20

This commit is contained in:
2019-07-17 22:08:50 +02:00
commit b484e522e8
2459 changed files with 1038434 additions and 0 deletions

337
libs/Zend/Pdf/Cmap.php Normal file
View File

@ -0,0 +1,337 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Cmap_ByteEncoding */
require_once 'Zend/Pdf/Cmap/ByteEncoding.php';
/** Zend_Pdf_Cmap_ByteEncoding_Static */
require_once 'Zend/Pdf/Cmap/ByteEncoding/Static.php';
/** Zend_Pdf_Cmap_SegmentToDelta */
require_once 'Zend/Pdf/Cmap/SegmentToDelta.php';
/** Zend_Pdf_Cmap_TrimmedTable */
require_once 'Zend/Pdf/Cmap/TrimmedTable.php';
/**
* Abstract helper class for {@link Zend_Pdf_Resource_Font} which manages font
* character maps.
*
* Defines the public interface for concrete subclasses which are responsible
* for mapping Unicode characters to the font's glyph numbers. Also provides
* shared utility methods.
*
* Cmap objects should ordinarily be obtained through the factory method
* {@link cmapWithTypeData()}.
*
* The supported character map types are those found in the OpenType spec. For
* additional detail on the internal binary format of these tables, see:
* <ul>
* <li>{@link http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html}
* <li>{@link http://www.microsoft.com/OpenType/OTSpec/cmap.htm}
* <li>{@link http://partners.adobe.com/public/developer/opentype/index_cmap.html}
* </ul>
*
* @todo Write code for Zend_Pdf_FontCmap_HighByteMapping class.
* @todo Write code for Zend_Pdf_FontCmap_MixedCoverage class.
* @todo Write code for Zend_Pdf_FontCmap_TrimmedArray class.
* @todo Write code for Zend_Pdf_FontCmap_SegmentedCoverage class.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Cmap
{
/**** Class Constants ****/
/* Cmap Table Types */
/**
* Byte Encoding character map table type.
*/
const TYPE_BYTE_ENCODING = 0x00;
/**
* High Byte Mapping character map table type.
*/
const TYPE_HIGH_BYTE_MAPPING = 0x02;
/**
* Segment Value to Delta Mapping character map table type.
*/
const TYPE_SEGMENT_TO_DELTA = 0x04;
/**
* Trimmed Table character map table type.
*/
const TYPE_TRIMMED_TABLE = 0x06;
/**
* Mixed Coverage character map table type.
*/
const TYPE_MIXED_COVERAGE = 0x08;
/**
* Trimmed Array character map table type.
*/
const TYPE_TRIMMED_ARRAY = 0x0a;
/**
* Segmented Coverage character map table type.
*/
const TYPE_SEGMENTED_COVERAGE = 0x0c;
/**
* Static Byte Encoding character map table type. Variant of
* {@link TYPE_BYTEENCODING}.
*/
const TYPE_BYTE_ENCODING_STATIC = 0xf1;
/**
* Unknown character map table type.
*/
const TYPE_UNKNOWN = 0xff;
/* Special Glyph Names */
/**
* Glyph representing missing characters.
*/
const MISSING_CHARACTER_GLYPH = 0x00;
/**** Public Interface ****/
/* Factory Methods */
/**
* Instantiates the appropriate concrete subclass based on the type of cmap
* table and returns the instance.
*
* The cmap type must be one of the following values:
* <ul>
* <li>{@link Zend_Pdf_Cmap::TYPE_BYTE_ENCODING}
* <li>{@link Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC}
* <li>{@link Zend_Pdf_Cmap::TYPE_HIGH_BYTE_MAPPING}
* <li>{@link Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA}
* <li>{@link Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE}
* <li>{@link Zend_Pdf_Cmap::TYPE_MIXED_COVERAGE}
* <li>{@link Zend_Pdf_Cmap::TYPE_TRIMMED_ARRAY}
* <li>{@link Zend_Pdf_Cmap::TYPE_SEGMENTED_COVERAGE}
* </ul>
*
* Throws an exception if the table type is invalid or the cmap table data
* cannot be validated.
*
* @param integer $cmapType Type of cmap.
* @param mixed $cmapData Cmap table data. Usually a string or array.
* @return Zend_Pdf_Cmap
* @throws Zend_Pdf_Exception
*/
public static function cmapWithTypeData($cmapType, $cmapData)
{
switch ($cmapType) {
case Zend_Pdf_Cmap::TYPE_BYTE_ENCODING:
return new Zend_Pdf_Cmap_ByteEncoding($cmapData);
case Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC:
return new Zend_Pdf_Cmap_ByteEncoding_Static($cmapData);
case Zend_Pdf_Cmap::TYPE_HIGH_BYTE_MAPPING:
throw new Zend_Pdf_Exception('High byte mapping cmap currently unsupported',
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
case Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA:
return new Zend_Pdf_Cmap_SegmentToDelta($cmapData);
case Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE:
return new Zend_Pdf_Cmap_TrimmedTable($cmapData);
case Zend_Pdf_Cmap::TYPE_MIXED_COVERAGE:
throw new Zend_Pdf_Exception('Mixed coverage cmap currently unsupported',
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
case Zend_Pdf_Cmap::TYPE_TRIMMED_ARRAY:
throw new Zend_Pdf_Exception('Trimmed array cmap currently unsupported',
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
case Zend_Pdf_Cmap::TYPE_SEGMENTED_COVERAGE:
throw new Zend_Pdf_Exception('Segmented coverage cmap currently unsupported',
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
default:
throw new Zend_Pdf_Exception("Unknown cmap type: $cmapType",
Zend_Pdf_Exception::CMAP_UNKNOWN_TYPE);
}
}
/* Abstract Methods */
/**
* Object constructor
*
* Parses the raw binary table data. Throws an exception if the table is
* malformed.
*
* @param string $cmapData Raw binary cmap table data.
* @throws Zend_Pdf_Exception
*/
abstract public function __construct($cmapData);
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
abstract public function glyphNumbersForCharacters($characterCodes);
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
abstract public function glyphNumberForCharacter($characterCode);
/**
* Returns an array containing the Unicode characters that have entries in
* this character map.
*
* @return array Unicode character codes.
*/
abstract public function getCoveredCharacters();
/**
* Returns an array containing the glyphs numbers that have entries in this character map.
* Keys are Unicode character codes (integers)
*
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
* call, but this method do it in more effective way (prepare complete list instead of searching
* glyph for each character code).
*
* @internal
* @return array Array representing <Unicode character code> => <glyph number> pairs.
*/
abstract public function getCoveredCharactersGlyphs();
/**** Internal Methods ****/
/* Internal Utility Methods */
/**
* Extracts a signed 2-byte integer from a string.
*
* Integers are always big-endian. Throws an exception if the index is out
* of range.
*
* @param string &$data
* @param integer $index Position in string of integer.
* @return integer
* @throws Zend_Pdf_Exception
*/
protected function _extractInt2(&$data, $index)
{
if (($index < 0) | (($index + 1) > strlen($data))) {
throw new Zend_Pdf_Exception("Index out of range: $index",
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
}
$number = ord($data[$index]);
if (($number & 0x80) == 0x80) { // negative
$number = ~((((~ $number) & 0xff) << 8) | ((~ ord($data[++$index])) & 0xff));
} else {
$number = ($number << 8) | ord($data[++$index]);
}
return $number;
}
/**
* Extracts an unsigned 2-byte integer from a string.
*
* Integers are always big-endian. Throws an exception if the index is out
* of range.
*
* @param string &$data
* @param integer $index Position in string of integer.
* @return integer
* @throws Zend_Pdf_Exception
*/
protected function _extractUInt2(&$data, $index)
{
if (($index < 0) | (($index + 1) > strlen($data))) {
throw new Zend_Pdf_Exception("Index out of range: $index",
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
}
$number = (ord($data[$index]) << 8) | ord($data[++$index]);
return $number;
}
/**
* Extracts an unsigned 4-byte integer from a string.
*
* Integers are always big-endian. Throws an exception if the index is out
* of range.
*
* 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 or
* similar operators on large integers!
*
* @param string &$data
* @param integer $index Position in string of integer.
* @return integer
* @throws Zend_Pdf_Exception
*/
protected function _extractUInt4(&$data, $index)
{
if (($index < 0) | (($index + 3) > strlen($data))) {
throw new Zend_Pdf_Exception("Index out of range: $index",
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
}
$number = (ord($data[$index]) << 24) | (ord($data[++$index]) << 16) |
(ord($data[++$index]) << 8) | ord($data[++$index]);
return $number;
}
}

View File

@ -0,0 +1,442 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Cmap */
require_once 'Zend/Pdf/Cmap.php';
/**
* Implements the "byte encoding" character map (type 0).
*
* This is the (legacy) Apple standard encoding mechanism and provides coverage
* for characters in the Mac Roman character set only. Consequently, this cmap
* type should be used only as a last resort.
*
* The mapping from Mac Roman to Unicode can be found at
* {@link http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Cmap_ByteEncoding extends Zend_Pdf_Cmap
{
/**** Instance Variables ****/
/**
* Glyph index array. Stores the actual glyph numbers. The array keys are
* the translated Unicode code points.
* @var array
*/
protected $_glyphIndexArray = array();
/**** Public Interface ****/
/* Concrete Class Implementation */
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
$glyphNumbers = array();
foreach ($characterCodes as $key => $characterCode) {
if (! isset($this->_glyphIndexArray[$characterCode])) {
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
continue;
}
$glyphNumbers[$key] = $this->_glyphIndexArray[$characterCode];
}
return $glyphNumbers;
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
if (! isset($this->_glyphIndexArray[$characterCode])) {
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
}
return $this->_glyphIndexArray[$characterCode];
}
/**
* Returns an array containing the Unicode characters that have entries in
* this character map.
*
* @return array Unicode character codes.
*/
public function getCoveredCharacters()
{
return array_keys($this->_glyphIndexArray);
}
/**
* Returns an array containing the glyphs numbers that have entries in this character map.
* Keys are Unicode character codes (integers)
*
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
* call, but this method do it in more effective way (prepare complete list instead of searching
* glyph for each character code).
*
* @internal
* @return array Array representing <Unicode character code> => <glyph number> pairs.
*/
public function getCoveredCharactersGlyphs()
{
return $this->_glyphIndexArray;
}
/* Object Lifecycle */
/**
* Object constructor
*
* Parses the raw binary table data. Throws an exception if the table is
* malformed.
*
* @param string $cmapData Raw binary cmap table data.
* @throws Zend_Pdf_Exception
*/
public function __construct($cmapData)
{
/* Sanity check: This table must be exactly 262 bytes long.
*/
$actualLength = strlen($cmapData);
if ($actualLength != 262) {
throw new Zend_Pdf_Exception('Insufficient table data',
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
}
/* Sanity check: Make sure this is right data for this table type.
*/
$type = $this->_extractUInt2($cmapData, 0);
if ($type != Zend_Pdf_Cmap::TYPE_BYTE_ENCODING) {
throw new Zend_Pdf_Exception('Wrong cmap table type',
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
}
$length = $this->_extractUInt2($cmapData, 2);
if ($length != $actualLength) {
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
}
/* Mapping tables should be language-independent. The font may not work
* as expected if they are not. Unfortunately, many font files in the
* wild incorrectly record a language ID in this field, so we can't
* call this a failure.
*/
$language = $this->_extractUInt2($cmapData, 4);
if ($language != 0) {
// Record a warning here somehow?
}
/* The mapping between the Mac Roman and Unicode characters is static.
* For simplicity, just put all 256 glyph indices into one array keyed
* off the corresponding Unicode character.
*/
$i = 6;
$this->_glyphIndexArray[0x00] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x01] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x03] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x04] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x05] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x06] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x07] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x08] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x09] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x10] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x11] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x12] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x13] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x14] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x15] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x16] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x17] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x18] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x19] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x1a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x1b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x1c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x1d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x1e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x1f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x20] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x21] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x22] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x23] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x24] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x25] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x26] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x27] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x28] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x29] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x30] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x31] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x32] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x33] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x34] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x35] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x36] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x37] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x38] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x39] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x3a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x3b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x3c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x3d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x3e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x3f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x40] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x41] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x42] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x43] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x44] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x45] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x46] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x47] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x48] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x49] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x4a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x4b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x4c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x4d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x4e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x4f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x50] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x51] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x52] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x53] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x54] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x55] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x56] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x57] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x58] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x59] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x5a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x5b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x5c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x5d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x5e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x5f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x60] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x61] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x62] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x63] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x64] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x65] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x66] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x67] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x68] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x69] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x6a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x6b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x6c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x6d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x6e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x6f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x70] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x71] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x72] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x73] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x74] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x75] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x76] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x77] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x78] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x79] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x7a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x7b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x7c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x7d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x7e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x7f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc4] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc5] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc7] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd1] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd6] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xdc] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe1] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe0] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe2] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe4] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe3] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe5] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe7] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xea] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xeb] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xed] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xec] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xee] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xef] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf1] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf3] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf2] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf4] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf6] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf5] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xfa] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xfb] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xfc] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2020] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb0] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa2] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa3] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa7] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2022] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb6] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xdf] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xae] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2122] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb4] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2260] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc6] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x221e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb1] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2264] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2265] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa5] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb5] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2202] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2211] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x220f] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x03c0] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x222b] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xaa] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xba] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x03a9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xe6] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xbf] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa1] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xac] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x221a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0192] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2248] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2206] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xab] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xbb] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2026] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xa0] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc0] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc3] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd5] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0152] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0153] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2013] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2014] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x201c] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x201d] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2018] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2019] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf7] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x25ca] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xff] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0178] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2044] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x20ac] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2039] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x203a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xfb01] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xfb02] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2021] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb7] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x201a] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x201e] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x2030] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc2] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xca] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc1] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xcb] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xc8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xcd] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xce] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xcf] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xcc] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd3] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd4] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xf8ff] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd2] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xda] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xdb] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xd9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x0131] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02c6] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02dc] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xaf] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02d8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02d9] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02da] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0xb8] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02dd] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02db] = ord($cmapData[$i++]);
$this->_glyphIndexArray[0x02c7] = ord($cmapData[$i]);
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Cmap_ByteEncoding */
require_once 'Zend/Pdf/Cmap/ByteEncoding.php';
/**
* Custom cmap type used for the Adobe Standard 14 PDF fonts.
*
* Just like {@link Zend_Pdf_Cmap_ByteEncoding} except that the constructor
* takes a predefined array of glyph numbers and can cover any Unicode character.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Cmap_ByteEncoding_Static extends Zend_Pdf_Cmap_ByteEncoding
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*
* @param array $cmapData Array whose keys are Unicode character codes and
* values are glyph numbers.
* @throws Zend_Pdf_Exception
*/
public function __construct($cmapData)
{
if (! is_array($cmapData)) {
throw new Zend_Pdf_Exception('Constructor parameter must be an array',
Zend_Pdf_Exception::BAD_PARAMETER_TYPE);
}
$this->_glyphIndexArray = $cmapData;
}
}

View File

@ -0,0 +1,401 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Cmap */
require_once 'Zend/Pdf/Cmap.php';
/**
* Implements the "segment mapping to delta values" character map (type 4).
*
* This is the Microsoft standard mapping table type for OpenType fonts. It
* provides the ability to cover multiple contiguous ranges of the Unicode
* character set, with the exception of Unicode Surrogates (U+D800 - U+DFFF).
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Cmap_SegmentToDelta extends Zend_Pdf_Cmap
{
/**** Instance Variables ****/
/**
* The number of segments in the table.
* @var integer
*/
protected $_segmentCount = 0;
/**
* The size of the binary search range for segments.
* @var integer
*/
protected $_searchRange = 0;
/**
* The number of binary search steps required to cover the entire search
* range.
* @var integer
*/
protected $_searchIterations = 0;
/**
* Array of ending character codes for each segment.
* @var array
*/
protected $_segmentTableEndCodes = array();
/**
* The ending character code for the segment at the end of the low search
* range.
* @var integer
*/
protected $_searchRangeEndCode = 0;
/**
* Array of starting character codes for each segment.
* @var array
*/
protected $_segmentTableStartCodes = array();
/**
* Array of character code to glyph delta values for each segment.
* @var array
*/
protected $_segmentTableIdDeltas = array();
/**
* Array of offsets into the glyph index array for each segment.
* @var array
*/
protected $_segmentTableIdRangeOffsets = array();
/**
* Glyph index array. Stores glyph numbers, used with range offset.
* @var array
*/
protected $_glyphIndexArray = array();
/**** Public Interface ****/
/* Concrete Class Implementation */
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
$glyphNumbers = array();
foreach ($characterCodes as $key => $characterCode) {
/* These tables only cover the 16-bit character range.
*/
if ($characterCode > 0xffff) {
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
continue;
}
/* Determine where to start the binary search. The segments are
* ordered from lowest-to-highest. We are looking for the first
* segment whose end code is greater than or equal to our character
* code.
*
* If the end code at the top of the search range is larger, then
* our target is probably below it.
*
* If it is smaller, our target is probably above it, so move the
* search range to the end of the segment list.
*/
if ($this->_searchRangeEndCode >= $characterCode) {
$searchIndex = $this->_searchRange;
} else {
$searchIndex = $this->_segmentCount;
}
/* Now do a binary search to find the first segment whose end code
* is greater or equal to our character code. No matter the number
* of segments (there may be hundreds in a large font), we will only
* need to perform $this->_searchIterations.
*/
for ($i = 1; $i <= $this->_searchIterations; $i++) {
if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
$subtableIndex = $searchIndex;
$searchIndex -= $this->_searchRange >> $i;
} else {
$searchIndex += $this->_searchRange >> $i;
}
}
/* If the segment's start code is greater than our character code,
* that character is not represented in this font. Move on.
*/
if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
continue;
}
if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
/* This segment uses a simple mapping from character code to
* glyph number.
*/
$glyphNumbers[$key] = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
} else {
/* This segment relies on the glyph index array to determine the
* glyph number. The calculation below determines the correct
* index into that array. It's a little odd because the range
* offset in the font file is designed to quickly provide an
* address of the index in the raw binary data instead of the
* index itself. Since we've parsed the data into arrays, we
* must process it a bit differently.
*/
$glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
$this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
$subtableIndex - 1);
$glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
}
}
return $glyphNumbers;
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
/* This code is pretty much a copy of glyphNumbersForCharacters().
* See that method for inline documentation.
*/
if ($characterCode > 0xffff) {
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
}
if ($this->_searchRangeEndCode >= $characterCode) {
$searchIndex = $this->_searchRange;
} else {
$searchIndex = $this->_segmentCount;
}
for ($i = 1; $i <= $this->_searchIterations; $i++) {
if ($this->_segmentTableEndCodes[$searchIndex] >= $characterCode) {
$subtableIndex = $searchIndex;
$searchIndex -= $this->_searchRange >> $i;
} else {
$searchIndex += $this->_searchRange >> $i;
}
}
if ($this->_segmentTableStartCodes[$subtableIndex] > $characterCode) {
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
}
if ($this->_segmentTableIdRangeOffsets[$subtableIndex] == 0) {
$glyphNumber = ($characterCode + $this->_segmentTableIdDeltas[$subtableIndex]) % 65536;
} else {
$glyphIndex = ($characterCode - $this->_segmentTableStartCodes[$subtableIndex] +
$this->_segmentTableIdRangeOffsets[$subtableIndex] - $this->_segmentCount +
$subtableIndex - 1);
$glyphNumber = $this->_glyphIndexArray[$glyphIndex];
}
return $glyphNumber;
}
/**
* Returns an array containing the Unicode characters that have entries in
* this character map.
*
* @return array Unicode character codes.
*/
public function getCoveredCharacters()
{
$characterCodes = array();
for ($i = 1; $i <= $this->_segmentCount; $i++) {
for ($code = $this->_segmentTableStartCodes[$i]; $code <= $this->_segmentTableEndCodes[$i]; $code++) {
$characterCodes[] = $code;
}
}
return $characterCodes;
}
/**
* Returns an array containing the glyphs numbers that have entries in this character map.
* Keys are Unicode character codes (integers)
*
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
* call, but this method do it in more effective way (prepare complete list instead of searching
* glyph for each character code).
*
* @internal
* @return array Array representing <Unicode character code> => <glyph number> pairs.
*/
public function getCoveredCharactersGlyphs()
{
$glyphNumbers = array();
for ($segmentNum = 1; $segmentNum <= $this->_segmentCount; $segmentNum++) {
if ($this->_segmentTableIdRangeOffsets[$segmentNum] == 0) {
$delta = $this->_segmentTableIdDeltas[$segmentNum];
for ($code = $this->_segmentTableStartCodes[$segmentNum];
$code <= $this->_segmentTableEndCodes[$segmentNum];
$code++) {
$glyphNumbers[$code] = ($code + $delta) % 65536;
}
} else {
$code = $this->_segmentTableStartCodes[$segmentNum];
$glyphIndex = $this->_segmentTableIdRangeOffsets[$segmentNum] - ($this->_segmentCount - $segmentNum) - 1;
while ($code <= $this->_segmentTableEndCodes[$segmentNum]) {
$glyphNumbers[$code] = $this->_glyphIndexArray[$glyphIndex];
$code++;
$glyphIndex++;
}
}
}
return $glyphNumbers;
}
/* Object Lifecycle */
/**
* Object constructor
*
* Parses the raw binary table data. Throws an exception if the table is
* malformed.
*
* @param string $cmapData Raw binary cmap table data.
* @throws Zend_Pdf_Exception
*/
public function __construct($cmapData)
{
/* Sanity check: The table should be at least 23 bytes in size.
*/
$actualLength = strlen($cmapData);
if ($actualLength < 23) {
throw new Zend_Pdf_Exception('Insufficient table data',
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
}
/* Sanity check: Make sure this is right data for this table type.
*/
$type = $this->_extractUInt2($cmapData, 0);
if ($type != Zend_Pdf_Cmap::TYPE_SEGMENT_TO_DELTA) {
throw new Zend_Pdf_Exception('Wrong cmap table type',
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
}
$length = $this->_extractUInt2($cmapData, 2);
if ($length != $actualLength) {
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
}
/* Mapping tables should be language-independent. The font may not work
* as expected if they are not. Unfortunately, many font files in the
* wild incorrectly record a language ID in this field, so we can't
* call this a failure.
*/
$language = $this->_extractUInt2($cmapData, 4);
if ($language != 0) {
// Record a warning here somehow?
}
/* These two values are stored premultiplied by two which is convienent
* when using the binary data directly, but we're parsing it out to
* native PHP data types, so divide by two.
*/
$this->_segmentCount = $this->_extractUInt2($cmapData, 6) >> 1;
$this->_searchRange = $this->_extractUInt2($cmapData, 8) >> 1;
$this->_searchIterations = $this->_extractUInt2($cmapData, 10) + 1;
$offset = 14;
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
$this->_segmentTableEndCodes[$i] = $this->_extractUInt2($cmapData, $offset);
}
$this->_searchRangeEndCode = $this->_segmentTableEndCodes[$this->_searchRange];
$offset += 2; // reserved bytes
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
$this->_segmentTableStartCodes[$i] = $this->_extractUInt2($cmapData, $offset);
}
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
$this->_segmentTableIdDeltas[$i] = $this->_extractInt2($cmapData, $offset); // signed
}
/* The range offset helps determine the index into the glyph index array.
* Like the segment count and search range above, it's stored as a byte
* multiple in the font, so divide by two as we extract the values.
*/
for ($i = 1; $i <= $this->_segmentCount; $i++, $offset += 2) {
$this->_segmentTableIdRangeOffsets[$i] = $this->_extractUInt2($cmapData, $offset) >> 1;
}
/* The size of the glyph index array varies by font and depends on the
* extent of the usage of range offsets versus deltas. Some fonts may
* not have any entries in this array.
*/
for (; $offset < $length; $offset += 2) {
$this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
}
/* Sanity check: After reading all of the data, we should be at the end
* of the table.
*/
if ($offset != $length) {
throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
Zend_Pdf_Exception::CMAP_FINAL_OFFSET_NOT_LENGTH);
}
}
}

View File

@ -0,0 +1,224 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Cmap */
require_once 'Zend/Pdf/Cmap.php';
/**
* Implements the "trimmed table mapping" character map (type 6).
*
* This table type is preferred over the {@link Zend_Pdf_Cmap_SegmentToDelta}
* table when the Unicode characters covered by the font fall into a single
* contiguous range.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Cmap_TrimmedTable extends Zend_Pdf_Cmap
{
/**** Instance Variables ****/
/**
* The starting character code covered by this table.
* @var integer
*/
protected $_startCode = 0;
/**
* The ending character code covered by this table.
* @var integer
*/
protected $_endCode = 0;
/**
* Glyph index array. Stores the actual glyph numbers.
* @var array
*/
protected $_glyphIndexArray = array();
/**** Public Interface ****/
/* Concrete Class Implementation */
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
$glyphNumbers = array();
foreach ($characterCodes as $key => $characterCode) {
if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
$glyphNumbers[$key] = Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
continue;
}
$glyphIndex = $characterCode - $this->_startCode;
$glyphNumbers[$key] = $this->_glyphIndexArray[$glyphIndex];
}
return $glyphNumbers;
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
if (($characterCode < $this->_startCode) || ($characterCode > $this->_endCode)) {
return Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH;
}
$glyphIndex = $characterCode - $this->_startCode;
return $this->_glyphIndexArray[$glyphIndex];
}
/**
* Returns an array containing the Unicode characters that have entries in
* this character map.
*
* @return array Unicode character codes.
*/
public function getCoveredCharacters()
{
$characterCodes = array();
for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
$characterCodes[] = $code;
}
return $characterCodes;
}
/**
* Returns an array containing the glyphs numbers that have entries in this character map.
* Keys are Unicode character codes (integers)
*
* This functionality is partially covered by glyphNumbersForCharacters(getCoveredCharacters())
* call, but this method do it in more effective way (prepare complete list instead of searching
* glyph for each character code).
*
* @internal
* @return array Array representing <Unicode character code> => <glyph number> pairs.
*/
public function getCoveredCharactersGlyphs()
{
$glyphNumbers = array();
for ($code = $this->_startCode; $code <= $this->_endCode; $code++) {
$glyphNumbers[$code] = $this->_glyphIndexArray[$code - $this->_startCode];
}
return $glyphNumbers;
}
/* Object Lifecycle */
/**
* Object constructor
*
* Parses the raw binary table data. Throws an exception if the table is
* malformed.
*
* @param string $cmapData Raw binary cmap table data.
* @throws Zend_Pdf_Exception
*/
public function __construct($cmapData)
{
/* Sanity check: The table should be at least 9 bytes in size.
*/
$actualLength = strlen($cmapData);
if ($actualLength < 9) {
throw new Zend_Pdf_Exception('Insufficient table data',
Zend_Pdf_Exception::CMAP_TABLE_DATA_TOO_SMALL);
}
/* Sanity check: Make sure this is right data for this table type.
*/
$type = $this->_extractUInt2($cmapData, 0);
if ($type != Zend_Pdf_Cmap::TYPE_TRIMMED_TABLE) {
throw new Zend_Pdf_Exception('Wrong cmap table type',
Zend_Pdf_Exception::CMAP_WRONG_TABLE_TYPE);
}
$length = $this->_extractUInt2($cmapData, 2);
if ($length != $actualLength) {
throw new Zend_Pdf_Exception("Table length ($length) does not match actual length ($actualLength)",
Zend_Pdf_Exception::CMAP_WRONG_TABLE_LENGTH);
}
/* Mapping tables should be language-independent. The font may not work
* as expected if they are not. Unfortunately, many font files in the
* wild incorrectly record a language ID in this field, so we can't
* call this a failure.
*/
$language = $this->_extractUInt2($cmapData, 4);
if ($language != 0) {
// Record a warning here somehow?
}
$this->_startCode = $this->_extractUInt2($cmapData, 6);
$entryCount = $this->_extractUInt2($cmapData, 8);
$expectedCount = ($length - 10) >> 1;
if ($entryCount != $expectedCount) {
throw new Zend_Pdf_Exception("Entry count is wrong; expected: $expectedCount; actual: $entryCount",
Zend_Pdf_Exception::CMAP_WRONG_ENTRY_COUNT);
}
$this->_endCode = $this->_startCode + $entryCount - 1;
$offset = 10;
for ($i = 0; $i < $entryCount; $i++, $offset += 2) {
$this->_glyphIndexArray[] = $this->_extractUInt2($cmapData, $offset);
}
/* Sanity check: After reading all of the data, we should be at the end
* of the table.
*/
if ($offset != $length) {
throw new Zend_Pdf_Exception("Ending offset ($offset) does not match length ($length)",
Zend_Pdf_Exception::CMAP_FINAL_OFFSET_NOT_LENGTH);
}
}
}

44
libs/Zend/Pdf/Color.php Normal file
View File

@ -0,0 +1,44 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* PDF provides a powerfull facilities for specifying the colors of graphics objects.
* This class encapsulates color behaviour.
*
* Some colors interact with PDF document (create additional objects in a PDF),
* others don't do it. That is defined in a subclasses.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Color
{
/**
* Instructions, which can be directly inserted into content stream
* to switch color.
* Color set instructions differ for stroking and nonstroking operations.
*
* @param boolean $stroking
* @return string
*/
abstract public function instructions($stroking);
}

View File

@ -0,0 +1,119 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/**
* CMYK color implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Color_Cmyk extends Zend_Pdf_Color
{
/**
* Cyan level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_c;
/**
* Magenta level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_m;
/**
* Yellow level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_y;
/**
* Key (BlacK) level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_k;
/**
* Object constructor
*
* @param float $c
* @param float $m
* @param float $y
* @param float $k
*/
public function __construct($c, $m, $y, $k)
{
$this->_c = new Zend_Pdf_Element_Numeric($c);
$this->_m = new Zend_Pdf_Element_Numeric($m);
$this->_y = new Zend_Pdf_Element_Numeric($y);
$this->_k = new Zend_Pdf_Element_Numeric($k);
if ($this->_c->value < 0) { $this->_c->value = 0; }
if ($this->_c->value > 1) { $this->_c->value = 1; }
if ($this->_m->value < 0) { $this->_m->value = 0; }
if ($this->_m->value > 1) { $this->_m->value = 1; }
if ($this->_y->value < 0) { $this->_y->value = 0; }
if ($this->_y->value > 1) { $this->_y->value = 1; }
if ($this->_k->value < 0) { $this->_k->value = 0; }
if ($this->_k->value > 1) { $this->_k->value = 1; }
}
/**
* Instructions, which can be directly inserted into content stream
* to switch color.
* Color set instructions differ for stroking and nonstroking operations.
*
* @param boolean $stroking
* @return string
*/
public function instructions($stroking)
{
return $this->_c->toString() . ' '
. $this->_m->toString() . ' '
. $this->_y->toString() . ' '
. $this->_k->toString() . ($stroking? " K\n" : " k\n");
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/**
* GrayScale color implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Color_GrayScale extends Zend_Pdf_Color
{
/**
* GrayLevel.
* 0.0 (black) - 1.0 (white)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_grayLevel;
/**
* Object constructor
*
* @param float $grayLevel
*/
public function __construct($grayLevel)
{
$this->_grayLevel = new Zend_Pdf_Element_Numeric($grayLevel);
if ($this->_grayLevel->value < 0) {
$this->_grayLevel->value = 0;
}
if ($this->_grayLevel->value > 1) {
$this->_grayLevel->value = 1;
}
}
/**
* Instructions, which can be directly inserted into content stream
* to switch color.
* Color set instructions differ for stroking and nonstroking operations.
*
* @param boolean $stroking
* @return string
*/
public function instructions($stroking)
{
return $this->_grayLevel->toString() . ($stroking? " G\n" : " g\n");
}
}

View File

@ -0,0 +1,407 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';
/** Zend_Pdf_Color_Rgb */
require_once 'Zend/Pdf/Color/Rgb.php';
/** Zend_Pdf_GrayScale */
require_once 'Zend/Pdf/Color/GrayScale.php';
/**
* HTML color implementation
*
* Factory class which vends Zend_Pdf_Color objects from typical HTML
* representations.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Color_Html extends Zend_Pdf_Color
{
/**
* Color
*
* @var Zend_Pdf_Color
*/
private $_color;
/**
* Class constructor.
*
* @param mixed $color
* @throws Zend_Pdf_Exception
*/
public function __construct($color)
{
$this->_color = self::color($color);
}
/**
* Instructions, which can be directly inserted into content stream
* to switch color.
* Color set instructions differ for stroking and nonstroking operations.
*
* @param boolean $stroking
* @return string
*/
public function instructions($stroking)
{
return $this->_color->instructions($stroking);
}
/**
* Creates a Zend_Pdf_Color object from the HTML representation.
*
* @param string $color May either be a hexidecimal number of the form
* #rrggbb or one of the 140 well-known names (black, white, blue, etc.)
* @return Zend_Pdf_Color
*/
public static function color($color)
{
$pattern = '/^#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})$/';
if (preg_match($pattern, $color, $matches)) {
$r = round((hexdec($matches[1]) / 255), 3);
$g = round((hexdec($matches[2]) / 255), 3);
$b = round((hexdec($matches[3]) / 255), 3);
if (($r == $g) && ($g == $b)) {
return new Zend_Pdf_Color_GrayScale($r);
} else {
return new Zend_Pdf_Color_Rgb($r, $g, $b);
}
} else {
return Zend_Pdf_Color_Html::namedColor($color);
}
}
/**
* Creates a Zend_Pdf_Color object from the named color.
*
* @param string $color One of the 140 well-known color names (black, white,
* blue, etc.)
* @return Zend_Pdf_Color
*/
public static function namedColor($color)
{
switch (strtolower($color)) {
case 'aqua':
$r = 0.0; $g = 1.0; $b = 1.0; break;
case 'black':
$r = 0.0; $g = 0.0; $b = 0.0; break;
case 'blue':
$r = 0.0; $g = 0.0; $b = 1.0; break;
case 'fuchsia':
$r = 1.0; $g = 0.0; $b = 1.0; break;
case 'gray':
$r = 0.502; $g = 0.502; $b = 0.502; break;
case 'green':
$r = 0.0; $g = 0.502; $b = 0.0; break;
case 'lime':
$r = 0.0; $g = 1.0; $b = 0.0; break;
case 'maroon':
$r = 0.502; $g = 0.0; $b = 0.0; break;
case 'navy':
$r = 0.0; $g = 0.0; $b = 0.502; break;
case 'olive':
$r = 0.502; $g = 0.502; $b = 0.0; break;
case 'purple':
$r = 0.502; $g = 0.0; $b = 0.502; break;
case 'red':
$r = 1.0; $g = 0.0; $b = 0.0; break;
case 'silver':
$r = 0.753; $g = 0.753; $b = 0.753; break;
case 'teal':
$r = 0.0; $g = 0.502; $b = 0.502; break;
case 'white':
$r = 1.0; $g = 1.0; $b = 1.0; break;
case 'yellow':
$r = 1.0; $g = 1.0; $b = 0.0; break;
case 'aliceblue':
$r = 0.941; $g = 0.973; $b = 1.0; break;
case 'antiquewhite':
$r = 0.980; $g = 0.922; $b = 0.843; break;
case 'aquamarine':
$r = 0.498; $g = 1.0; $b = 0.831; break;
case 'azure':
$r = 0.941; $g = 1.0; $b = 1.0; break;
case 'beige':
$r = 0.961; $g = 0.961; $b = 0.863; break;
case 'bisque':
$r = 1.0; $g = 0.894; $b = 0.769; break;
case 'blanchedalmond':
$r = 1.0; $g = 1.0; $b = 0.804; break;
case 'blueviolet':
$r = 0.541; $g = 0.169; $b = 0.886; break;
case 'brown':
$r = 0.647; $g = 0.165; $b = 0.165; break;
case 'burlywood':
$r = 0.871; $g = 0.722; $b = 0.529; break;
case 'cadetblue':
$r = 0.373; $g = 0.620; $b = 0.627; break;
case 'chartreuse':
$r = 0.498; $g = 1.0; $b = 0.0; break;
case 'chocolate':
$r = 0.824; $g = 0.412; $b = 0.118; break;
case 'coral':
$r = 1.0; $g = 0.498; $b = 0.314; break;
case 'cornflowerblue':
$r = 0.392; $g = 0.584; $b = 0.929; break;
case 'cornsilk':
$r = 1.0; $g = 0.973; $b = 0.863; break;
case 'crimson':
$r = 0.863; $g = 0.078; $b = 0.235; break;
case 'cyan':
$r = 0.0; $g = 1.0; $b = 1.0; break;
case 'darkblue':
$r = 0.0; $g = 0.0; $b = 0.545; break;
case 'darkcyan':
$r = 0.0; $g = 0.545; $b = 0.545; break;
case 'darkgoldenrod':
$r = 0.722; $g = 0.525; $b = 0.043; break;
case 'darkgray':
$r = 0.663; $g = 0.663; $b = 0.663; break;
case 'darkgreen':
$r = 0.0; $g = 0.392; $b = 0.0; break;
case 'darkkhaki':
$r = 0.741; $g = 0.718; $b = 0.420; break;
case 'darkmagenta':
$r = 0.545; $g = 0.0; $b = 0.545; break;
case 'darkolivegreen':
$r = 0.333; $g = 0.420; $b = 0.184; break;
case 'darkorange':
$r = 1.0; $g = 0.549; $b = 0.0; break;
case 'darkorchid':
$r = 0.6; $g = 0.196; $b = 0.8; break;
case 'darkred':
$r = 0.545; $g = 0.0; $b = 0.0; break;
case 'darksalmon':
$r = 0.914; $g = 0.588; $b = 0.478; break;
case 'darkseagreen':
$r = 0.561; $g = 0.737; $b = 0.561; break;
case 'darkslateblue':
$r = 0.282; $g = 0.239; $b = 0.545; break;
case 'darkslategray':
$r = 0.184; $g = 0.310; $b = 0.310; break;
case 'darkturquoise':
$r = 0.0; $g = 0.808; $b = 0.820; break;
case 'darkviolet':
$r = 0.580; $g = 0.0; $b = 0.827; break;
case 'deeppink':
$r = 1.0; $g = 0.078; $b = 0.576; break;
case 'deepskyblue':
$r = 0.0; $g = 0.749; $b = 1.0; break;
case 'dimgray':
$r = 0.412; $g = 0.412; $b = 0.412; break;
case 'dodgerblue':
$r = 0.118; $g = 0.565; $b = 1.0; break;
case 'firebrick':
$r = 0.698; $g = 0.133; $b = 0.133; break;
case 'floralwhite':
$r = 1.0; $g = 0.980; $b = 0.941; break;
case 'forestgreen':
$r = 0.133; $g = 0.545; $b = 0.133; break;
case 'gainsboro':
$r = 0.863; $g = 0.863; $b = 0.863; break;
case 'ghostwhite':
$r = 0.973; $g = 0.973; $b = 1.0; break;
case 'gold':
$r = 1.0; $g = 0.843; $b = 0.0; break;
case 'goldenrod':
$r = 0.855; $g = 0.647; $b = 0.125; break;
case 'greenyellow':
$r = 0.678; $g = 1.0; $b = 0.184; break;
case 'honeydew':
$r = 0.941; $g = 1.0; $b = 0.941; break;
case 'hotpink':
$r = 1.0; $g = 0.412; $b = 0.706; break;
case 'indianred':
$r = 0.804; $g = 0.361; $b = 0.361; break;
case 'indigo':
$r = 0.294; $g = 0.0; $b = 0.510; break;
case 'ivory':
$r = 1.0; $g = 0.941; $b = 0.941; break;
case 'khaki':
$r = 0.941; $g = 0.902; $b = 0.549; break;
case 'lavender':
$r = 0.902; $g = 0.902; $b = 0.980; break;
case 'lavenderblush':
$r = 1.0; $g = 0.941; $b = 0.961; break;
case 'lawngreen':
$r = 0.486; $g = 0.988; $b = 0.0; break;
case 'lemonchiffon':
$r = 1.0; $g = 0.980; $b = 0.804; break;
case 'lightblue':
$r = 0.678; $g = 0.847; $b = 0.902; break;
case 'lightcoral':
$r = 0.941; $g = 0.502; $b = 0.502; break;
case 'lightcyan':
$r = 0.878; $g = 1.0; $b = 1.0; break;
case 'lightgoldenrodyellow':
$r = 0.980; $g = 0.980; $b = 0.824; break;
case 'lightgreen':
$r = 0.565; $g = 0.933; $b = 0.565; break;
case 'lightgrey':
$r = 0.827; $g = 0.827; $b = 0.827; break;
case 'lightpink':
$r = 1.0; $g = 0.714; $b = 0.757; break;
case 'lightsalmon':
$r = 1.0; $g = 0.627; $b = 0.478; break;
case 'lightseagreen':
$r = 0.125; $g = 0.698; $b = 0.667; break;
case 'lightskyblue':
$r = 0.529; $g = 0.808; $b = 0.980; break;
case 'lightslategray':
$r = 0.467; $g = 0.533; $b = 0.6; break;
case 'lightsteelblue':
$r = 0.690; $g = 0.769; $b = 0.871; break;
case 'lightyellow':
$r = 1.0; $g = 1.0; $b = 0.878; break;
case 'limegreen':
$r = 0.196; $g = 0.804; $b = 0.196; break;
case 'linen':
$r = 0.980; $g = 0.941; $b = 0.902; break;
case 'magenta':
$r = 1.0; $g = 0.0; $b = 1.0; break;
case 'mediumaquamarine':
$r = 0.4; $g = 0.804; $b = 0.667; break;
case 'mediumblue':
$r = 0.0; $g = 0.0; $b = 0.804; break;
case 'mediumorchid':
$r = 0.729; $g = 0.333; $b = 0.827; break;
case 'mediumpurple':
$r = 0.576; $g = 0.439; $b = 0.859; break;
case 'mediumseagreen':
$r = 0.235; $g = 0.702; $b = 0.443; break;
case 'mediumslateblue':
$r = 0.482; $g = 0.408; $b = 0.933; break;
case 'mediumspringgreen':
$r = 0.0; $g = 0.980; $b = 0.604; break;
case 'mediumturquoise':
$r = 0.282; $g = 0.820; $b = 0.8; break;
case 'mediumvioletred':
$r = 0.780; $g = 0.082; $b = 0.522; break;
case 'midnightblue':
$r = 0.098; $g = 0.098; $b = 0.439; break;
case 'mintcream':
$r = 0.961; $g = 1.0; $b = 0.980; break;
case 'mistyrose':
$r = 1.0; $g = 0.894; $b = 0.882; break;
case 'moccasin':
$r = 1.0; $g = 0.894; $b = 0.710; break;
case 'navajowhite':
$r = 1.0; $g = 0.871; $b = 0.678; break;
case 'oldlace':
$r = 0.992; $g = 0.961; $b = 0.902; break;
case 'olivedrab':
$r = 0.420; $g = 0.557; $b = 0.137; break;
case 'orange':
$r = 1.0; $g = 0.647; $b = 0.0; break;
case 'orangered':
$r = 1.0; $g = 0.271; $b = 0.0; break;
case 'orchid':
$r = 0.855; $g = 0.439; $b = 0.839; break;
case 'palegoldenrod':
$r = 0.933; $g = 0.910; $b = 0.667; break;
case 'palegreen':
$r = 0.596; $g = 0.984; $b = 0.596; break;
case 'paleturquoise':
$r = 0.686; $g = 0.933; $b = 0.933; break;
case 'palevioletred':
$r = 0.859; $g = 0.439; $b = 0.576; break;
case 'papayawhip':
$r = 1.0; $g = 0.937; $b = 0.835; break;
case 'peachpuff':
$r = 1.0; $g = 0.937; $b = 0.835; break;
case 'peru':
$r = 0.804; $g = 0.522; $b = 0.247; break;
case 'pink':
$r = 1.0; $g = 0.753; $b = 0.796; break;
case 'plum':
$r = 0.867; $g = 0.627; $b = 0.867; break;
case 'powderblue':
$r = 0.690; $g = 0.878; $b = 0.902; break;
case 'rosybrown':
$r = 0.737; $g = 0.561; $b = 0.561; break;
case 'royalblue':
$r = 0.255; $g = 0.412; $b = 0.882; break;
case 'saddlebrown':
$r = 0.545; $g = 0.271; $b = 0.075; break;
case 'salmon':
$r = 0.980; $g = 0.502; $b = 0.447; break;
case 'sandybrown':
$r = 0.957; $g = 0.643; $b = 0.376; break;
case 'seagreen':
$r = 0.180; $g = 0.545; $b = 0.341; break;
case 'seashell':
$r = 1.0; $g = 0.961; $b = 0.933; break;
case 'sienna':
$r = 0.627; $g = 0.322; $b = 0.176; break;
case 'skyblue':
$r = 0.529; $g = 0.808; $b = 0.922; break;
case 'slateblue':
$r = 0.416; $g = 0.353; $b = 0.804; break;
case 'slategray':
$r = 0.439; $g = 0.502; $b = 0.565; break;
case 'snow':
$r = 1.0; $g = 0.980; $b = 0.980; break;
case 'springgreen':
$r = 0.0; $g = 1.0; $b = 0.498; break;
case 'steelblue':
$r = 0.275; $g = 0.510; $b = 0.706; break;
case 'tan':
$r = 0.824; $g = 0.706; $b = 0.549; break;
case 'thistle':
$r = 0.847; $g = 0.749; $b = 0.847; break;
case 'tomato':
$r = 0.992; $g = 0.388; $b = 0.278; break;
case 'turquoise':
$r = 0.251; $g = 0.878; $b = 0.816; break;
case 'violet':
$r = 0.933; $g = 0.510; $b = 0.933; break;
case 'wheat':
$r = 0.961; $g = 0.871; $b = 0.702; break;
case 'whitesmoke':
$r = 0.961; $g = 0.961; $b = 0.961; break;
case 'yellowgreen':
$r = 0.604; $g = 0.804; $b = 0.196; break;
default:
throw new Zend_Pdf_Exception('Unknown color name: ' . $color);
}
if (($r == $g) && ($g == $b)) {
return new Zend_Pdf_Color_GrayScale($r);
} else {
return new Zend_Pdf_Color_Rgb($r, $g, $b);
}
}
}

106
libs/Zend/Pdf/Color/Rgb.php Normal file
View File

@ -0,0 +1,106 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/**
* RGB color implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Color_Rgb extends Zend_Pdf_Color
{
/**
* Red level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_r;
/**
* Green level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_g;
/**
* Blue level.
* 0.0 (zero concentration) - 1.0 (maximum concentration)
*
* @var Zend_Pdf_Element_Numeric
*/
private $_b;
/**
* Object constructor
*
* @param float $r
* @param float $g
* @param float $b
*/
public function __construct($r, $g, $b)
{
/** Clamp values to legal limits. */
if ($r < 0) { $r = 0; }
if ($r > 1) { $r = 1; }
if ($g < 0) { $g = 0; }
if ($g > 1) { $g = 1; }
if ($b < 0) { $b = 0; }
if ($b > 1) { $b = 1; }
$this->_r = new Zend_Pdf_Element_Numeric($r);
$this->_g = new Zend_Pdf_Element_Numeric($g);
$this->_b = new Zend_Pdf_Element_Numeric($b);
}
/**
* Instructions, which can be directly inserted into content stream
* to switch color.
* Color set instructions differ for stroking and nonstroking operations.
*
* @param boolean $stroking
* @return string
*/
public function instructions($stroking)
{
return $this->_r->toString() . ' '
. $this->_g->toString() . ' '
. $this->_b->toString() . ($stroking? " RG\n" : " rg\n");
}
}

159
libs/Zend/Pdf/Element.php Normal file
View File

@ -0,0 +1,159 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/**
* PDF file element implementation
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Element
{
const TYPE_BOOL = 1;
const TYPE_NUMERIC = 2;
const TYPE_STRING = 3;
const TYPE_NAME = 4;
const TYPE_ARRAY = 5;
const TYPE_DICTIONARY = 6;
const TYPE_STREAM = 7;
const TYPE_NULL = 11;
/**
* Reference to the top level indirect object, which contains this element.
*
* @var Zend_Pdf_Element_Object
*/
private $_parentObject = null;
/**
* Return type of the element.
* See ZPdfPDFConst for possible values
*
* @return integer
*/
abstract public function getType();
/**
* Convert element to a string, which can be directly
* written to a PDF file.
*
* $factory parameter defines operation context.
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
abstract public function toString($factory = null);
/**
* Set top level parent indirect object.
*
* @param Zend_Pdf_Element_Object $parent
*/
public function setParentObject(Zend_Pdf_Element_Object &$parent)
{
$this->_parentObject = &$parent;
}
/**
* Get top level parent indirect object.
*
* @return Zend_Pdf_Element_Object
*/
public function getParentObject()
{
return $this->_parentObject;
}
/**
* Mark object as modified, to include it into new PDF file segment.
*
* We don't automate this action to keep control on PDF update process.
* All new objects are treated as "modified" automatically.
*/
public function touch()
{
if ($this->_parentObject !== null) {
$this->_parentObject->touch();
}
}
/**
* Clean up resources, used by object
*/
public function cleanUp()
{
// Do nothing
}
/**
* Convert PDF element to PHP type.
*
* @return mixed
*/
public function toPhp()
{
return $this->value;
}
/**
* Convert PHP value into PDF element.
*
* @param mixed $input
* @return Zend_Pdf_Element
*/
public static function phpToPdf($input)
{
if (is_numeric($input)) {
return new Zend_Pdf_Element_Numeric($input);
} else if (is_bool($input)) {
return new Zend_Pdf_Element_Boolean($input);
} else if (is_array($input)) {
$pdfElementsArray = array();
$isDictionary = false;
foreach ($input as $key => $value) {
if (is_string($key)) {
$isDictionary = true;
}
$pdfElementsArray[$key] = Zend_Pdf_Element::phpToPdf($value);
}
if ($isDictionary) {
return new Zend_Pdf_Element_Dictionary($pdfElementsArray);
} else {
return new Zend_Pdf_Element_Array($pdfElementsArray);
}
} else {
return new Zend_Pdf_Element_String((string)$input);
}
}
}

View File

@ -0,0 +1,151 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_PhpArray */
require_once 'Zend/Pdf/PhpArray.php';
/**
* PDF file 'array' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Array extends Zend_Pdf_Element
{
/**
* Object value
* Array of Zend_Pdf_Element objects.
* Appropriate methods must (!) be used to modify it to provide correct
* work with objects and references.
*
* @var Zend_Pdf_PhpArray
*/
private $_items;
/**
* Object constructor
*
* @param array $val - array of Zend_Pdf_Element objects
* @throws Zend_Pdf_Exception
*/
public function __construct($val = null)
{
$this->_items = new Zend_Pdf_PhpArray();
if ($val !== null && is_array($val)) {
foreach ($val as $element) {
if (!$element instanceof Zend_Pdf_Element) {
throw new Zend_Pdf_Exception('Array elements must be Zend_Pdf_Element objects');
}
$this->_items[] = $element;
}
} else if ($val !== null){
throw new Zend_Pdf_Exception('Argument must be an array');
}
}
/**
* Provides access to $this->_items
*
* @param string $property
* @return Zend_Pdf_PhpArray
*/
public function __get($property) {
if ($property=='items') {
return $this->_items;
}
throw new Exception('Undefined property: Zend_Pdf_Element_Array::$' . $property);
}
/**
* Provides read-only access to $this->_items;
*
* @param unknown_type $offset
* @param unknown_type $value
*/
public function __set($property, $value) {
if ($property=='items') {
throw new Exception('Array container cannot be overwritten');
}
throw new Exception('Undefined property: Zend_Pdf_Element_Array::$' . $property);
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_ARRAY;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
$outStr = '[';
$lastNL = 0;
foreach ($this->_items as $element) {
if (strlen($outStr) - $lastNL > 128) {
$outStr .= "\n";
$lastNL = strlen($outStr);
}
$outStr .= $element->toString($factory) . ' ';
}
$outStr .= ']';
return $outStr;
}
/**
* Convert PDF element to PHP type.
*
* Dictionary is returned as an associative array
*
* @return mixed
*/
public function toPhp()
{
foreach ($this->_items as $item) {
$phpArray[] = $item->toPhp();
}
return $phpArray;
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/**
* PDF file 'boolean' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Boolean extends Zend_Pdf_Element
{
/**
* Object value
*
* @var boolean
*/
public $value;
/**
* Object constructor
*
* @param boolean $val
* @throws Zend_Pdf_Exception
*/
public function __construct($val)
{
if (! is_bool($val)) {
throw new Zend_Pdf_Exception('Argument must be boolean.');
}
$this->value = $val;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_BOOL;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
return $this->value ? 'true' : 'false';
}
}

View File

@ -0,0 +1,181 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/**
* PDF file 'dictionary' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Dictionary extends Zend_Pdf_Element
{
/**
* Dictionary elements
* Array of Zend_Pdf_Element objects ('name' => Zend_Pdf_Element)
*
* @var array
*/
private $_items = array();
/**
* Object constructor
*
* @param array $val - array of Zend_Pdf_Element objects
* @throws Zend_Pdf_Exception
*/
public function __construct($val = null)
{
if ($val === null) {
return;
} else if (!is_array($val)) {
throw new Zend_Pdf_Exception('Argument must be an array');
}
foreach ($val as $name => $element) {
if (!$element instanceof Zend_Pdf_Element) {
throw new Zend_Pdf_Exception('Array elements must be Zend_Pdf_Element objects');
}
if (!is_string($name)) {
throw new Zend_Pdf_Exception('Array keys must be strings');
}
$this->_items[$name] = $element;
}
}
/**
* Add element to an array
*
* @name Zend_Pdf_Element_Name $name
* @param Zend_Pdf_Element $val - Zend_Pdf_Element object
* @throws Zend_Pdf_Exception
*/
public function add(Zend_Pdf_Element_Name $name, Zend_Pdf_Element $val)
{
$this->_items[$name->value] = $val;
}
/**
* Return dictionary keys
*
* @return array
*/
public function getKeys()
{
return array_keys($this->_items);
}
/**
* Get handler
*
* @param string $property
* @return Zend_Pdf_Element | null
*/
public function __get($item)
{
$element = isset($this->_items[$item]) ? $this->_items[$item]
: null;
return $element;
}
/**
* Set handler
*
* @param string $property
* @param mixed $value
*/
public function __set($item, $value)
{
if ($value === null) {
unset($this->_items[$item]);
} else {
$this->_items[$item] = $value;
}
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_DICTIONARY;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
$outStr = '<<';
$lastNL = 0;
foreach ($this->_items as $name => $element) {
if (!is_object($element)) {
throw new Zend_Pdf_Exception('Wrong data');
}
if (strlen($outStr) - $lastNL > 128) {
$outStr .= "\n";
$lastNL = strlen($outStr);
}
$nameObj = new Zend_Pdf_Element_Name($name);
$outStr .= $nameObj->toString($factory) . ' ' . $element->toString($factory) . ' ';
}
$outStr .= '>>';
return $outStr;
}
/**
* Convert PDF element to PHP type.
*
* Dictionary is returned as an associative array
*
* @return mixed
*/
public function toPhp()
{
$phpArray = array();
foreach ($this->_items as $itemName => $item) {
$phpArray[$itemName] = $item->toPhp();
}
return $phpArray;
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/**
* PDF file 'name' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Name extends Zend_Pdf_Element
{
/**
* Object value
*
* @var string
*/
public $value;
/**
* Object constructor
*
* @param string $val
* @throws Zend_Pdf_Exception
*/
public function __construct($val)
{
settype($val, 'string');
if (strpos($val,"\x00") !== false) {
throw new Zend_Pdf_Exception('Null character is not allowed in PDF Names');
}
$this->value = (string)$val;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_NAME;
}
/**
* Escape string according to the PDF rules
*
* @param string $inStr
* @return string
*/
public static function escape($inStr)
{
$outStr = '';
for ($count = 0; $count < strlen($inStr); $count++) {
$nextCode = ord($inStr[$count]);
switch ($inStr[$count]) {
case '(':
// fall through to next case
case ')':
// fall through to next case
case '<':
// fall through to next case
case '>':
// fall through to next case
case '[':
// fall through to next case
case ']':
// fall through to next case
case '{':
// fall through to next case
case '}':
// fall through to next case
case '/':
// fall through to next case
case '%':
// fall through to next case
case '\\':
// fall through to next case
case '#':
$outStr .= sprintf('#%02X', $nextCode);
break;
default:
if ($nextCode >= 33 && $nextCode <= 126 ) {
// Visible ASCII symbol
$outStr .= $inStr[$count];
} else {
$outStr .= sprintf('#%02X', $nextCode);
}
}
}
return $outStr;
}
/**
* Unescape string according to the PDF rules
*
* @param string $inStr
* @return string
*/
public static function unescape($inStr)
{
$outStr = '';
for ($count = 0; $count < strlen($inStr); $count++) {
if ($inStr[$count] != '#' ) {
$outStr .= $inStr[$count];
} else {
// Escape sequence
$outStr .= chr(base_convert(substr($inStr, $count+1, 2), 16, 10 ));
$count +=2;
}
}
return $outStr;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
return '/' . self::escape((string)$this->value);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/**
* PDF file 'null' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Null extends Zend_Pdf_Element
{
/**
* Object value. Always null.
*
* @var mixed
*/
public $value;
/**
* Object constructor
*/
public function __construct()
{
$this->value = null;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_NULL;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
return 'null';
}
}

View File

@ -0,0 +1,93 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/**
* PDF file 'numeric' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Numeric extends Zend_Pdf_Element
{
/**
* Object value
*
* @var numeric
*/
public $value;
/**
* Object constructor
*
* @param numeric $val
* @throws Zend_Pdf_Exception
*/
public function __construct($val)
{
if ( !is_numeric($val) ) {
throw new Zend_Pdf_Exception('Argument must be numeric');
}
$this->value = $val;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_NUMERIC;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
if (is_integer($this->value)) {
return (string)$this->value;
}
/**
* PDF doesn't support exponental format.
* Fixed point format must be used instead
*/
$prec = 0; $v = $this->value;
while (abs( floor($v) - $v ) > 1e-10) {
$prec++; $v *= 10;
}
return sprintf("%.{$prec}F", $this->value);
}
}

View File

@ -0,0 +1,250 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_ElementFactory */
require_once 'Zend/Pdf/ElementFactory.php';
/**
* PDF file 'indirect object' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Object extends Zend_Pdf_Element
{
/**
* Object value
*
* @var Zend_Pdf_Element
*/
protected $_value;
/**
* Object number within PDF file
*
* @var integer
*/
protected $_objNum;
/**
* Generation number
*
* @var integer
*/
protected $_genNum;
/**
* Reference to the factory.
*
* @var Zend_Pdf_ElementFactory
*/
protected $_factory;
/**
* Object constructor
*
* @param Zend_Pdf_Element $val
* @param integer $objNum
* @param integer $genNum
* @param Zend_Pdf_ElementFactory $factory
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory)
{
if ($val instanceof self) {
throw new Zend_Pdf_Exception('Object number must not be instance of Zend_Pdf_Element_Object.');
}
if ( !(is_integer($objNum) && $objNum > 0) ) {
throw new Zend_Pdf_Exception('Object number must be positive integer.');
}
if ( !(is_integer($genNum) && $genNum >= 0) ) {
throw new Zend_Pdf_Exception('Generation number must be non-negative integer.');
}
$this->_value = $val;
$this->_objNum = $objNum;
$this->_genNum = $genNum;
$this->_factory = $factory;
$factory->registerObject($this);
}
/**
* Check, that object is generated by specified factory
*
* @return Zend_Pdf_ElementFactory
*/
public function getFactory()
{
return $this->_factory;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return $this->_value->getType();
}
/**
* Get object number
*
* @return integer
*/
public function getObjNum()
{
return $this->_objNum;
}
/**
* Get generation number
*
* @return integer
*/
public function getGenNum()
{
return $this->_genNum;
}
/**
* Return reference to the object
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
if ($factory === null) {
$shift = 0;
} else {
$shift = $factory->getEnumerationShift($this->_factory);
}
return $this->_objNum + $shift . ' ' . $this->_genNum . ' R';
}
/**
* Dump object to a string to save within PDF file.
*
* $factory parameter defines operation context.
*
* @param Zend_Pdf_ElementFactory $factory
* @return string
*/
public function dump(Zend_Pdf_ElementFactory $factory)
{
$shift = $factory->getEnumerationShift($this->_factory);
return $this->_objNum + $shift . " " . $this->_genNum . " obj \n"
. $this->_value->toString($factory) . "\n"
. "endobj\n";
}
/**
* Get handler
*
* @param string $property
* @return mixed
*/
public function __get($property)
{
return $this->_value->$property;
}
/**
* Set handler
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value)
{
$this->_value->$property = $value;
}
/**
* Call handler
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
switch (count($args)) {
case 0:
return $this->_value->$method();
case 1:
return $this->_value->$method($args[0]);
case 2:
return $this->_value->$method($args[0], $args[1]);
case 3:
return $this->_value->$method($args[0], $args[1], $args[2]);
case 4:
return $this->_value->$method($args[0], $args[1], $args[2], $args[3]);
default:
throw new Zend_Pdf_Exception('Unsupported number of arguments');
}
}
/**
* Mark object as modified, to include it into new PDF file segment
*/
public function touch()
{
$this->_factory->markAsModified($this);
}
/**
* Clean up resources, used by object
*/
public function cleanUp()
{
$this->_value = null;
}
/**
* Convert PDF element to PHP type.
*
* @return mixed
*/
public function toPhp()
{
return $this->_value->toPhp();
}
}

View File

@ -0,0 +1,409 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Stream */
require_once 'Zend/Pdf/Element/Stream.php';
/** Zend_Pdf_Filter_Ascii85 */
require_once 'Zend/Pdf/Filter/Ascii85.php';
/** Zend_Pdf_Filter_AsciiHex */
require_once 'Zend/Pdf/Filter/AsciiHex.php';
/** Zend_Pdf_Filter_Compression_Flate */
require_once 'Zend/Pdf/Filter/Compression/Flate.php';
/** Zend_Pdf_Filter_Compression_Lzw */
require_once 'Zend/Pdf/Filter/Compression/Lzw.php';
/** Zend_Pdf_ElementFactory */
require_once 'Zend/Pdf/ElementFactory.php';
/**
* PDF file 'stream object' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Object_Stream extends Zend_Pdf_Element_Object
{
/**
* StreamObject dictionary
* Required enries:
* Length
*
* @var Zend_Pdf_Element_Dictionary
*/
private $_dictionary;
/**
* Flag which signals, that stream is decoded
*
* @var boolean
*/
private $_streamDecoded;
/**
* Stored original stream object dictionary.
* Used to decode stream during an access time.
*
* The only properties, which affect decoding, are sored here.
*
* @var array|null
*/
private $_originalDictionary = null;
/**
* Object constructor
*
* @param mixed $val
* @param integer $objNum
* @param integer $genNum
* @param Zend_Pdf_ElementFactory $factory
* @param Zend_Pdf_Element_Dictionary|null $dictionary
* @throws Zend_Pdf_Exception
*/
public function __construct($val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory, $dictionary = null)
{
parent::__construct(new Zend_Pdf_Element_Stream($val), $objNum, $genNum, $factory);
if ($dictionary === null) {
$this->_dictionary = new Zend_Pdf_Element_Dictionary();
$this->_dictionary->Length = new Zend_Pdf_Element_Numeric(strlen( $val ));
$this->_streamDecoded = true;
} else {
$this->_dictionary = $dictionary;
$this->_streamDecoded = false;
}
}
/**
* Store original dictionary information in $_originalDictionary class member.
* Used to store information and to normalize filters information before defiltering.
*
*/
private function _storeOriginalDictionary()
{
$this->_originalDictionary = array();
$this->_originalDictionary['Filter'] = array();
$this->_originalDictionary['DecodeParms'] = array();
if ($this->_dictionary->Filter === null) {
// Do nothing.
} else if ($this->_dictionary->Filter->getType() == Zend_Pdf_Element::TYPE_ARRAY) {
foreach ($this->_dictionary->Filter->items as $id => $filter) {
$this->_originalDictionary['Filter'][$id] = $filter->value;
$this->_originalDictionary['DecodeParms'][$id] = array();
if ($this->_dictionary->DecodeParms !== null ) {
if ($this->_dictionary->DecodeParms->items[$id] !== null &&
$this->_dictionary->DecodeParms->items[$id]->value !== null ) {
foreach ($this->_dictionary->DecodeParms->items[$id]->getKeys() as $paramKey) {
$this->_originalDictionary['DecodeParms'][$id][$paramKey] =
$this->_dictionary->DecodeParms->items[$id]->$paramKey->value;
}
}
}
}
} else if ($this->_dictionary->Filter->getType() != Zend_Pdf_Element::TYPE_NULL) {
$this->_originalDictionary['Filter'][0] = $this->_dictionary->Filter->value;
$this->_originalDictionary['DecodeParms'][0] = array();
if ($this->_dictionary->DecodeParms !== null ) {
foreach ($this->_dictionary->DecodeParms->getKeys() as $paramKey) {
$this->_originalDictionary['DecodeParms'][0][$paramKey] =
$this->_dictionary->DecodeParms->$paramKey->value;
}
}
}
if ($this->_dictionary->F !== null) {
$this->_originalDictionary['F'] = $this->_dictionary->F->value;
}
$this->_originalDictionary['FFilter'] = array();
$this->_originalDictionary['FDecodeParms'] = array();
if ($this->_dictionary->FFilter === null) {
// Do nothing.
} else if ($this->_dictionary->FFilter->getType() == Zend_Pdf_Element::TYPE_ARRAY) {
foreach ($this->_dictionary->FFilter->items as $id => $filter) {
$this->_originalDictionary['FFilter'][$id] = $filter->value;
$this->_originalDictionary['FDecodeParms'][$id] = array();
if ($this->_dictionary->FDecodeParms !== null ) {
if ($this->_dictionary->FDecodeParms->items[$id] !== null &&
$this->_dictionary->FDecodeParms->items[$id]->value !== null) {
foreach ($this->_dictionary->FDecodeParms->items[$id]->getKeys() as $paramKey) {
$this->_originalDictionary['FDecodeParms'][$id][$paramKey] =
$this->_dictionary->FDecodeParms->items[$id]->items[$paramKey]->value;
}
}
}
}
} else {
$this->_originalDictionary['FFilter'][0] = $this->_dictionary->FFilter->value;
$this->_originalDictionary['FDecodeParms'][0] = array();
if ($this->_dictionary->FDecodeParms !== null ) {
foreach ($this->_dictionary->FDecodeParms->getKeys() as $paramKey) {
$this->_originalDictionary['FDecodeParms'][0][$paramKey] =
$this->_dictionary->FDecodeParms->items[$paramKey]->value;
}
}
}
}
/**
* Decode stream
*
* @throws Zend_Pdf_Exception
*/
private function _decodeStream()
{
if ($this->_originalDictionary === null) {
$this->_storeOriginalDictionary();
}
/**
* All applied stream filters must be processed to decode stream.
* If we don't recognize any of applied filetrs an exception should be thrown here
*/
if (isset($this->_originalDictionary['F'])) {
/** @todo Check, how external files can be processed. */
throw new Zend_Pdf_Exception('External filters are not supported now.');
}
foreach ($this->_originalDictionary['Filter'] as $id => $filterName ) {
$valueRef = &$this->_value->value->getRef();
$this->_value->value->touch();
switch ($filterName) {
case 'ASCIIHexDecode':
$valueRef = Zend_Pdf_Filter_AsciiHex::decode($valueRef);
break;
case 'ASCII85Decode':
$valueRef = Zend_Pdf_Filter_Ascii85::decode($valueRef);
break;
case 'FlateDecode':
$valueRef = Zend_Pdf_Filter_Compression_Flate::decode($valueRef,
$this->_originalDictionary['DecodeParms'][$id]);
break;
case 'LZWDecode':
$valueRef = Zend_Pdf_Filter_Compression_Lzw::decode($valueRef,
$this->_originalDictionary['DecodeParms'][$id]);
break;
default:
throw new Zend_Pdf_Exception('Unknown stream filter: \'' . $filterName . '\'.');
}
}
$this->_streamDecoded = true;
}
/**
* Encode stream
*
* @throws Zend_Pdf_Exception
*/
private function _encodeStream()
{
/**
* All applied stream filters must be processed to encode stream.
* If we don't recognize any of applied filetrs an exception should be thrown here
*/
if (isset($this->_originalDictionary['F'])) {
/** @todo Check, how external files can be processed. */
throw new Zend_Pdf_Exception('External filters are not supported now.');
}
$filters = array_reverse($this->_originalDictionary['Filter'], true);
foreach ($filters as $id => $filterName ) {
$valueRef = &$this->_value->value->getRef();
$this->_value->value->touch();
switch ($filterName) {
case 'ASCIIHexDecode':
$valueRef = Zend_Pdf_Filter_AsciiHex::encode($valueRef);
break;
case 'ASCII85Decode':
$valueRef = Zend_Pdf_Filter_Ascii85::encode($valueRef);
break;
case 'FlateDecode':
$valueRef = Zend_Pdf_Filter_Compression_Flate::encode($valueRef,
$this->_originalDictionary['DecodeParms'][$id]);
break;
case 'LZWDecode':
$valueRef = Zend_Pdf_Filter_Compression_Lzw::encode($valueRef,
$this->_originalDictionary['DecodeParms'][$id]);
break;
default:
throw new Zend_Pdf_Exception('Unknown stream filter: \'' . $filterName . '\'.');
}
}
$this->_streamDecoded = false;
}
/**
* Get handler
*
* @param string $property
* @return mixed
* @throws Zend_Pdf_Exception
*/
public function __get($property)
{
if ($property == 'dictionary') {
/**
* If stream is note decoded yet, then store original decoding options (do it only once).
*/
if (( !$this->_streamDecoded ) && ($this->_originalDictionary === null)) {
$this->_storeOriginalDictionary();
}
return $this->_dictionary;
}
if ($property == 'value') {
if (!$this->_streamDecoded) {
$this->_decodeStream();
}
return $this->_value->value->getRef();
}
throw new Zend_Pdf_Exception('Unknown stream object property requested.');
}
/**
* Set handler
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value)
{
if ($property == 'value') {
$valueRef = &$this->_value->value->getRef();
$valueRef = $value;
$this->_value->value->touch();
$this->_streamDecoded = true;
return;
}
throw new Zend_Pdf_Exception('Unknown stream object property: \'' . $property . '\'.');
}
/**
* Treat stream data as already encoded
*/
public function skipFilters()
{
$this->_streamDecoded = false;
}
/**
* Call handler
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
if (!$this->_streamDecoded) {
$this->_decodeStream();
}
switch (count($args)) {
case 0:
return $this->_value->$method();
case 1:
return $this->_value->$method($args[0]);
default:
throw new Zend_Pdf_Exception('Unsupported number of arguments');
}
}
/**
* Dump object to a string to save within PDF file
*
* $factory parameter defines operation context.
*
* @param Zend_Pdf_ElementFactory $factory
* @return string
*/
public function dump(Zend_Pdf_ElementFactory $factory)
{
$shift = $factory->getEnumerationShift($this->_factory);
if ($this->_streamDecoded) {
$this->_storeOriginalDictionary();
$this->_encodeStream();
} else if ($this->_originalDictionary != null) {
$startDictionary = $this->_originalDictionary;
$this->_storeOriginalDictionary();
$newDictionary = $this->_originalDictionary;
if ($startDictionary !== $newDictionary) {
$this->_originalDictionary = $startDictionary;
$this->_decodeStream();
$this->_originalDictionary = $newDictionary;
$this->_encodeStream();
}
}
// Update stream length
$this->dictionary->Length->value = $this->_value->length();
return $this->_objNum + $shift . " " . $this->_genNum . " obj \n"
. $this->dictionary->toString($factory) . "\n"
. $this->_value->toString($factory) . "\n"
. "endobj\n";
}
/**
* Clean up resources, used by object
*/
public function cleanUp()
{
$this->_dictionary = null;
$this->_value = null;
}
}

View File

@ -0,0 +1,280 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_Element_Reference_Context */
require_once 'Zend/Pdf/Element/Reference/Context.php';
/** Zend_Pdf_Element_Reference_Table */
require_once 'Zend/Pdf/Element/Reference/Table.php';
/** Zend_Pdf_ElementFactory */
require_once 'Zend/Pdf/ElementFactory.php';
/**
* PDF file 'reference' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Reference extends Zend_Pdf_Element
{
/**
* Object value
* The reference to the object
*
* @var mixed
*/
private $_ref;
/**
* Object number within PDF file
*
* @var integer
*/
private $_objNum;
/**
* Generation number
*
* @var integer
*/
private $_genNum;
/**
* Reference context
*
* @var Zend_Pdf_Element_Reference_Context
*/
private $_context;
/**
* Reference to the factory.
*
* It's the same as referenced object factory, but we save it here to avoid
* unnecessary dereferencing, whech can produce cascade dereferencing and parsing.
* The same for duplication of getFactory() function. It can be processed by __call()
* method, but we catch it here.
*
* @var Zend_Pdf_ElementFactory
*/
private $_factory;
/**
* Object constructor:
*
* @param integer $objNum
* @param integer $genNum
* @param Zend_Pdf_Element_Reference_Context $context
* @param Zend_Pdf_ElementFactory $factory
* @throws Zend_Pdf_Exception
*/
public function __construct($objNum, $genNum = 0, Zend_Pdf_Element_Reference_Context $context, Zend_Pdf_ElementFactory $factory)
{
if ( !(is_integer($objNum) && $objNum > 0) ) {
throw new Zend_Pdf_Exception('Object number must be positive integer');
}
if ( !(is_integer($genNum) && $genNum >= 0) ) {
throw new Zend_Pdf_Exception('Generation number must be non-negative integer');
}
$this->_objNum = $objNum;
$this->_genNum = $genNum;
$this->_ref = null;
$this->_context = $context;
$this->_factory = $factory;
}
/**
* Check, that object is generated by specified factory
*
* @return Zend_Pdf_ElementFactory
*/
public function getFactory()
{
return $this->_factory;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
if ($this->_ref === null) {
$this->_dereference();
}
return $this->_ref->getType();
}
/**
* Return reference to the object
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
if ($factory === null) {
$shift = 0;
} else {
$shift = $factory->getEnumerationShift($this->_factory);
}
return $this->_objNum + $shift . ' ' . $this->_genNum . ' R';
}
/**
* Dereference.
* Take inderect object, take $value member of this object (must be Zend_Pdf_Element),
* take reference to the $value member of this object and assign it to
* $value member of current PDF Reference object
* $obj can be null
*
* @throws Zend_Pdf_Exception
*/
private function _dereference()
{
$obj = $this->_context->getParser()->getObject(
$this->_context->getRefTable()->getOffset($this->_objNum . ' ' . $this->_genNum . ' R'),
$this->_context
);
if ($obj === null ) {
$this->_ref = new Zend_Pdf_Element_Null();
return;
}
if ($obj->toString() != $this->_objNum . ' ' . $this->_genNum . ' R') {
throw new Zend_Pdf_Exception('Incorrect reference to the object');
}
$this->_ref = $obj;
$this->setParentObject($obj);
$this->_factory->registerObject($this);
}
/**
* Mark object as modified, to include it into new PDF file segment.
*/
public function touch()
{
if ($this->_ref === null) {
$this->_dereference();
}
$this->_ref->touch();
}
/**
* Get handler
*
* @param string $property
* @return mixed
*/
public function __get($property)
{
if ($this->_ref === null) {
$this->_dereference();
}
return $this->_ref->$property;
}
/**
* Set handler
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value)
{
if ($this->_ref === null) {
$this->_dereference();
}
$this->_ref->$property = $value;
}
/**
* Call handler
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
if ($this->_ref === null) {
$this->_dereference();
}
switch (count($args)) {
case 0:
return $this->_ref->$method();
case 1:
return $this->_ref->$method($args[0]);
case 2:
return $this->_ref->$method($args[0], $args[1]);
case 3:
return $this->_ref->$method($args[0], $args[1], $args[2]);
case 4:
return $this->_ref->$method($args[0], $args[1], $args[2], $args[3]);
default:
throw new Zend_Pdf_Exception('Unsupported number of arguments');
}
}
/**
* Clean up resources
*/
public function cleanUp()
{
$this->_ref = null;
}
/**
* Convert PDF element to PHP type.
*
* @return mixed
*/
public function toPhp()
{
if ($this->_ref === null) {
$this->_dereference();
}
return $this->_ref->toPhp();
}
}

View File

@ -0,0 +1,89 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_StringParser */
require_once 'Zend/Pdf/StringParser.php';
/** Zend_Pdf_Element_Reference_Table */
require_once 'Zend/Pdf/Element/Reference/Table.php';
/**
* PDF reference object context
* Reference context is defined by PDF parser and PDF Refernce table
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Reference_Context
{
/**
* PDF parser object.
*
* @var Zend_Pdf_Parser
*/
private $_stringParser;
/**
* Reference table
*
* @var Zend_Pdf_Element_Reference_Table
*/
private $_refTable;
/**
* Object constructor
*
* @param Zend_Pdf_StringParser $parser
* @param Zend_Pdf_Element_Reference_Table $refTable
*/
public function __construct(Zend_Pdf_StringParser $parser,
Zend_Pdf_Element_Reference_Table $refTable)
{
$this->_stringParser = $parser;
$this->_refTable = $refTable;
}
/**
* Context parser
*
* @return Zend_Pdf_Parser
*/
public function getParser()
{
return $this->_stringParser;
}
/**
* Context reference table
*
* @return Zend_Pdf_Element_Reference_Table
*/
public function getRefTable()
{
return $this->_refTable;
}
}

View File

@ -0,0 +1,193 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* PDF file reference table
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Reference_Table
{
/**
* Parent reference table
*
* @var Zend_Pdf_Element_Reference_Table
*/
private $_parent;
/**
* Free entries
* 'reference' => next free object number
*
* @var array
*/
private $_free;
/**
* Generation numbers for free objects.
* Array: objNum => nextGeneration
*
* @var array
*/
private $_generations;
/**
* In use entries
* 'reference' => offset
*
* @var array
*/
private $_inuse;
/**
* Generation numbers for free objects.
* Array: objNum => objGeneration
*
* @var array
*/
private $_usedObjects;
/**
* Object constructor
*/
public function __construct()
{
$this->_parent = null;
$this->_free = array(); $this->_generations = array();
$this->_inuse = array(); $this->_usedObjects = array();
}
/**
* Add reference to the reference table
*
* @param string $ref
* @param integer $offset
* @param boolean $inuse
*/
public function addReference($ref, $offset, $inuse = true)
{
$refElements = explode(' ', $ref);
if (!is_numeric($refElements[0]) || !is_numeric($refElements[1]) || $refElements[2] != 'R') {
throw new Zend_Pdf_Exception("Incorrect reference: '$ref'");
}
$objNum = (int)$refElements[0];
$genNum = (int)$refElements[1];
if ($inuse) {
$this->_inuse[$ref] = $offset;
$this->_usedObjects[$objNum] = $objNum;
} else {
$this->_free[$ref] = $offset;
$this->_generations[$objNum] = $genNum;
}
}
/**
* Set parent reference table
*
* @param Zend_Pdf_Element_Reference_Table $parent
*/
public function setParent(self $parent)
{
$this->_parent = $parent;
}
/**
* Get object offset
*
* @param string $ref
* @return integer
*/
public function getOffset($ref)
{
if (isset($this->_inuse[$ref])) {
return $this->_inuse[$ref];
}
if (isset($this->_free[$ref])) {
return null;
}
if (isset($this->_parent)) {
return $this->_parent->getOffset($ref);
}
return null;
}
/**
* Get next object from a list of free objects.
*
* @param string $ref
* @return integer
* @throws Zend_Pdf_Exception
*/
public function getNextFree($ref)
{
if (isset($this->_inuse[$ref])) {
throw new Zend_Pdf_Exception('Object is not free');
}
if (isset($this->_free[$ref])) {
return $this->_free[$ref];
}
if (isset($this->_parent)) {
return $this->_parent->getNextFree($ref);
}
throw new Zend_Pdf_Exception('Object not found.');
}
/**
* Get next generation number for free object
*
* @param integer $objNum
* @return unknown
*/
public function getNewGeneration($objNum)
{
if (isset($this->_usedObjects[$objNum])) {
throw new Zend_Pdf_Exception('Object is not free');
}
if (isset($this->_generations[$objNum])) {
return $this->_generations[$objNum];
}
if (isset($this->_parent)) {
return $this->_parent->getNewGeneration($objNum);
}
throw new Zend_Pdf_Exception('Object not found.');
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* @see Zend_Pdf
*/
require_once 'Zend/Pdf.php';
/**
* @see Zend_Pdf_Element
*/
require_once 'Zend/Pdf/Element.php';
/**
* @see Zend_Memory
*/
require_once 'Zend/Memory.php';
/**
* PDF file 'stream' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_Stream extends Zend_Pdf_Element
{
/**
* Object value
*
* @var Zend_Memory_Container
*/
public $value;
/**
* Object constructor
*
* @param string $val
*/
public function __construct($val)
{
$this->value = Zend_Pdf::getMemoryManager()->create($val);
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_STREAM;
}
/**
* Stream length.
* (Method is used to avoid string copying, which may occurs in some cases)
*
* @return integer
*/
public function length()
{
return strlen($this->value->getRef());
}
/**
* Clear stream
*
*/
public function clear()
{
$ref = &$this->value->getRef();
$ref = '';
$this->value->touch();
}
/**
* Append value to a stream
*
* @param mixed $val
*/
public function append($val)
{
$ref = &$this->value->getRef();
$ref .= (string)$val;
$this->value->touch();
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
return "stream\n" . $this->value->getRef() . "\nendstream";
}
}

View File

@ -0,0 +1,246 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/**
* PDF file 'string' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_String extends Zend_Pdf_Element
{
/**
* Object value
*
* @var string
*/
public $value;
/**
* Object constructor
*
* @param string $val
*/
public function __construct($val)
{
$this->value = (string)$val;
}
/**
* Return type of the element.
*
* @return integer
*/
public function getType()
{
return Zend_Pdf_Element::TYPE_STRING;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
return '(' . self::escape((string)$this->value) . ')';
}
/**
* Escape string according to the PDF rules
*
* @param string $inStr
* @return string
*/
public static function escape($inStr)
{
$outStr = '';
$lastNL = 0;
for ($count = 0; $count < strlen($inStr); $count++) {
if (strlen($outStr) - $lastNL > 128) {
$outStr .= "\\\n";
$lastNL = strlen($outStr);
}
$nextCode = ord($inStr[$count]);
switch ($nextCode) {
// "\n" - line feed (LF)
case 10:
$outStr .= '\\n';
break;
// "\r" - carriage return (CR)
case 13:
$outStr .= '\\r';
break;
// "\t" - horizontal tab (HT)
case 9:
$outStr .= '\\t';
break;
// "\b" - backspace (BS)
case 8:
$outStr .= '\\b';
break;
// "\f" - form feed (FF)
case 12:
$outStr .= '\\f';
break;
// '(' - left paranthesis
case 40:
$outStr .= '\\(';
break;
// ')' - right paranthesis
case 41:
$outStr .= '\\)';
break;
// '\' - backslash
case 92:
$outStr .= '\\\\';
break;
default:
// Don't use non-ASCII characters escaping
// if ($nextCode >= 32 && $nextCode <= 126 ) {
// // Visible ASCII symbol
// $outStr .= $inStr[$count];
// } else {
// $outStr .= sprintf('\\%03o', $nextCode);
// }
$outStr .= $inStr[$count];
break;
}
}
return $outStr;
}
/**
* Unescape string according to the PDF rules
*
* @param string $inStr
* @return string
*/
public static function unescape($inStr)
{
$outStr = '';
for ($count = 0; $count < strlen($inStr); $count++) {
if ($inStr[$count] != '\\' || $count == strlen($inStr)-1) {
$outStr .= $inStr[$count];
} else { // Escape sequence
switch ($inStr{++$count}) {
// '\\n' - line feed (LF)
case 'n':
$outStr .= "\n";
break;
// '\\r' - carriage return (CR)
case 'r':
$outStr .= "\r";
break;
// '\\t' - horizontal tab (HT)
case 't':
$outStr .= "\t";
break;
// '\\b' - backspace (BS)
case 'b':
$outStr .= "\x08";
break;
// '\\f' - form feed (FF)
case 'f':
$outStr .= "\x0C";
break;
// '\\(' - left paranthesis
case '(':
$outStr .= '(';
break;
// '\\)' - right paranthesis
case ')':
$outStr .= ')';
break;
// '\\\\' - backslash
case '\\':
$outStr .= '\\';
break;
// "\\\n" or "\\\n\r"
case "\n":
// skip new line symbol
if ($inStr[$count+1] == "\r") {
$count++;
}
break;
default:
if (ord($inStr[$count]) >= ord('0') &&
ord($inStr[$count]) <= ord('9')) {
// Character in octal representation
// '\\xxx'
$nextCode = '0' . $inStr[$count];
if (ord($inStr[$count+1]) >= ord('0') &&
ord($inStr[$count+1]) <= ord('9')) {
$nextCode .= $inStr{++$count};
if (ord($inStr[$count+1]) >= ord('0') &&
ord($inStr[$count+1]) <= ord('9')) {
$nextCode .= $inStr{++$count};
}
}
$outStr .= chr($nextCode);
} else {
$outStr .= $inStr[$count];
}
break;
}
}
}
return $outStr;
}
}

View File

@ -0,0 +1,110 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element_String */
require_once 'Zend/Pdf/Element/String.php';
/**
* PDF file 'binary string' element implementation
*
* @category Zend
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Element_String_Binary extends Zend_Pdf_Element_String
{
/**
* Object value
*
* @var string
*/
public $value;
/**
* Escape string according to the PDF rules
*
* @param string $inStr
* @return string
*/
public static function escape($inStr)
{
$outStr = '';
for ($count = 0; $count < strlen($inStr); $count++) {
$outStr .= sprintf('%02X', ord($inStr[$count]));
}
return $outStr;
}
/**
* Unescape string according to the PDF rules
*
* @param string $inStr
* @return string
*/
public static function unescape($inStr)
{
$outStr = '';
$nextHexCode = '';
for ($count = 0; $count < strlen($inStr); $count++) {
$nextCharCode = ord($inStr[$count]);
if( ($nextCharCode >= 48 /*'0'*/ &&
$nextCharCode <= 57 /*'9'*/ ) ||
($nextCharCode >= 97 /*'a'*/ &&
$nextCharCode <= 102 /*'f'*/ ) ||
($nextCharCode >= 65 /*'A'*/ &&
$nextCharCode <= 70 /*'F'*/ ) ) {
$nextHexCode .= $inStr[$count];
}
if (strlen($nextHexCode) == 2) {
$outStr .= chr(intval($nextHexCode, 16));
$nextHexCode = '';
}
}
if ($nextHexCode != '') {
// We have odd number of digits.
// Final digit is assumed to be '0'
$outStr .= chr(base_convert($nextHexCode . '0', 16, 10));
}
return $outStr;
}
/**
* Return object as string
*
* @param Zend_Pdf_Factory $factory
* @return string
*/
public function toString($factory = null)
{
return '<' . self::escape((string)$this->value) . '>';
}
}

View File

@ -0,0 +1,441 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_ElementFactory_Interface */
require_once 'Zend/Pdf/ElementFactory/Interface.php';
/** Zend_Pdf_ElementFactory_Proxy */
require_once 'Zend/Pdf/ElementFactory/Proxy.php';
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_Element_Array */
require_once 'Zend/Pdf/Element/Array.php';
/** Zend_Pdf_Element_String_Binary */
require_once 'Zend/Pdf/Element/String/Binary.php';
/** Zend_Pdf_Element_Boolean */
require_once 'Zend/Pdf/Element/Boolean.php';
/** Zend_Pdf_Element_Dictionary */
require_once 'Zend/Pdf/Element/Dictionary.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Reference */
require_once 'Zend/Pdf/Element/Reference.php';
/** Zend_Pdf_Element_Object_Stream */
require_once 'Zend/Pdf/Element/Object/Stream.php';
/** Zend_Pdf_Element_String */
require_once 'Zend/Pdf/Element/String.php';
/** Zend_Pdf_Element_Null */
require_once 'Zend/Pdf/Element/Null.php';
/** Zend_Pdf_UpdateInfoContainer */
require_once 'Zend/Pdf/UpdateInfoContainer.php';
/**
* PDF element factory.
* Responsibility is to log PDF changes
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_ElementFactory implements Zend_Pdf_ElementFactory_Interface
{
/**
* List of the modified objects.
* Also contains new and removed objects
*
* Array: ojbectNumber => Zend_Pdf_Element_Object
*
* @var array
*/
private $_modifiedObjects = array();
/**
* List of the removed objects
*
* Array: ojbectNumber => Zend_Pdf_Element_Object
*
* @var array
*/
private $_removedObjects = array();
/**
* List of registered objects.
* Used for resources clean up when factory is destroyed.
*
* Array of Zend_Pdf_Element objects
*
* @var array
*/
private $_registeredObjects = array();
/**
* PDF object counter.
* Actually it's an object number for new PDF object
*
* @var integer
*/
private $_objectCount;
/**
* List of the attached object factories.
* Array of Zend_Pdf_ElementFactory_Interface objects
*
* @var array
*/
private $_attachedFactories = array();
/**
* Factory internal id
*
* @var integer
*/
private $_factoryId;
/**
* Identity, used for factory id generation
*
* @var integer
*/
private static $_identity = 0;
/**
* Internal cache to save calculated shifts
*
* @var array
*/
private $_shiftCalculationCache = array();
/**
* Object constructor
*
* @param integer $objCount
*/
public function __construct($objCount)
{
$this->_objectCount = (int)$objCount;
$this->_factoryId = self::$_identity++;
}
/**
* Factory generator
*
* @param integer $objCount
* @return Zend_Pdf_ElementFactory_Interface
*/
static public function createFactory($objCount)
{
return new Zend_Pdf_ElementFactory_Proxy(new Zend_Pdf_ElementFactory($objCount));
}
/**
* Close factory and clean-up resources
*
* @internal
*/
public function close()
{
$this->_modifiedObjects = null;
$this->_removedObjects = null;
$this->_attachedFactories = null;
foreach ($this->_registeredObjects as $obj) {
$obj->cleanUp();
}
$this->_registeredObjects = null;
}
/**
* Get source factory object
*
* @return Zend_Pdf_ElementFactory
*/
public function resolve()
{
return $this;
}
/**
* Get factory ID
*
* @return integer
*/
public function getId()
{
return $this->_factoryId;
}
/**
* Set object counter
*
* @param integer $objCount
*/
public function setObjectCount($objCount)
{
$this->_objectCount = (int)$objCount;
}
/**
* Get object counter
*
* @return integer
*/
public function getObjectCount()
{
$count = $this->_objectCount;
foreach ($this->_attachedFactories as $attached) {
$count += $attached->getObjectCount() - 1; // -1 as "0" object is a special case and shared between factories
}
return $count;
}
/**
* Attach factory to the current;
*
* @param Zend_Pdf_ElementFactory_Interface $factory
*/
public function attach(Zend_Pdf_ElementFactory_Interface $factory)
{
if ( $factory === $this || isset($this->_attachedFactories[$factory->getId()])) {
/**
* Don't attach factory twice.
* We do not check recusively because of nature of attach operation
* (Pages are always attached to the Documents, Fonts are always attached
* to the pages even if pages already use Document level object factory and so on)
*/
return;
}
$this->_attachedFactories[$factory->getId()] = $factory;
}
/**
* Calculate object enumeration shift.
*
* @internal
* @param Zend_Pdf_ElementFactory_Interface $factory
* @return integer
*/
public function calculateShift(Zend_Pdf_ElementFactory_Interface $factory)
{
if ($factory === $this) {
return 0;
}
if (isset($this->_shiftCalculationCache[$factory->_factoryId])) {
return $this->_shiftCalculationCache[$factory->_factoryId];
}
$shift = $this->_objectCount - 1;
foreach ($this->_attachedFactories as $subFactory) {
$subFactoryShift = $subFactory->calculateShift($factory);
if ($subFactoryShift != -1) {
// context found
$this->_shiftCalculationCache[$factory->_factoryId] = $shift + $subFactoryShift;
return $shift + $subFactoryShift;
} else {
$shift += $subFactory->getObjectCount()-1;
}
}
$this->_shiftCalculationCache[$factory->_factoryId] = -1;
return -1;
}
/**
* Retrive object enumeration shift.
*
* @param Zend_Pdf_ElementFactory_Interface $factory
* @return integer
* @throws Zend_Pdf_Exception
*/
public function getEnumerationShift(Zend_Pdf_ElementFactory_Interface $factory)
{
if (($shift = $this->calculateShift($factory)) == -1) {
throw new Zend_Pdf_Exception('Wrong object context');
}
return $shift;
}
/**
* Mark object as modified in context of current factory.
*
* @param Zend_Pdf_Element_Object $obj
* @throws Zend_Pdf_Exception
*/
public function markAsModified(Zend_Pdf_Element_Object $obj)
{
if ($obj->getFactory() !== $this) {
throw new Zend_Pdf_Exception('Object is not generated by this factory');
}
$this->_modifiedObjects[$obj->getObjNum()] = $obj;
}
/**
* Remove object in context of current factory.
*
* @param Zend_Pdf_Element_Object $obj
* @throws Zend_Pdf_Exception
*/
public function remove(Zend_Pdf_Element_Object $obj)
{
if (!$obj->compareFactory($this)) {
throw new Zend_Pdf_Exception('Object is not generated by this factory');
}
$this->_modifiedObjects[$obj->getObjNum()] = $obj;
$this-> _removedObjects[$obj->getObjNum()] = $obj;
}
/**
* Generate new Zend_Pdf_Element_Object
*
* @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
*
* @param Zend_Pdf_Element $objectValue
* @return Zend_Pdf_Element_Object
*/
public function newObject(Zend_Pdf_Element $objectValue)
{
$obj = new Zend_Pdf_Element_Object($objectValue, $this->_objectCount++, 0, $this);
$this->_modifiedObjects[$obj->getObjNum()] = $obj;
return $obj;
}
/**
* Generate new Zend_Pdf_Element_Object_Stream
*
* @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
*
* @param mixed $objectValue
* @return Zend_Pdf_Element_Object_Stream
*/
public function newStreamObject($streamValue)
{
$obj = new Zend_Pdf_Element_Object_Stream($streamValue, $this->_objectCount++, 0, $this);
$this->_modifiedObjects[$obj->getObjNum()] = $obj;
return $obj;
}
/**
* Enumerate modified objects.
* Returns array of Zend_Pdf_UpdateInfoContainer
*
* @param Zend_Pdf_ElementFactory_Interface $rootFactory
* @return array
*/
public function listModifiedObjects($rootFactory = null)
{
if ($rootFactory == null) {
$rootFactory = $this;
$shift = 0;
} else {
$shift = $rootFactory->getEnumerationShift($this);
}
ksort($this->_modifiedObjects);
$result = array();
foreach ($this->_modifiedObjects as $objNum => $obj) {
if (key_exists($objNum, $this->_removedObjects)) {
$result[$objNum+$shift] = new Zend_Pdf_UpdateInfoContainer($objNum + $shift,
$obj->getGenNum()+1,
true);
} else {
$result[$objNum+$shift] = new Zend_Pdf_UpdateInfoContainer($objNum + $shift,
$obj->getGenNum(),
false,
$obj->dump($rootFactory));
}
}
foreach ($this->_attachedFactories as $factory) {
$result += $factory->listModifiedObjects($rootFactory);
}
return $result;
}
/**
* Register object in the factory
*
* It's used to clear "parent object" referencies when factory is closed and clean up resources
*
* @param Zend_Pdf_Element_Object $obj
*/
public function registerObject($obj)
{
$this->_registeredObjects[] = $obj;
}
/**
* Check if PDF file was modified
*
* @return boolean
*/
public function isModified()
{
if (count($this->_modifiedObjects) != 0) {
return true;
}
foreach ($this->_attachedFactories as $subFactory) {
if ($subFactory->isModified()) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,142 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* PDF element factory interface.
* Responsibility is to log PDF changes
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Pdf_ElementFactory_Interface
{
/**
* Close factory and clean-up resources
*
* @internal
*/
public function close();
/**
* Get source factory object
*
* @return Zend_Pdf_ElementFactory
*/
public function resolve();
/**
* Get factory ID
*
* @return integer
*/
public function getId();
/**
* Set object counter
*
* @param integer $objCount
*/
public function setObjectCount($objCount);
/**
* Get object counter
*
* @return integer
*/
public function getObjectCount();
/**
* Attach factory to the current;
*
* @param Zend_Pdf_ElementFactory_Interface $factory
*/
public function attach(Zend_Pdf_ElementFactory_Interface $factory);
/**
* Calculate object enumeration shift.
*
* @internal
* @param Zend_Pdf_ElementFactory_Interface $factory
* @return integer
*/
public function calculateShift(Zend_Pdf_ElementFactory_Interface $factory);
/**
* Retrive object enumeration shift.
*
* @param Zend_Pdf_ElementFactory_Interface $factory
* @return integer
* @throws Zend_Pdf_Exception
*/
public function getEnumerationShift(Zend_Pdf_ElementFactory_Interface $factory);
/**
* Mark object as modified in context of current factory.
*
* @param Zend_Pdf_Element_Object $obj
* @throws Zend_Pdf_Exception
*/
public function markAsModified(Zend_Pdf_Element_Object $obj);
/**
* Remove object in context of current factory.
*
* @param Zend_Pdf_Element_Object $obj
* @throws Zend_Pdf_Exception
*/
public function remove(Zend_Pdf_Element_Object $obj);
/**
* Generate new Zend_Pdf_Element_Object
*
* @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
*
* @param Zend_Pdf_Element $objectValue
* @return Zend_Pdf_Element_Object
*/
public function newObject(Zend_Pdf_Element $objectValue);
/**
* Generate new Zend_Pdf_Element_Object_Stream
*
* @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
*
* @param mixed $objectValue
* @return Zend_Pdf_Element_Object_Stream
*/
public function newStreamObject($streamValue);
/**
* Enumerate modified objects.
* Returns array of Zend_Pdf_UpdateInfoContainer
*
* @param Zend_Pdf_ElementFactory $rootFactory
* @return array
*/
public function listModifiedObjects($rootFactory = null);
/**
* Check if PDF file was modified
*
* @return boolean
*/
public function isModified();
}

View File

@ -0,0 +1,212 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_ElementFactory_Interface */
require_once 'Zend/Pdf/ElementFactory/Interface.php';
/**
* PDF element factory interface.
* Responsibility is to log PDF changes
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_ElementFactory_Proxy implements Zend_Pdf_ElementFactory_Interface
{
/**
* Factory object
*
* @var Zend_Pdf_ElementFactory_Interface
*/
private $_factory;
/**
* Object constructor
*
* @param Zend_Pdf_ElementFactory_Interface $factory
*/
public function __construct(Zend_Pdf_ElementFactory_Interface $factory)
{
$this->_factory = $factory;
}
public function __destruct()
{
$this->_factory->close();
$this->_factory = null;
}
/**
* Close factory and clean-up resources
*
* @internal
*/
public function close()
{
// Do nothing
}
/**
* Get source factory object
*
* @return Zend_Pdf_ElementFactory
*/
public function resolve()
{
return $this->_factory->resolve();
}
/**
* Get factory ID
*
* @return integer
*/
public function getId()
{
return $this->_factory->getId();
}
/**
* Set object counter
*
* @param integer $objCount
*/
public function setObjectCount($objCount)
{
$this->_factory->setObjectCount($objCount);
}
/**
* Get object counter
*
* @return integer
*/
public function getObjectCount()
{
return $this->_factory->getObjectCount();
}
/**
* Attach factory to the current;
*
* @param Zend_Pdf_ElementFactory_Interface $factory
*/
public function attach(Zend_Pdf_ElementFactory_Interface $factory)
{
$this->_factory->attach($factory);
}
/**
* Calculate object enumeration shift.
*
* @internal
* @param Zend_Pdf_ElementFactory_Interface $factory
* @return integer
*/
public function calculateShift(Zend_Pdf_ElementFactory_Interface $factory)
{
return $this->_factory->calculateShift($factory);
}
/**
* Retrive object enumeration shift.
*
* @param Zend_Pdf_ElementFactory_Interface $factory
* @return integer
* @throws Zend_Pdf_Exception
*/
public function getEnumerationShift(Zend_Pdf_ElementFactory_Interface $factory)
{
return $this->_factory->getEnumerationShift($factory);
}
/**
* Mark object as modified in context of current factory.
*
* @param Zend_Pdf_Element_Object $obj
* @throws Zend_Pdf_Exception
*/
public function markAsModified(Zend_Pdf_Element_Object $obj)
{
$this->_factory->markAsModified($obj);
}
/**
* Remove object in context of current factory.
*
* @param Zend_Pdf_Element_Object $obj
* @throws Zend_Pdf_Exception
*/
public function remove(Zend_Pdf_Element_Object $obj)
{
$this->_factory->remove($obj);
}
/**
* Generate new Zend_Pdf_Element_Object
*
* @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
*
* @param Zend_Pdf_Element $objectValue
* @return Zend_Pdf_Element_Object
*/
public function newObject(Zend_Pdf_Element $objectValue)
{
return $this->_factory->newObject($objectValue);
}
/**
* Generate new Zend_Pdf_Element_Object_Stream
*
* @todo Reusage of the freed object. It's not a support of new feature, but only improvement.
*
* @param mixed $objectValue
* @return Zend_Pdf_Element_Object_Stream
*/
public function newStreamObject($streamValue)
{
return $this->_factory->newStreamObject($streamValue);
}
/**
* Enumerate modified objects.
* Returns array of Zend_Pdf_UpdateInfoContainer
*
* @param Zend_Pdf_ElementFactory $rootFactory
* @return array
*/
public function listModifiedObjects($rootFactory = null)
{
return $this->_factory->listModifiedObjects($rootFactory);
}
/**
* Check if PDF file was modified
*
* @return boolean
*/
public function isModified()
{
return $this->_factory->isModified();
}
}

341
libs/Zend/Pdf/Exception.php Normal file
View File

@ -0,0 +1,341 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Core
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Exception */
require_once 'Zend/Exception.php';
/**
* Exception class for Zend_Pdf.
*
* If you expect a certain type of exception to be caught and handled by the
* caller, create a constant for it here and include it in the object being
* thrown. Example:
*
* throw new Zend_Pdf_Exception('foo() is not yet implemented',
* Zend_Pdf_Exception::NOT_IMPLEMENTED);
*
* This allows the caller to determine the specific type of exception that was
* thrown without resorting to parsing the descriptive text.
*
* IMPORTANT: Do not rely on numeric values of the constants! They are grouped
* sequentially below for organizational purposes only. The numbers may come to
* mean something in the future, but they are subject to renumbering at any
* time. ALWAYS use the symbolic constant names, which are guaranteed never to
* change, in logical checks! You have been warned.
*
* @package Zend_Pdf
* @subpackage Core
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Exception extends Zend_Exception
{
/**** Class Constants ****/
/* Generic Exceptions */
/**
* The feature or option is planned but has not yet been implemented. It
* should be available in a future revision of the framework.
*/
const NOT_IMPLEMENTED = 0x0001;
/**
* The feature or option has been deprecated and will be removed in a future
* revision of the framework. The descriptive text accompanying this
* exception should explain how to use the replacement features or options.
*/
const DEPRECATED = 0x0002;
/**
* Not enough paramaters were supplied to the method.
*/
const TOO_FEW_PARAMETERS = 0x0003;
/**
* A parameter was of the wrong data type.
*/
const BAD_PARAMETER_TYPE = 0x0004;
/**
* A parameter contained an unusable value.
*/
const BAD_PARAMETER_VALUE = 0x0005;
/**
* A parameter value was not within the expected range.
*/
const PARAMETER_VALUE_OUT_OF_RANGE = 0x0006;
/**
* The method that has multiple signatures could not understand the
* number and/or types of parameters.
*/
const BAD_METHOD_SIGNATURE = 0x0007;
/**
* An array or string index was out of range.
*/
const INDEX_OUT_OF_RANGE = 0x0008;
/* Filesystem I/O */
/**
* The file path was unusable or invalid.
*/
const BAD_FILE_PATH = 0x0101;
/**
* The file is not readable by the current user.
*/
const NOT_READABLE = 0x0102;
/**
* The file is not writeable by the current user.
*/
const NOT_WRITEABLE = 0x0103;
/**
* The file resource has been closed unexpectedly.
*/
const FILE_NOT_OPEN = 0x0104;
/**
* An error was encountered while attempting to open the file.
*/
const CANT_OPEN_FILE = 0x0105;
/**
* An error was encountered while attempting to obtain the current file
* position.
*/
const CANT_GET_FILE_POSITION = 0x0106;
/**
* An error was encountered while attempting to set a new file position.
*/
const CANT_SET_FILE_POSITION = 0x0107;
/**
* An attempt was made to move the current file position before the start
* of the file.
*/
const MOVE_BEFORE_START_OF_FILE = 0x0108;
/**
* An attempt was made to move the current file position beyond the end of
* the file.
*/
const MOVE_BEYOND_END_OF_FILE = 0x0109;
/**
* An error was encountered while attempting to obtain the file size.
*/
const CANT_GET_FILE_SIZE = 0x010a;
/**
* An error was encountered while attempting to read data from the file.
*/
const ERROR_DURING_READ = 0x010b;
/**
* An error was encountered while attempting to write data to the file.
*/
const ERROR_DURING_WRITE = 0x010c;
/**
* An incompatible page size was specified for a buffered read operation.
*/
const INVALID_PAGE_SIZE = 0x010d;
/**
* There is insufficient data to fulfill the read request.
*/
const INSUFFICIENT_DATA = 0x010e;
/* Zend_Pdf_FileParser */
/**
* The file parser data source object was invalid or improperly initialized.
*/
const BAD_DATA_SOURCE = 0x0201;
/**
* An unknown byte order was specified.
*/
const INVALID_BYTE_ORDER = 0x0202;
/**
* An invalid integer size was specified.
*/
const INVALID_INTEGER_SIZE = 0x0203;
/**
* An invalid fixed-point number size was specified.
*/
const BAD_FIXED_POINT_SIZE = 0x0204;
/**
* The string cannot be read.
*/
const CANT_READ_STRING = 0x0205;
/**
* This file type must be parsed in a specific order and a parsing method
* was called out-of-turn.
*/
const PARSED_OUT_OF_ORDER = 0x0206;
/* Zend_Pdf_FileParser_Font and Subclasses */
/**
* The font file type is incorrect.
*/
const WRONG_FONT_TYPE = 0x0301;
/**
* The number of tables contained in the font is outside the expected range.
*/
const BAD_TABLE_COUNT = 0x0302;
/**
* A required table was not present in the font.
*/
const REQUIRED_TABLE_NOT_FOUND = 0x0303;
/**
* The parser does not understand this version of this table in the font.
*/
const DONT_UNDERSTAND_TABLE_VERSION = 0x0303;
/**
* The magic number in the font file is incorrect.
*/
const BAD_MAGIC_NUMBER = 0x0304;
/**
* Could not locate a usable character map for this font.
*/
const CANT_FIND_GOOD_CMAP = 0x0305;
/* Zend_Pdf_Cmap and Subclasses */
/**
* The character map type is currently unsupported.
*/
const CMAP_TYPE_UNSUPPORTED = 0x0401;
/**
* The type of the character map is not understood.
*/
const CMAP_UNKNOWN_TYPE = 0x0402;
/**
* The character map table data is too small.
*/
const CMAP_TABLE_DATA_TOO_SMALL = 0x0403;
/**
* The character map table data is for a different type of table.
*/
const CMAP_WRONG_TABLE_TYPE = 0x0404;
/**
* The character map table data contains in incorrect length.
*/
const CMAP_WRONG_TABLE_LENGTH = 0x0405;
/**
* This character map table is language-dependent. Character maps must be
* language-independent.
*/
const CMAP_NOT_LANGUAGE_INDEPENDENT = 0x0406;
/**
* The final byte offset when reading the character map table data does not
* match the reported length of the table.
*/
const CMAP_FINAL_OFFSET_NOT_LENGTH = 0x0407;
/**
* The character map subtable entry count does not match the expected value.
*/
const CMAP_WRONG_ENTRY_COUNT = 0x0408;
/* Zend_Pdf_Resource_Font and Subclasses */
/**
* The specified glyph number is out of range for this font.
*/
const GLYPH_OUT_OF_RANGE = 0x0501;
/**
* This font program has copyright bits set which prevent it from being
* embedded in the PDF file. You must specify the no-embed option to use
* this font.
*/
const FONT_CANT_BE_EMBEDDED = 0x0502;
/* Zend_Pdf_Font */
/**
* The font name did not match any previously instantiated font and is not
* one of the standard 14 PDF fonts.
*/
const BAD_FONT_NAME = 0x0601;
/**
* The factory method could not determine the type of the font file.
*/
const CANT_DETERMINE_FONT_TYPE = 0x0602;
/* Text Layout System */
/**
* The specified attribute value for the text object cannot be used.
*/
const BAD_ATTRIBUTE_VALUE = 0x0701;
/* Zend_Pdf_Image and Subclasses */
const CANT_DETERMINE_IMAGE_TYPE = 0x0801;
const WRONG_IMAGE_TYPE = 0x0802;
const UNSUPPORTED_IMAGE_ENCODING_OPTIONS = 0x0803;
const IMAGE_FILE_CORRUPT = 0x0804;
}

View File

@ -0,0 +1,480 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/**
* 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 {@link Zend_Pdf_FileParserDataSource} object.
* This allows the same parser code to work with many different data sources:
* in-memory objects, filesystem files, etc.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_FileParser
{
/**** Class Constants ****/
/**
* Little-endian byte order (0x04 0x03 0x02 0x01).
*/
const BYTE_ORDER_LITTLE_ENDIAN = 0;
/**
* Big-endian byte order (0x01 0x02 0x03 0x04).
*/
const BYTE_ORDER_BIG_ENDIAN = 1;
/**** Instance Variables ****/
/**
* Flag indicating that the file has passed a cursory validation check.
* @var boolean
*/
protected $_isScreened = false;
/**
* Flag indicating that the file has been sucessfully parsed.
* @var boolean
*/
protected $_isParsed = false;
/**
* Object representing the data source to be parsed.
* @var Zend_Pdf_FileParserDataSource
*/
protected $_dataSource = null;
/**** Public Interface ****/
/* Abstract Methods */
/**
* 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.
*
* @throws Zend_Pdf_Exception
*/
abstract public function screen();
/**
* Reads and parses the complete binary file.
*
* Must set $this->_isParsed to true if successful.
*
* @throws Zend_Pdf_Exception
*/
abstract public function parse();
/* Object Lifecycle */
/**
* Object constructor.
*
* Verifies that the data source has been properly initialized.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParserDataSource $dataSource)
{
if ($dataSource->getSize() == 0) {
throw new Zend_Pdf_Exception('The data source has not been properly initialized',
Zend_Pdf_Exception::BAD_DATA_SOURCE);
}
$this->_dataSource = $dataSource;
}
/**
* Object destructor.
*
* Discards the data source object.
*/
public function __destruct()
{
$this->_dataSource = null;
}
/* Accessors */
/**
* Returns true if the file has passed a cursory validation check.
*
* @return boolean
*/
public function isScreened()
{
return $this->_isScreened;
}
/**
* Returns true if the file has been successfully parsed.
*
* @return boolean
*/
public function isParsed()
{
return $this->_isParsed;
}
/**
* Returns the data source object representing the file being parsed.
*
* @return Zend_Pdf_FileParserDataSource
*/
public function getDataSource()
{
return $this->_dataSource;
}
/* Primitive Methods */
/**
* Convenience wrapper for the data source object's moveToOffset() method.
*
* @param integer $offset Destination byte offset.
* @throws Zend_Pdf_Exception
*/
public function moveToOffset($offset)
{
$this->_dataSource->moveToOffset($offset);
}
public function getOffset() {
return $this->_dataSource->getOffset();
}
public function getSize() {
return $this->_dataSource->getSize();
}
/**
* Convenience wrapper for the data source object's readBytes() method.
*
* @param integer $byteCount Number of bytes to read.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readBytes($byteCount)
{
return $this->_dataSource->readBytes($byteCount);
}
/**
* Convenience wrapper for the data source object's skipBytes() method.
*
* @param integer $byteCount Number of bytes to skip.
* @throws Zend_Pdf_Exception
*/
public function skipBytes($byteCount)
{
$this->_dataSource->skipBytes($byteCount);
}
/* Parser Methods */
/**
* 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.
*
* @param integer $size Size of integer in bytes: 1-4
* @param integer $byteOrder (optional) Big- or little-endian byte order.
* Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}.
* If omitted, uses big-endian.
* @return integer
* @throws Zend_Pdf_Exception
*/
public function readInt($size, $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN)
{
if (($size < 1) || ($size > 4)) {
throw new Zend_Pdf_Exception("Invalid signed integer size: $size",
Zend_Pdf_Exception::INVALID_INTEGER_SIZE);
}
$bytes = $this->_dataSource->readBytes($size);
/* unpack() will not work for this method because it always works in
* the host byte order for signed integers. It also does not allow for
* variable integer sizes.
*/
if ($byteOrder == Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) {
$number = ord($bytes[0]);
if (($number & 0x80) == 0x80) {
/* This number is negative. Extract the positive equivalent.
*/
$number = (~ $number) & 0xff;
for ($i = 1; $i < $size; $i++) {
$number = ($number << 8) | ((~ ord($bytes[$i])) & 0xff);
}
/* Now turn this back into a negative number by taking the
* two's complement (we didn't add one above so won't
* subtract it below). This works reliably on both 32- and
* 64-bit systems.
*/
$number = ~$number;
} else {
for ($i = 1; $i < $size; $i++) {
$number = ($number << 8) | ord($bytes[$i]);
}
}
} else if ($byteOrder == Zend_Pdf_FileParser::BYTE_ORDER_LITTLE_ENDIAN) {
$number = ord($bytes[$size - 1]);
if (($number & 0x80) == 0x80) {
/* Negative number. See discussion above.
*/
$number = 0;
for ($i = --$size; $i >= 0; $i--) {
$number |= ((~ ord($bytes[$i])) & 0xff) << ($i * 8);
}
$number = ~$number;
} else {
$number = 0;
for ($i = --$size; $i >= 0; $i--) {
$number |= ord($bytes[$i]) << ($i * 8);
}
}
} else {
throw new Zend_Pdf_Exception("Invalid byte order: $byteOrder",
Zend_Pdf_Exception::INVALID_BYTE_ORDER);
}
return $number;
}
/**
* 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!
*
* @param integer $size Size of integer in bytes: 1-4
* @param integer $byteOrder (optional) Big- or little-endian byte order.
* Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}.
* If omitted, uses big-endian.
* @return integer
* @throws Zend_Pdf_Exception
*/
public function readUInt($size, $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN)
{
if (($size < 1) || ($size > 4)) {
throw new Zend_Pdf_Exception("Invalid unsigned integer size: $size",
Zend_Pdf_Exception::INVALID_INTEGER_SIZE);
}
$bytes = $this->_dataSource->readBytes($size);
/* unpack() is a bit heavyweight for this simple conversion. Just
* work the bytes directly.
*/
if ($byteOrder == Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) {
$number = ord($bytes[0]);
for ($i = 1; $i < $size; $i++) {
$number = ($number << 8) | ord($bytes[$i]);
}
} else if ($byteOrder == Zend_Pdf_FileParser::BYTE_ORDER_LITTLE_ENDIAN) {
$number = 0;
for ($i = --$size; $i >= 0; $i--) {
$number |= ord($bytes[$i]) << ($i * 8);
}
} else {
throw new Zend_Pdf_Exception("Invalid byte order: $byteOrder",
Zend_Pdf_Exception::INVALID_BYTE_ORDER);
}
return $number;
}
/**
* Returns true if the specified bit is set in the integer bitfield.
*
* @param integer $bit Bit number to test (i.e. - 0-31)
* @param integer $bitField
* @return boolean
*/
public function isBitSet($bit, $bitField)
{
$bitMask = 1 << $bit;
$isSet = (($bitField & $bitMask) == $bitMask);
return $isSet;
}
/**
* 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.
*
* @param integer $mantissaBits Number of bits in the mantissa
* @param integer $fractionBits Number of bits in the fraction
* @param integer $byteOrder (optional) Big- or little-endian byte order.
* Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}.
* If omitted, uses big-endian.
* @return float
* @throws Zend_Pdf_Exception
*/
public function readFixed($mantissaBits, $fractionBits,
$byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN)
{
$bitsToRead = $mantissaBits + $fractionBits;
if (($bitsToRead % 8) !== 0) {
throw new Zend_Pdf_Exception('Fixed-point numbers are whole bytes',
Zend_Pdf_Exception::BAD_FIXED_POINT_SIZE);
}
$number = $this->readInt(($bitsToRead >> 3), $byteOrder) / (1 << $fractionBits);
return $number;
}
/**
* 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 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.
*
* @param integer $byteCount Number of bytes (characters * 2) to return.
* @param integer $byteOrder (optional) Big- or little-endian byte order.
* Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}.
* If omitted, uses big-endian.
* @param string $characterSet (optional) Desired resulting character set.
* You may use any character set supported by {@link iconv()}. If omitted,
* uses 'current locale'.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readStringUTF16($byteCount,
$byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN,
$characterSet = '')
{
if ($byteCount == 0) {
return '';
}
$bytes = $this->_dataSource->readBytes($byteCount);
if ($byteOrder == Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN) {
if ($characterSet == 'UTF-16BE') {
return $bytes;
}
return iconv('UTF-16BE', $characterSet, $bytes);
} else if ($byteOrder == Zend_Pdf_FileParser::BYTE_ORDER_LITTLE_ENDIAN) {
if ($characterSet == 'UTF-16LE') {
return $bytes;
}
return iconv('UTF-16LE', $characterSet, $bytes);
} else {
throw new Zend_Pdf_Exception("Invalid byte order: $byteOrder",
Zend_Pdf_Exception::INVALID_BYTE_ORDER);
}
}
/**
* 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.
*
* @param integer $byteCount Number of bytes (characters) to return.
* @param string $characterSet (optional) Desired resulting character set.
* You may use any character set supported by {@link iconv()}. If omitted,
* uses 'current locale'.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readStringMacRoman($byteCount, $characterSet = '')
{
if ($byteCount == 0) {
return '';
}
$bytes = $this->_dataSource->readBytes($byteCount);
if ($characterSet == 'MacRoman') {
return $bytes;
}
return iconv('MacRoman', $characterSet, $bytes);
}
/**
* 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.
*
* @param string $characterSet (optional) Desired resulting character set.
* You may use any character set supported by {@link iconv()}. If omitted,
* uses 'current locale'.
* @param integer $lengthBytes (optional) Number of bytes that make up the
* length. Default is 1.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readStringPascal($characterSet = '', $lengthBytes = 1)
{
$byteCount = $this->readUInt($lengthBytes);
if ($byteCount == 0) {
return '';
}
$bytes = $this->_dataSource->readBytes($byteCount);
if ($characterSet == 'ASCII') {
return $bytes;
}
return iconv('ASCII', $characterSet, $bytes);
}
}

View File

@ -0,0 +1,209 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParser */
require_once 'Zend/Pdf/FileParser.php';
/**
* Abstract helper class for {@link Zend_Pdf_Font} that parses font files.
*
* Defines the public interface for concrete subclasses which are responsible
* for parsing the raw binary data from the font file on disk. Also provides
* a debug logging interface and a couple of shared utility methods.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_FileParser_Font extends Zend_Pdf_FileParser
{
/**** Instance Variables ****/
/**
* Array of parsed font properties. Used with {@link __get()} and
* {@link __set()}.
* @var array
*/
private $_fontProperties = array();
/**
* Flag indicating whether or not debug logging is active.
* @var boolean
*/
private $_debug = false;
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor.
*
* Validates the data source and enables debug logging if so configured.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParserDataSource $dataSource)
{
parent::__construct($dataSource);
$this->fontType = Zend_Pdf_Font::TYPE_UNKNOWN;
}
/* Accessors */
/**
* Get handler
*
* @param string $property
* @return mixed
*/
public function __get($property)
{
if (isset($this->_fontProperties[$property])) {
return $this->_fontProperties[$property];
} else {
return null;
}
}
/* NOTE: The set handler is defined below in the internal methods group. */
/* Parser Methods */
/**
* Reads the Unicode UTF-16-encoded string from the binary file at the
* current offset location. Overridden to fix return character set at UTF-16BE.
*
* @todo Deal with to-dos in the parent method.
*
* @param integer $byteCount Number of bytes (characters * 2) to return.
* @param integer $byteOrder (optional) Big- or little-endian byte order.
* Use the BYTE_ORDER_ constants defined in {@link Zend_Pdf_FileParser}. If
* omitted, uses big-endian.
* @param string $characterSet (optional) --Ignored--
* @return string
* @throws Zend_Pdf_Exception
*/
public function readStringUTF16($byteCount,
$byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN,
$characterSet = '')
{
return parent::readStringUTF16($byteCount, $byteOrder, 'UTF-16BE');
}
/**
* Reads the Mac Roman-encoded string from the binary file at the current
* offset location. Overridden to fix return character set at UTF-16BE.
*
* @param integer $byteCount Number of bytes (characters) to return.
* @param string $characterSet (optional) --Ignored--
* @return string
* @throws Zend_Pdf_Exception
*/
public function readStringMacRoman($byteCount, $characterSet = '')
{
return parent::readStringMacRoman($byteCount, 'UTF-16BE');
}
/**
* Reads the Pascal string from the binary file at the current offset
* location. Overridden to fix return character set at UTF-16BE.
*
* @param string $characterSet (optional) --Ignored--
* @param integer $lengthBytes (optional) Number of bytes that make up the
* length. Default is 1.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readStringPascal($characterSet = '', $lengthBytes = 1)
{
return parent::readStringPascal('UTF-16BE');
}
/* Utility Methods */
/**
* Writes the entire font properties array to STDOUT. Used only for debugging.
*/
public function writeDebug()
{
print_r($this->_fontProperties);
}
/**** Internal Methods ****/
/* Internal Accessors */
/**
* Set handler
*
* NOTE: This method is protected. Other classes may freely interrogate
* the font properties, but only this and its subclasses may set them.
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value)
{
if (is_null($value)) {
unset($this->_fontProperties[$property]);
} else {
$this->_fontProperties[$property] = $value;
}
}
/* Internal Utility Methods */
/**
* If debug logging is enabled, writes the log message.
*
* The log message is a sprintf() style string and any number of arguments
* may accompany it as additional parameters.
*
* @param string $message
* @param mixed (optional, multiple) Additional arguments
*/
protected function _debugLog($message)
{
if (! $this->_debug) {
return;
}
if (func_num_args() > 1) {
$args = func_get_args();
$message = array_shift($args);
$message = vsprintf($message, $args);
}
Zend_Log::log($message, Zend_Log::LEVEL_DEBUG, 'ZF');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParser_Font_OpenType */
require_once 'Zend/Pdf/FileParser/Font/OpenType.php';
/**
* Parses an OpenType font file containing TrueType outlines.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_FileParser_Font_OpenType_TrueType extends Zend_Pdf_FileParser_Font_OpenType
{
/**** Public Interface ****/
/* Concrete Class Implementation */
/**
* Verifies that the font file actually contains TrueType outlines.
*
* @throws Zend_Pdf_Exception
*/
public function screen()
{
if ($this->_isScreened) {
return;
}
parent::screen();
switch ($this->_readScalerType()) {
case 0x00010000: // version 1.0 - Windows TrueType signature
break;
case 0x74727565: // 'true' - Macintosh TrueType signature
break;
default:
throw new Zend_Pdf_Exception('Not a TrueType font file',
Zend_Pdf_Exception::WRONG_FONT_TYPE);
}
$this->fontType = Zend_Pdf_Font::TYPE_TRUETYPE;
$this->_isScreened = true;
}
/**
* Reads and parses the TrueType font data from the file on disk.
*
* @throws Zend_Pdf_Exception
*/
public function parse()
{
if ($this->_isParsed) {
return;
}
parent::parse();
/* There is nothing additional to parse for TrueType fonts at this time.
*/
$this->_isParsed = true;
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParser */
require_once 'Zend/Pdf/FileParser.php';
/** Zend_Log */
require_once 'Zend/Log.php';
/**
* FileParser for Zend_Pdf_Image subclasses.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_FileParser_Image extends Zend_Pdf_FileParser
{
protected $imageType;
/**
* Object constructor.
*
* Validates the data source and enables debug logging if so configured.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParserDataSource $dataSource)
{
parent::__construct($dataSource);
$this->imageType = Zend_Pdf_Image::TYPE_UNKNOWN;
}
}

View File

@ -0,0 +1,324 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParser_Image */
require_once 'Zend/Pdf/FileParser/Image.php';
/**
* Abstract base class for Image file parsers.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_FileParser_Image_Png extends Zend_Pdf_FileParser_Image
{
protected $_isPNG;
protected $_width;
protected $_height;
protected $_bits;
protected $_color;
protected $_compression;
protected $_preFilter;
protected $_interlacing;
protected $_imageData;
protected $_paletteData;
protected $_transparencyData;
/**** Public Interface ****/
public function getWidth() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_width;
}
public function getHeight() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_width;
}
public function getBitDepth() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_bits;
}
public function getColorSpace() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_color;
}
public function getCompressionStrategy() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_compression;
}
public function getPaethFilter() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_preFilter;
}
public function getInterlacingMode() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_interlacing;
}
public function getRawImageData() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_imageData;
}
public function getRawPaletteData() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_paletteData;
}
public function getRawTransparencyData() {
if(!$this->_isParsed) {
$this->parse();
}
return $this->_transparencyData;
}
/* Semi-Concrete Class Implementation */
/**
* Verifies that the image file is in the expected format.
*
* @throws Zend_Pdf_Exception
*/
public function screen()
{
if ($this->_isScreened) {
return;
}
return $this->_checkSignature();
}
/**
* Reads and parses the image data from the file on disk.
*
* @throws Zend_Pdf_Exception
*/
public function parse()
{
if ($this->_isParsed) {
return;
}
/* Screen the font file first, if it hasn't been done yet.
*/
$this->screen();
$this->_parseIHDRChunk();
$this->_parseChunks();
}
protected function _parseSignature() {
$this->moveToOffset(1); //Skip the first byte (%)
if('PNG' != $this->readBytes(3)) {
$this->_isPNG = false;
} else {
$this->_isPNG = true;
}
}
protected function _checkSignature() {
if(!isset($this->_isPNG)) {
$this->_parseSignature();
}
return $this->_isPNG;
}
protected function _parseChunks() {
$this->moveToOffset(33); //Variable chunks start at the end of IHDR
//Start processing chunks. If there are no more bytes to read parsing is complete.
$size = $this->getSize();
while($size - $this->getOffset() >= 8) {
$chunkLength = $this->readUInt(4);
if($chunkLength < 0 || ($chunkLength + $this->getOffset() + 4) > $size) {
throw new Zend_Pdf_Exception("PNG Corrupt: Invalid Chunk Size In File.");
}
$chunkType = $this->readBytes(4);
$offset = $this->getOffset();
//If we know how to process the chunk, do it here, else ignore the chunk and move on to the next
switch($chunkType) {
case 'IDAT': // This chunk may appear more than once. It contains the actual image data.
$this->_parseIDATChunk($offset, $chunkLength);
break;
case 'PLTE': // This chunk contains the image palette.
$this->_parsePLTEChunk($offset, $chunkLength);
break;
case 'tRNS': // This chunk contains non-alpha channel transparency data
$this->_parseTRNSChunk($offset, $chunkLength);
break;
case 'IEND':
break 2; //End the loop too
//@TODO Implement the rest of the PNG chunks. (There are many not implemented here)
}
if($offset + $chunkLength + 4 < $size) {
$this->moveToOffset($offset + $chunkLength + 4); //Skip past the data finalizer. (Don't rely on the parse to leave the offsets correct)
}
}
if(empty($this->_imageData)) {
throw new Zend_Pdf_Exception ( "This PNG is corrupt. All png must contain IDAT chunks." );
}
}
protected function _parseIHDRChunk() {
$this->moveToOffset(12); //IHDR must always start at offset 12 and run for 17 bytes
if(!$this->readBytes(4) == 'IHDR') {
throw new Zend_Pdf_Exception( "This PNG is corrupt. The first chunk in a PNG file must be IHDR." );
}
$this->_width = $this->readUInt(4);
$this->_height = $this->readUInt(4);
$this->_bits = $this->readInt(1);
$this->_color = $this->readInt(1);
$this->_compression = $this->readInt(1);
$this->_preFilter = $this->readInt(1);
$this->_interlacing = $this->readInt(1);
if($this->_interlacing != Zend_Pdf_Image::PNG_INTERLACING_DISABLED) {
throw new Zend_Pdf_Exception( "Only non-interlaced images are currently supported." );
}
}
protected function _parseIDATChunk($chunkOffset, $chunkLength) {
$this->moveToOffset($chunkOffset);
if(!isset($this->_imageData)) {
$this->_imageData = $this->readBytes($chunkLength);
} else {
$this->_imageData .= $this->readBytes($chunkLength);
}
}
protected function _parsePLTEChunk($chunkOffset, $chunkLength) {
$this->moveToOffset($chunkOffset);
$this->_paletteData = $this->readBytes($chunkLength);
}
protected function _parseTRNSChunk($chunkOffset, $chunkLength) {
$this->moveToOffset($chunkOffset);
//Processing of tRNS data varies dependending on the color depth
switch($this->_color) {
case Zend_Pdf_Image::PNG_CHANNEL_GRAY:
$baseColor = $this->readInt(1);
$this->_transparencyData = array($baseColor, $baseColor);
break;
case Zend_Pdf_Image::PNG_CHANNEL_RGB:
//@TODO Fix this hack.
//This parser cheats and only uses the lsb's (and only works with < 16 bit depth images)
/*
From the standard:
For color type 2 (truecolor), the tRNS chunk contains a single RGB color value, stored in the format:
Red: 2 bytes, range 0 .. (2^bitdepth)-1
Green: 2 bytes, range 0 .. (2^bitdepth)-1
Blue: 2 bytes, range 0 .. (2^bitdepth)-1
(If the image bit depth is less than 16, the least significant bits are used and the others are 0.)
Pixels of the specified color value are to be treated as transparent (equivalent to alpha value 0);
all other pixels are to be treated as fully opaque (alpha value 2bitdepth-1).
*/
$red = $this->readInt(1);
$this->skipBytes(1);
$green = $this->readInt(1);
$this->skipBytes(1);
$blue = $this->readInt(1);
$this->_transparencyData = array($red, $red, $green, $green, $blue, $blue);
break;
case Zend_Pdf_Image::PNG_CHANNEL_INDEXED:
//@TODO Fix this hack.
//This parser cheats too. It only masks the first color in the palette.
/*
From the standard:
For color type 3 (indexed color), the tRNS chunk contains a series of one-byte alpha values, corresponding to entries in the PLTE chunk:
Alpha for palette index 0: 1 byte
Alpha for palette index 1: 1 byte
...etc...
Each entry indicates that pixels of the corresponding palette index must be treated as having the specified alpha value.
Alpha values have the same interpretation as in an 8-bit full alpha channel: 0 is fully transparent, 255 is fully opaque,
regardless of image bit depth. The tRNS chunk must not contain more alpha values than there are palette entries,
but tRNS can contain fewer values than there are palette entries. In this case, the alpha value for all remaining palette
entries is assumed to be 255. In the common case in which only palette index 0 need be made transparent, only a one-byte
tRNS chunk is needed.
*/
$tmpData = $this->readBytes($chunkLength);
if(($trnsIdx = strpos($tmpData, chr(0))) !== false) {
$this->_transparencyData = array($trnsIdx, $trnsIdx);
}
break;
case Zend_Pdf_Image::PNG_CHANNEL_GRAY_ALPHA:
//Fall through to the next case
case Zend_Pdf_Image::PING_CHANNEL_RGB_ALPHA:
throw new Zend_Pdf_Exception( "tRNS chunk illegal for Alpha Channel Images" );
break;
}
}
}

View File

@ -0,0 +1,205 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/**
* 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 {@link __construct()},
* {@link __destruct()}, {@link readBytes()}, and {@link readAllBytes()}.
* Subclasses should also override {@link moveToOffset()} and
* {@link __toString()} as appropriate.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_FileParserDataSource
{
/**** Instance Variables ****/
/**
* Total size in bytes of the data source.
* @var integer
*/
protected $_size = 0;
/**
* Byte offset of the current read position within the data source.
* @var integer
*/
protected $_offset = 0;
/**** Public Interface ****/
/* Abstract Methods */
/**
* Object constructor. Opens the data source for parsing.
*
* Must set $this->_size to the total size in bytes of the data source.
*
* Upon return the data source can be interrogated using the primitive
* methods described here.
*
* If the data source cannot be opened for any reason (such as insufficient
* permissions, missing file, etc.), will throw an appropriate exception.
*
* @throws Zend_Pdf_Exception
*/
abstract public function __construct();
/**
* Object destructor. Closes the data source.
*
* May also perform cleanup tasks such as deleting temporary files.
*/
abstract public function __destruct();
/**
* Returns the specified number of raw bytes from the data source at the
* byte offset of the current read position.
*
* 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.
*
* @param integer $byteCount Number of bytes to read.
* @return string
* @throws Zend_Pdf_Exception
*/
abstract public function readBytes($byteCount);
/**
* Returns the entire contents of the data source as a 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.
*
* @return string
*/
abstract public function readAllBytes();
/* Object Magic Methods */
/**
* Returns a description of the object for debugging purposes.
*
* Subclasses should override this method to provide a more specific
* description of the actual object being represented.
*
* @return string
*/
public function __toString()
{
return get_class($this);
}
/* Accessors */
/**
* Returns the byte offset of the current read position within the data
* source.
*
* @return integer
*/
public function getOffset()
{
return $this->_offset;
}
/**
* Returns the total size in bytes of the data source.
*
* @return integer
*/
public function getSize()
{
return $this->_size;
}
/* Primitive Methods */
/**
* Moves the current read position to the specified byte 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.
*
* @param integer $offset Destination byte offset.
* @throws Zend_Pdf_Exception
*/
public function moveToOffset($offset)
{
if ($this->_offset == $offset) {
return; // Not moving; do nothing.
}
if ($offset < 0) {
throw new Zend_Pdf_Exception('Attempt to move before start of data source',
Zend_Pdf_Exception::MOVE_BEFORE_START_OF_FILE);
}
if ($offset >= $this->_size) { // Offsets are zero-based.
throw new Zend_Pdf_Exception('Attempt to move beyond end of data source',
Zend_Pdf_Exception::MOVE_BEYOND_END_OF_FILE);
}
$this->_offset = $offset;
}
/**
* Shifts the current read position within the data source by the specified
* number of bytes.
*
* 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.
*
* @param integer $byteCount Number of bytes to skip.
* @throws Zend_Pdf_Exception
*/
public function skipBytes($byteCount)
{
$this->moveToOffset($this->_offset + $byteCount);
}
}

View File

@ -0,0 +1,188 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParserDataSource */
require_once 'Zend/Pdf/FileParserDataSource.php';
/**
* Concrete subclass of {@link Zend_Pdf_FileParserDataSource} that provides an
* interface to filesystem objects.
*
* Note that this class cannot be used for other sources that may be supported
* by {@link fopen()} (through URL wrappers). It may be used for local
* filesystem objects only.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_FileParserDataSource_File extends Zend_Pdf_FileParserDataSource
{
/**** Instance Variables ****/
/**
* Fully-qualified path to the file.
* @var string
*/
protected $_filePath = '';
/**
* File resource handle .
* @var resource
*/
protected $_fileResource = null;
/**** Public Interface ****/
/* Concrete Class Implementation */
/**
* Object constructor.
*
* Validates the path to the file, ensures that it is readable, then opens
* it for reading.
*
* Throws an exception if the file is missing or cannot be opened.
*
* @param string $filePath Fully-qualified path to the file.
* @throws Zend_Pdf_Exception
*/
public function __construct($filePath)
{
if (! (is_file($filePath) || is_link($filePath))) {
throw new Zend_Pdf_Exception("Invalid file path: $filePath",
Zend_Pdf_Exception::BAD_FILE_PATH);
}
if (! is_readable($filePath)) {
throw new Zend_Pdf_Exception("File is not readable: $filePath",
Zend_Pdf_Exception::NOT_READABLE);
}
if (($this->_size = @filesize($filePath)) === false) {
throw new Zend_Pdf_Exception("Error while obtaining file size: $filePath",
Zend_Pdf_Exception::CANT_GET_FILE_SIZE);
}
if (($this->_fileResource = @fopen($filePath, 'rb')) === false) {
throw new Zend_Pdf_Exception("Cannot open file for reading: $filePath",
Zend_Pdf_Exception::CANT_OPEN_FILE);
}
$this->_filePath = $filePath;
}
/**
* Object destructor.
*
* Closes the file if it had been successfully opened.
*/
public function __destruct()
{
if (is_resource($this->_fileResource)) {
@fclose($this->_fileResource);
}
}
/**
* Returns the specified number of raw bytes from the file at the byte
* offset of the current read position.
*
* Advances the read position by the number of bytes read.
*
* Throws an exception if an error was encountered while reading the file or
* if there is insufficient data to completely fulfill the request.
*
* @param integer $byteCount Number of bytes to read.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readBytes($byteCount)
{
$bytes = @fread($this->_fileResource, $byteCount);
if ($bytes === false) {
throw new Zend_Pdf_Exception('Unexpected error while reading file',
Zend_Pdf_Exception::ERROR_DURING_READ);
}
if (strlen($bytes) != $byteCount) {
throw new Zend_Pdf_Exception("Insufficient data to read $byteCount bytes",
Zend_Pdf_Exception::INSUFFICIENT_DATA);
}
$this->_offset += $byteCount;
return $bytes;
}
/**
* Returns the entire contents of the file as a string.
*
* Preserves the current file seek position.
*
* @return string
*/
public function readAllBytes()
{
return file_get_contents($this->_filePath);
}
/* Object Magic Methods */
/**
* Returns the full filesystem path of the file.
*
* @return string
*/
public function __toString()
{
return $this->_filePath;
}
/* Primitive Methods */
/**
* Seeks the file read position to the specified byte offset.
*
* Throws an exception if the file pointer cannot be moved or if it is
* moved beyond EOF (end of file).
*
* @param integer $offset Destination byte offset.
* @throws Zend_Pdf_Exception
*/
public function moveToOffset($offset)
{
if ($this->_offset == $offset) {
return; // Not moving; do nothing.
}
parent::moveToOffset($offset);
$result = @fseek($this->_fileResource, $offset, SEEK_SET);
if ($result !== 0) {
throw new Zend_Pdf_Exception('Error while setting new file position',
Zend_Pdf_Exception::CANT_SET_FILE_POSITION);
}
if (feof($this->_fileResource)) {
throw new Zend_Pdf_Exception('Moved beyond the end of the file',
Zend_Pdf_Exception::MOVE_BEYOND_END_OF_FILE);
}
}
}

View File

@ -0,0 +1,126 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParserDataSource */
require_once 'Zend/Pdf/FileParserDataSource.php';
/**
* Concrete subclass of {@link Zend_Pdf_FileParserDataSource} that provides an
* interface to binary strings.
*
* @package Zend_Pdf
* @subpackage FileParser
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_FileParserDataSource_String extends Zend_Pdf_FileParserDataSource
{
/**** Instance Variables ****/
/**
* The string to parse.
* @var string
*/
protected $_string = '';
/**** Public Interface ****/
/* Concrete Class Implementation */
/**
* Object constructor.
*
* Verifies that the string is not empty.
*
* @param string $string String to parse.
*/
public function __construct($string)
{
if (empty($string)) {
throw new Zend_Pdf_Exception('String is empty',
Zend_Pdf_Exception::PARAMETER_VALUE_OUT_OF_RANGE);
}
$this->_size = strlen($string);
$this->_string = $string;
}
/**
* Object destructor.
*/
public function __destruct()
{
$this->_string = '';
}
/**
* Returns the specified number of raw bytes from the string at the byte
* offset of the current read position.
*
* Advances the read position by the number of bytes read.
*
* Throws an exception if there is insufficient data to completely fulfill
* the request.
*
* @param integer $byteCount Number of bytes to read.
* @return string
* @throws Zend_Pdf_Exception
*/
public function readBytes($byteCount)
{
if (($this->_offset + $byteCount) > $this->_size) {
throw new Zend_Pdf_Exception("Insufficient data to read $byteCount bytes",
Zend_Pdf_Exception::INSUFFICIENT_DATA);
}
$bytes = substr($this->_string, $this->_offset, $byteCount);
$this->_offset += $byteCount;
return $bytes;
}
/**
* Returns the entire string.
*
* Preserves the current read position.
*
* @return string
*/
public function readAllBytes()
{
return $this->_string;
}
/* Object Magic Methods */
/**
* Returns a string containing the parsed string's length.
*
* @return string
*/
public function __toString()
{
return "String ($this->_size bytes)";
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Filter_Interface */
require_once 'Zend/Pdf/Filter/Interface.php';
/**
* ASCII85 stream filter
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Filter_Ascii85 implements Zend_Pdf_Filter_Interface
{
/**
* Encode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function encode($data, $params = null)
{
throw new Zend_Pdf_Exception('Not implemented yet');
}
/**
* Decode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function decode($data, $params = null)
{
throw new Zend_Pdf_Exception('Not implemented yet');
}
}

View File

@ -0,0 +1,132 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Filter_Interface */
require_once 'Zend/Pdf/Filter/Interface.php';
/**
* AsciiHex stream filter
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Filter_AsciiHex implements Zend_Pdf_Filter_Interface
{
/**
* Encode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function encode($data, $params = null)
{
return bin2hex($data) . '>';
}
/**
* Decode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function decode($data, $params = null)
{
$output = '';
$oddCode = true;
$commentMode = false;
for ($count = 0; $count < strlen($data) && $data[$count] != '>'; $count++) {
$charCode = ord($data[$count]);
if ($commentMode) {
if ($charCode == 0x0A || $charCode == 0x0D ) {
$commentMode = false;
}
continue;
}
switch ($charCode) {
//Skip white space
case 0x00: // null character
// fall through to next case
case 0x09: // Tab
// fall through to next case
case 0x0A: // Line feed
// fall through to next case
case 0x0C: // Form Feed
// fall through to next case
case 0x0D: // Carriage return
// fall through to next case
case 0x20: // Space
// Do nothing
break;
case 0x25: // '%'
// Switch to comment mode
$commentMode = true;
break;
default:
if ($charCode >= 0x30 /*'0'*/ && $charCode <= 0x39 /*'9'*/) {
$code = $charCode - 0x30;
} else if ($charCode >= 0x41 /*'A'*/ && $charCode <= 0x46 /*'F'*/) {
$code = $charCode - 0x37/*0x41 - 0x0A*/;
} else if ($charCode >= 0x61 /*'a'*/ && $charCode <= 0x66 /*'f'*/) {
$code = $charCode - 0x57/*0x61 - 0x0A*/;
} else {
throw new Zend_Pdf_Exception('Wrong character in a encoded stream');
}
if ($oddCode) {
// Odd pass. Store hex digit for next pass
// Scope of $hexCodeHigh variable is whole function
$hexCodeHigh = $code;
} else {
// Even pass.
// Add decoded character to the output
// ($hexCodeHigh is stored in previous pass)
$output .= chr($hexCodeHigh*16 + $code);
}
$oddCode = !$oddCode;
break;
}
}
/* Check that stream is terminated by End Of Data marker */
if ($data[$count] != '>') {
throw new Zend_Pdf_Exception('Wrong encoded stream End Of Data marker.');
}
/* Last '0' character is omitted */
if (!$oddCode) {
$output .= chr($hexCodeHigh*16);
}
return $output;
}
}

View File

@ -0,0 +1,380 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Filter_Interface */
require_once 'Zend/Pdf/Filter/Interface.php';
/**
* ASCII85 stream filter
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Filter_Compression implements Zend_Pdf_Filter_Interface
{
/**
* Paeth prediction function
*
* @param integer $a
* @param integer $b
* @param integer $c
* @return integer
*/
private static function _paeth($a, $b, $c)
{
// $a - left, $b - above, $c - upper left
$p = $a + $b - $c; // initial estimate
$pa = abs($p - $a); // distances to a, b, c
$pb = abs($p - $b);
$pc = abs($p - $c);
// return nearest of a,b,c,
// breaking ties in order a,b,c.
if ($pa <= $pb && $pa <= $pc) {
return $a;
} else if ($pb <= $pc) {
return $b;
} else {
return $c;
}
}
/**
* Get Predictor decode param value
*
* @param array $params
* @return integer
* @throws Zend_Pdf_Exception
*/
private static function _getPredictorValue(&$params)
{
if (isset($params['Predictor'])) {
$predictor = $params['Predictor'];
if ($predictor != 1 && $predictor != 2 &&
$predictor != 10 && $predictor != 11 && $predictor != 12 &&
$predictor != 13 && $predictor != 14 && $predictor != 15) {
throw new Zend_Pdf_Exception('Invalid value of \'Predictor\' decode param - ' . $predictor . '.' );
}
return $predictor;
} else {
return 1;
}
}
/**
* Get Colors decode param value
*
* @param array $params
* @return integer
* @throws Zend_Pdf_Exception
*/
private static function _getColorsValue(&$params)
{
if (isset($params['Colors'])) {
$colors = $params['Colors'];
if ($colors != 1 && $colors != 2 && $colors != 3 && $colors != 4) {
throw new Zend_Pdf_Exception('Invalid value of \'Color\' decode param - ' . $colors . '.' );
}
return $colors;
} else {
return 1;
}
}
/**
* Get BitsPerComponent decode param value
*
* @param array $params
* @return integer
* @throws Zend_Pdf_Exception
*/
private static function _getBitsPerComponentValue(&$params)
{
if (isset($params['BitsPerComponent'])) {
$bitsPerComponent = $params['BitsPerComponent'];
if ($bitsPerComponent != 1 && $bitsPerComponent != 2 &&
$bitsPerComponent != 4 && $bitsPerComponent != 8 &&
$bitsPerComponent != 16 ) {
throw new Zend_Pdf_Exception('Invalid value of \'BitsPerComponent\' decode param - ' . $bitsPerComponent . '.' );
}
return $bitsPerComponent;
} else {
return 8;
}
}
/**
* Get Columns decode param value
*
* @param array $params
* @return integer
*/
private static function _getColumnsValue(&$params)
{
if (isset($params['Columns'])) {
return $params['Columns'];
} else {
return 1;
}
}
/**
* Convert stream data according to the filter params set before encoding.
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
protected static function _applyEncodeParams($data, $params) {
$predictor = self::_getPredictorValue($params);
$colors = self::_getColorsValue($params);
$bitsPerComponent = self::_getBitsPerComponentValue($params);
$columns = self::_getColumnsValue($params);
/** None of prediction */
if ($predictor == 1) {
return $data;
}
/** TIFF Predictor 2 */
if ($predictor == 2) {
throw new Zend_Pdf_Exception('Not implemented yet' );
}
/** Optimal PNG prediction */
if ($predictor == 15) {
/** Use Paeth prediction as optimal */
$predictor = 14;
}
/** PNG prediction */
if ($predictor == 10 || /** None of prediction */
$predictor == 11 || /** Sub prediction */
$predictor == 12 || /** Up prediction */
$predictor == 13 || /** Average prediction */
$predictor == 14 /** Paeth prediction */
) {
$predictor -= 10;
if($bitsPerComponent == 16) {
throw new Zend_Pdf_Exception("PNG Prediction with bit depth greater than 8 not yet supported.");
}
$bitsPerSample = $bitsPerComponent*$colors;
$bytesPerSample = (int)(($bitsPerSample + 7)/8); // (int)ceil(...) emulation
$bytesPerRow = (int)(($bitsPerSample*$columns + 7)/8); // (int)ceil(...) emulation
$rows = strlen($data)/$bytesPerRow;
$output = '';
$offset = 0;
if (!is_integer($rows)) {
throw new Zend_Pdf_Exception('Wrong data length.');
}
switch ($predictor) {
case 0: // None of prediction
for ($count = 0; $count < $rows; $count++) {
$output .= chr($predictor);
$output .= substr($data, $offset, $bytesPerRow);
$offset += $bytesPerRow;
}
break;
case 1: // Sub prediction
for ($count = 0; $count < $rows; $count++) {
$output .= chr($predictor);
$lastSample = array_fill(0, $bytesPerSample, 0);
for ($count2 = 0; $count2 < $bytesPerRow; $count2++) {
$newByte = ord($data[$offset++]);
// Note. chr() automatically cuts input to 8 bit
$output .= chr($newByte - $lastSample[$count2 % $bytesPerSample]);
$lastSample[$count2 % $bytesPerSample] = $newByte;
}
}
break;
case 2: // Up prediction
$lastRow = array_fill(0, $bytesPerRow, 0);
for ($count = 0; $count < $rows; $count++) {
$output .= chr($predictor);
for ($count2 = 0; $count2 < $bytesPerRow; $count2++) {
$newByte = ord($data[$offset++]);
// Note. chr() automatically cuts input to 8 bit
$output .= chr($newByte - $lastRow[$count2]);
$lastRow[$count2] = $newByte;
}
}
break;
case 3: // Average prediction
$lastRow = array_fill(0, $bytesPerRow, 0);
for ($count = 0; $count < $rows; $count++) {
$output .= chr($predictor);
$lastSample = array_fill(0, $bytesPerSample, 0);
for ($count2 = 0; $count2 < $bytesPerRow; $count2++) {
$newByte = ord($data[$offset++]);
// Note. chr() automatically cuts input to 8 bit
$output .= chr($newByte - floor(( $lastSample[$count2 % $bytesPerSample] + $lastRow[$count2])/2));
$lastSample[$count2 % $bytesPerSample] = $lastRow[$count2] = $newByte;
}
}
break;
case 4: // Paeth prediction
$lastRow = array_fill(0, $bytesPerRow, 0);
$currentRow = array();
for ($count = 0; $count < $rows; $count++) {
$output .= chr($predictor);
$lastSample = array_fill(0, $bytesPerSample, 0);
for ($count2 = 0; $count2 < $bytesPerRow; $count2++) {
$newByte = ord($data[$offset++]);
// Note. chr() automatically cuts input to 8 bit
$output .= chr($newByte - self::_paeth( $lastSample[$count2 % $bytesPerSample],
$lastRow[$count2],
($count2 - $bytesPerSample < 0)?
0 : $lastRow[$count2 - $bytesPerSample] ));
$lastSample[$count2 % $bytesPerSample] = $currentRow[$count2] = $newByte;
}
$lastRow = $currentRow;
}
break;
}
return $output;
}
throw new Zend_Pdf_Exception('Unknown prediction algorithm - ' . $predictor . '.' );
}
/**
* Convert stream data according to the filter params set after decoding.
*
* @param string $data
* @param array $params
* @return string
*/
protected static function _applyDecodeParams($data, $params) {
$predictor = self::_getPredictorValue($params);
$colors = self::_getColorsValue($params);
$bitsPerComponent = self::_getBitsPerComponentValue($params);
$columns = self::_getColumnsValue($params);
/** None of prediction */
if ($predictor == 1) {
return $data;
}
/** TIFF Predictor 2 */
if ($predictor == 2) {
throw new Zend_Pdf_Exception('Not implemented yet' );
}
/**
* PNG prediction
* Prediction code is duplicated on each row.
* Thus all cases can be brought to one
*/
if ($predictor == 10 || /** None of prediction */
$predictor == 11 || /** Sub prediction */
$predictor == 12 || /** Up prediction */
$predictor == 13 || /** Average prediction */
$predictor == 14 || /** Paeth prediction */
$predictor == 15 /** Optimal prediction */) {
$bitsPerSample = $bitsPerComponent*$colors;
$bytesPerSample = ceil($bitsPerSample/8);
$bytesPerRow = ceil($bitsPerSample*$columns/8);
$rows = ceil(strlen($data)/($bytesPerRow + 1));
$output = '';
$offset = 0;
$lastRow = array_fill(0, $bytesPerRow, 0);
for ($count = 0; $count < $rows; $count++) {
$lastSample = array_fill(0, $bytesPerSample, 0);
switch (ord($data[$offset++])) {
case 0: // None of prediction
$output .= substr($data, $offset, $bytesPerRow);
for ($count2 = 0; $count2 < $bytesPerRow && $offset < strlen($data); $count2++) {
$lastSample[$count2 % $bytesPerSample] = $lastRow[$count2] = ord($data[$offset++]);
}
break;
case 1: // Sub prediction
for ($count2 = 0; $count2 < $bytesPerRow && $offset < strlen($data); $count2++) {
$decodedByte = (ord($data[$offset++]) + $lastSample[$count2 % $bytesPerSample]) & 0xFF;
$lastSample[$count2 % $bytesPerSample] = $lastRow[$count2] = $decodedByte;
$output .= chr($decodedByte);
}
break;
case 2: // Up prediction
for ($count2 = 0; $count2 < $bytesPerRow && $offset < strlen($data); $count2++) {
$decodedByte = (ord($data[$offset++]) + $lastRow[$count2]) & 0xFF;
$lastSample[$count2 % $bytesPerSample] = $lastRow[$count2] = $decodedByte;
$output .= chr($decodedByte);
}
break;
case 3: // Average prediction
for ($count2 = 0; $count2 < $bytesPerRow && $offset < strlen($data); $count2++) {
$decodedByte = (ord($data[$offset++]) +
floor(( $lastSample[$count2 % $bytesPerSample] + $lastRow[$count2])/2)
) & 0xFF;
$lastSample[$count2 % $bytesPerSample] = $lastRow[$count2] = $decodedByte;
$output .= chr($decodedByte);
}
break;
case 4: // Paeth prediction
$currentRow = array();
for ($count2 = 0; $count2 < $bytesPerRow && $offset < strlen($data); $count2++) {
$decodedByte = (ord($data[$offset++]) +
self::_paeth($lastSample[$count2 % $bytesPerSample],
$lastRow[$count2],
($count2 - $bytesPerSample < 0)?
0 : $lastRow[$count2 - $bytesPerSample])
) & 0xFF;
$lastSample[$count2 % $bytesPerSample] = $currentRow[$count2] = $decodedByte;
$output .= chr($decodedByte);
}
$lastRow = $currentRow;
break;
default:
throw new Zend_Pdf_Exception('Unknown prediction tag.');
}
}
return $output;
}
throw new Zend_Pdf_Exception('Unknown prediction algorithm - ' . $predictor . '.' );
}
}

View File

@ -0,0 +1,97 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Filter_Compression */
require_once 'Zend/Pdf/Filter/Compression.php';
/**
* Flate stream filter
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Filter_Compression_Flate extends Zend_Pdf_Filter_Compression
{
/**
* Encode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function encode($data, $params = null)
{
if ($params != null) {
$data = self::_applyEncodeParams($data, $params);
}
if (extension_loaded('zlib')) {
$trackErrors = ini_get( "track_errors");
ini_set('track_errors', '1');
if (($output = @gzcompress($data)) === false) {
ini_set('track_errors', $trackErrors);
throw new Zend_Pdf_Exception($php_errormsg);
}
ini_set('track_errors', $trackErrors);
} else {
throw new Zend_Pdf_Exception('Not implemented yet. You have to use zlib extension.');
}
return $output;
}
/**
* Decode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function decode($data, $params = null)
{
global $php_errormsg;
if (extension_loaded('zlib')) {
$trackErrors = ini_get( "track_errors");
ini_set('track_errors', '1');
if (($output = @gzuncompress($data)) === false) {
ini_set('track_errors', $trackErrors);
throw new Zend_Pdf_Exception($php_errormsg);
}
ini_set('track_errors', $trackErrors);
} else {
throw new Zend_Pdf_Exception('Not implemented yet');
}
if ($params !== null) {
return self::_applyDecodeParams($output, $params);
} else {
return $output;
}
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Filter_Compression */
require_once 'Zend/Pdf/Filter/Compression.php';
/**
* LZW stream filter
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Filter_Compression_Lzw extends Zend_Pdf_Filter_Compression
{
/**
* Get EarlyChange decode param value
*
* @param array $params
* @return integer
* @throws Zend_Pdf_Exception
*/
private static function _getEarlyChangeValue($params)
{
if (isset($params['EarlyChange'])) {
$earlyChange = $params['EarlyChange'];
if ($earlyChange != 0 && $earlyChange != 1) {
throw new Zend_Pdf_Exception('Invalid value of \'EarlyChange\' decode param - ' . $earlyChange . '.' );
}
return $earlyChange;
} else {
return 1;
}
}
/**
* Encode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function encode($data, $params = null)
{
if ($params != null) {
$data = self::_applyEncodeParams($data, $params);
}
throw new Zend_Pdf_Exception('Not implemented yet');
}
/**
* Decode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function decode($data, $params = null)
{
throw new Zend_Pdf_Exception('Not implemented yet');
if ($params !== null) {
return self::_applyDecodeParams($data, $params);
} else {
return $data;
}
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/**
* PDF stream filter
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Zend_Pdf_Filter_Interface
{
/**
* Encode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function encode($data, $params = null);
/**
* Decode data
*
* @param string $data
* @param array $params
* @return string
* @throws Zend_Pdf_Exception
*/
public static function decode($data, $params = null);
}

775
libs/Zend/Pdf/Font.php Normal file
View File

@ -0,0 +1,775 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParserDataSource */
require_once 'Zend/Pdf/FileParserDataSource.php';
/** Zend_Pdf_FileParserDataSource_File */
require_once 'Zend/Pdf/FileParserDataSource/File.php';
/** Zend_Pdf_FileParserDataSource_String */
require_once 'Zend/Pdf/FileParserDataSource/String.php';
/** Zend_Pdf_FileParser_Font_OpenType_TrueType */
require_once 'Zend/Pdf/FileParser/Font/OpenType/TrueType.php';
/** Zend_Pdf_Resource_Font_Simple_Parsed_TrueType */
require_once 'Zend/Pdf/Resource/Font/Simple/Parsed/TrueType.php';
/** Zend_Pdf_Resource_Font_Type0 */
require_once 'Zend/Pdf/Resource/Font/Type0.php';
/** Zend_Pdf_Resource_Font_CidFont_TrueType */
require_once 'Zend/Pdf/Resource/Font/CidFont/TrueType.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_Courier */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/Courier.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_CourierBold */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/CourierBold.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_CourierBoldOblique */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/CourierBoldOblique.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_CourierOblique */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/CourierOblique.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_Helvetica */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/Helvetica.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBold */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/HelveticaBold.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBoldOblique */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/HelveticaBoldOblique.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_HelveticaOblique */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/HelveticaOblique.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_Symbol */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/Symbol.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_TimesBold */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/TimesBold.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_TimesBoldItalic */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/TimesBoldItalic.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_TimesItalic */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/TimesItalic.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_TimesRoman */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/TimesRoman.php';
/** Zend_Pdf_Resource_Font_Simple_Standard_ZapfDingbats */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard/ZapfDingbats.php';
/** Zend_Pdf_Resource_Font_Extracted */
require_once 'Zend/Pdf/Resource/Font/Extracted.php';
/**
* Abstract factory class which vends {@link Zend_Pdf_Resource_Font} objects.
*
* Font objects themselves are normally instantiated through the factory methods
* {@link fontWithName()} or {@link fontWithPath()}.
*
* This class is also the home for font-related constants because the name of
* the true base class ({@link Zend_Pdf_Resource_Font}) is not intuitive for the
* end user.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Font
{
/**** Class Constants ****/
/* Font Types */
/**
* Unknown font type.
*/
const TYPE_UNKNOWN = 0;
/**
* One of the standard 14 PDF fonts.
*/
const TYPE_STANDARD = 1;
/**
* A PostScript Type 1 font.
*/
const TYPE_TYPE_1 = 2;
/**
* A TrueType font or an OpenType font containing TrueType outlines.
*/
const TYPE_TRUETYPE = 3;
/**
* Type 0 composite font.
*/
const TYPE_TYPE_0 = 4;
/**
* CID font containing a PostScript Type 1 font.
* These fonts are used only to construct Type 0 composite fonts and can't be used directly
*/
const TYPE_CIDFONT_TYPE_0 = 5;
/**
* CID font containing a TrueType font or an OpenType font containing TrueType outlines.
* These fonts are used only to construct Type 0 composite fonts and can't be used directly
*/
const TYPE_CIDFONT_TYPE_2 = 6;
/* Names of the Standard 14 PDF Fonts */
/**
* Name of the standard PDF font Courier.
*/
const FONT_COURIER = 'Courier';
/**
* Name of the bold style of the standard PDF font Courier.
*/
const FONT_COURIER_BOLD = 'Courier-Bold';
/**
* Name of the italic style of the standard PDF font Courier.
*/
const FONT_COURIER_OBLIQUE = 'Courier-Oblique';
/**
* Convenience constant for a common misspelling of
* {@link FONT_COURIER_OBLIQUE}.
*/
const FONT_COURIER_ITALIC = 'Courier-Oblique';
/**
* Name of the bold and italic style of the standard PDF font Courier.
*/
const FONT_COURIER_BOLD_OBLIQUE = 'Courier-BoldOblique';
/**
* Convenience constant for a common misspelling of
* {@link FONT_COURIER_BOLD_OBLIQUE}.
*/
const FONT_COURIER_BOLD_ITALIC = 'Courier-BoldOblique';
/**
* Name of the standard PDF font Helvetica.
*/
const FONT_HELVETICA = 'Helvetica';
/**
* Name of the bold style of the standard PDF font Helvetica.
*/
const FONT_HELVETICA_BOLD = 'Helvetica-Bold';
/**
* Name of the italic style of the standard PDF font Helvetica.
*/
const FONT_HELVETICA_OBLIQUE = 'Helvetica-Oblique';
/**
* Convenience constant for a common misspelling of
* {@link FONT_HELVETICA_OBLIQUE}.
*/
const FONT_HELVETICA_ITALIC = 'Helvetica-Oblique';
/**
* Name of the bold and italic style of the standard PDF font Helvetica.
*/
const FONT_HELVETICA_BOLD_OBLIQUE = 'Helvetica-BoldOblique';
/**
* Convenience constant for a common misspelling of
* {@link FONT_HELVETICA_BOLD_OBLIQUE}.
*/
const FONT_HELVETICA_BOLD_ITALIC = 'Helvetica-BoldOblique';
/**
* Name of the standard PDF font Symbol.
*/
const FONT_SYMBOL = 'Symbol';
/**
* Name of the standard PDF font Times.
*/
const FONT_TIMES_ROMAN = 'Times-Roman';
/**
* Convenience constant for a common misspelling of
* {@link FONT_TIMES_ROMAN}.
*/
const FONT_TIMES = 'Times-Roman';
/**
* Name of the bold style of the standard PDF font Times.
*/
const FONT_TIMES_BOLD = 'Times-Bold';
/**
* Name of the italic style of the standard PDF font Times.
*/
const FONT_TIMES_ITALIC = 'Times-Italic';
/**
* Name of the bold and italic style of the standard PDF font Times.
*/
const FONT_TIMES_BOLD_ITALIC = 'Times-BoldItalic';
/**
* Name of the standard PDF font Zapf Dingbats.
*/
const FONT_ZAPFDINGBATS = 'ZapfDingbats';
/* Font Name String Types */
/**
* Full copyright notice for the font.
*/
const NAME_COPYRIGHT = 0;
/**
* Font family name. Used to group similar styles of fonts together.
*/
const NAME_FAMILY = 1;
/**
* Font style within the font family. Examples: Regular, Italic, Bold, etc.
*/
const NAME_STYLE = 2;
/**
* Unique font identifier.
*/
const NAME_ID = 3;
/**
* Full font name. Usually a combination of the {@link NAME_FAMILY} and
* {@link NAME_STYLE} strings.
*/
const NAME_FULL = 4;
/**
* Version number of the font.
*/
const NAME_VERSION = 5;
/**
* PostScript name for the font. This is the name used to identify fonts
* internally and within the PDF file.
*/
const NAME_POSTSCRIPT = 6;
/**
* Font trademark notice. This is distinct from the {@link NAME_COPYRIGHT}.
*/
const NAME_TRADEMARK = 7;
/**
* Name of the font manufacturer.
*/
const NAME_MANUFACTURER = 8;
/**
* Name of the designer of the font.
*/
const NAME_DESIGNER = 9;
/**
* Description of the font. May contain revision information, usage
* recommendations, features, etc.
*/
const NAME_DESCRIPTION = 10;
/**
* URL of the font vendor. Some fonts may contain a unique serial number
* embedded in this URL, which is used for licensing.
*/
const NAME_VENDOR_URL = 11;
/**
* URL of the font designer ({@link NAME_DESIGNER}).
*/
const NAME_DESIGNER_URL = 12;
/**
* Plain language licensing terms for the font.
*/
const NAME_LICENSE = 13;
/**
* URL of more detailed licensing information for the font.
*/
const NAME_LICENSE_URL = 14;
/**
* Preferred font family. Used by some fonts to work around a Microsoft
* Windows limitation where only four fonts styles can share the same
* {@link NAME_FAMILY} value.
*/
const NAME_PREFERRED_FAMILY = 16;
/**
* Preferred font style. A more descriptive string than {@link NAME_STYLE}.
*/
const NAME_PREFERRED_STYLE = 17;
/**
* Suggested text to use as a representative sample of the font.
*/
const NAME_SAMPLE_TEXT = 19;
/**
* PostScript CID findfont name.
*/
const NAME_CID_NAME = 20;
/* Font Weights */
/**
* Thin font weight.
*/
const WEIGHT_THIN = 100;
/**
* Extra-light (Ultra-light) font weight.
*/
const WEIGHT_EXTRA_LIGHT = 200;
/**
* Light font weight.
*/
const WEIGHT_LIGHT = 300;
/**
* Normal (Regular) font weight.
*/
const WEIGHT_NORMAL = 400;
/**
* Medium font weight.
*/
const WEIGHT_MEDIUM = 500;
/**
* Semi-bold (Demi-bold) font weight.
*/
const WEIGHT_SEMI_BOLD = 600;
/**
* Bold font weight.
*/
const WEIGHT_BOLD = 700;
/**
* Extra-bold (Ultra-bold) font weight.
*/
const WEIGHT_EXTRA_BOLD = 800;
/**
* Black (Heavy) font weight.
*/
const WEIGHT_BLACK = 900;
/* Font Widths */
/**
* Ultra-condensed font width. Typically 50% of normal.
*/
const WIDTH_ULTRA_CONDENSED = 1;
/**
* Extra-condensed font width. Typically 62.5% of normal.
*/
const WIDTH_EXTRA_CONDENSED = 2;
/**
* Condensed font width. Typically 75% of normal.
*/
const WIDTH_CONDENSED = 3;
/**
* Semi-condensed font width. Typically 87.5% of normal.
*/
const WIDTH_SEMI_CONDENSED = 4;
/**
* Normal (Medium) font width.
*/
const WIDTH_NORMAL = 5;
/**
* Semi-expanded font width. Typically 112.5% of normal.
*/
const WIDTH_SEMI_EXPANDED = 6;
/**
* Expanded font width. Typically 125% of normal.
*/
const WIDTH_EXPANDED = 7;
/**
* Extra-expanded font width. Typically 150% of normal.
*/
const WIDTH_EXTRA_EXPANDED = 8;
/**
* Ultra-expanded font width. Typically 200% of normal.
*/
const WIDTH_ULTRA_EXPANDED = 9;
/* Font Embedding Options */
/**
* Do not embed the font in the PDF document.
*/
const EMBED_DONT_EMBED = 0x01;
/**
* Embed, but do not subset the font in the PDF document.
*/
const EMBED_DONT_SUBSET = 0x02;
/**
* Embed, but do not compress the font in the PDF document.
*/
const EMBED_DONT_COMPRESS = 0x04;
/**
* Suppress the exception normally thrown if the font cannot be embedded
* due to its copyright bits being set.
*/
const EMBED_SUPPRESS_EMBED_EXCEPTION = 0x08;
/**** Class Variables ****/
/**
* Array whose keys are the unique PostScript names of instantiated fonts.
* The values are the font objects themselves.
* @var array
*/
private static $_fontNames = array();
/**
* Array whose keys are the md5 hash of the full paths on disk for parsed
* fonts. The values are the font objects themselves.
* @var array
*/
private static $_fontFilePaths = array();
/**** Public Interface ****/
/* Factory Methods */
/**
* Returns a {@link Zend_Pdf_Resource_Font} object by full name.
*
* This is the preferred method to obtain one of the standard 14 PDF fonts.
*
* The result of this method is cached, preventing unnecessary duplication
* of font objects. Repetitive calls for a font with the same name will
* return the same object.
*
* The $embeddingOptions parameter allows you to set certain flags related
* to font embedding. You may combine options by OR-ing them together. See
* the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
* available options and their descriptions. Note that this value is only
* used when creating a font for the first time. If a font with the same
* name already exists, you will get that object and the options you specify
* here will be ignored. This is because fonts are only embedded within the
* PDF file once.
*
* If the font name supplied does not match the name of a previously
* instantiated object and it is not one of the 14 standard PDF fonts, an
* exception will be thrown.
*
* @param string $name Full PostScript name of font.
* @param integer $embeddingOptions (optional) Options for font embedding.
* @return Zend_Pdf_Resource_Font
* @throws Zend_Pdf_Exception
*/
public static function fontWithName($name, $embeddingOptions = 0)
{
/* First check the cache. Don't duplicate font objects.
*/
if (isset(Zend_Pdf_Font::$_fontNames[$name])) {
return Zend_Pdf_Font::$_fontNames[$name];
}
/**
* @todo It would be cool to be able to have a mapping of font names to
* file paths in a configuration file for frequently used custom
* fonts. This would allow a user to use custom fonts without having
* to hard-code file paths all over the place. Table this idea until
* {@link Zend_Config} is ready.
*/
/* Not an existing font and no mapping in the config file. Check to see
* if this is one of the standard 14 PDF fonts.
*/
switch ($name) {
case Zend_Pdf_Font::FONT_COURIER:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_Courier();
break;
case Zend_Pdf_Font::FONT_COURIER_BOLD:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_CourierBold();
break;
case Zend_Pdf_Font::FONT_COURIER_OBLIQUE:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_CourierOblique();
break;
case Zend_Pdf_Font::FONT_COURIER_BOLD_OBLIQUE:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_CourierBoldOblique();
break;
case Zend_Pdf_Font::FONT_HELVETICA:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_Helvetica();
break;
case Zend_Pdf_Font::FONT_HELVETICA_BOLD:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBold();
break;
case Zend_Pdf_Font::FONT_HELVETICA_OBLIQUE:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_HelveticaOblique();
break;
case Zend_Pdf_Font::FONT_HELVETICA_BOLD_OBLIQUE:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBoldOblique();
break;
case Zend_Pdf_Font::FONT_SYMBOL:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_Symbol();
break;
case Zend_Pdf_Font::FONT_TIMES_ROMAN:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_TimesRoman();
break;
case Zend_Pdf_Font::FONT_TIMES_BOLD:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_TimesBold();
break;
case Zend_Pdf_Font::FONT_TIMES_ITALIC:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_TimesItalic();
break;
case Zend_Pdf_Font::FONT_TIMES_BOLD_ITALIC:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_TimesBoldItalic();
break;
case Zend_Pdf_Font::FONT_ZAPFDINGBATS:
$font = new Zend_Pdf_Resource_Font_Simple_Standard_ZapfDingbats();
break;
default:
throw new Zend_Pdf_Exception("Unknown font name: $name",
Zend_Pdf_Exception::BAD_FONT_NAME);
}
/* Add this new font to the cache array and return it for use.
*/
Zend_Pdf_Font::$_fontNames[$name] = $font;
return $font;
}
/**
* Returns a {@link Zend_Pdf_Resource_Font} object by file path.
*
* The result of this method is cached, preventing unnecessary duplication
* of font objects. Repetitive calls for the font with the same path will
* return the same object.
*
* The $embeddingOptions parameter allows you to set certain flags related
* to font embedding. You may combine options by OR-ing them together. See
* the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
* available options and their descriptions. Note that this value is only
* used when creating a font for the first time. If a font with the same
* name already exists, you will get that object and the options you specify
* here will be ignored. This is because fonts are only embedded within the
* PDF file once.
*
* If the file path supplied does not match the path of a previously
* instantiated object or the font type cannot be determined, an exception
* will be thrown.
*
* @param string $filePath Full path to the font file.
* @param integer $embeddingOptions (optional) Options for font embedding.
* @return Zend_Pdf_Resource_Font
* @throws Zend_Pdf_Exception
*/
public static function fontWithPath($filePath, $embeddingOptions = 0)
{
/* First check the cache. Don't duplicate font objects.
*/
$filePathKey = md5($filePath);
if (isset(Zend_Pdf_Font::$_fontFilePaths[$filePathKey])) {
return Zend_Pdf_Font::$_fontFilePaths[$filePathKey];
}
/* Create a file parser data source object for this file. File path and
* access permission checks are handled here.
*/
$dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
/* Attempt to determine the type of font. We can't always trust file
* extensions, but try that first since it's fastest.
*/
$fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
/* If it turns out that the file is named improperly and we guess the
* wrong type, we'll get null instead of a font object.
*/
switch ($fileExtension) {
case 'ttf':
$font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
break;
default:
/* Unrecognized extension. Try to determine the type by actually
* parsing it below.
*/
$font = null;
break;
}
if (is_null($font)) {
/* There was no match for the file extension or the extension was
* wrong. Attempt to detect the type of font by actually parsing it.
* We'll do the checks in order of most likely format to try to
* reduce the detection time.
*/
// OpenType
// TrueType
if ((is_null($font)) && ($fileExtension != 'ttf')) {
$font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
}
// Type 1 PostScript
// Mac OS X dfont
// others?
}
/* Done with the data source object.
*/
$dataSource = null;
if (! is_null($font)) {
/* Parsing was successful. Add this font instance to the cache arrays
* and return it for use.
*/
$fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, '', '');
Zend_Pdf_Font::$_fontNames[$fontName] = $font;
$filePathKey = md5($filePath);
Zend_Pdf_Font::$_fontFilePaths[$filePathKey] = $font;
return $font;
} else {
/* The type of font could not be determined. Give up.
*/
throw new Zend_Pdf_Exception("Cannot determine font type: $filePath",
Zend_Pdf_Exception::CANT_DETERMINE_FONT_TYPE);
}
}
/**** Internal Methods ****/
/* Font Extraction Methods */
/**
* Attempts to extract a TrueType font from the data source.
*
* If the font parser throws an exception that suggests the data source
* simply doesn't contain a TrueType font, catches it and returns null. If
* an exception is thrown that suggests the TrueType font is corrupt or
* otherwise unusable, throws that exception. If successful, returns the
* font object.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @param integer $embeddingOptions Options for font embedding.
* @return Zend_Pdf_Resource_Font_OpenType_TrueType May also return null if
* the data source does not appear to contain a TrueType font.
* @throws Zend_Pdf_Exception
*/
protected static function _extractTrueTypeFont($dataSource, $embeddingOptions)
{
try {
$fontParser = new Zend_Pdf_FileParser_Font_OpenType_TrueType($dataSource);
$fontParser->parse();
if ($fontParser->isAdobeLatinSubset) {
$font = new Zend_Pdf_Resource_Font_Simple_Parsed_TrueType($fontParser, $embeddingOptions);
} else {
/* Use Composite Type 0 font which supports Unicode character mapping */
$cidFont = new Zend_Pdf_Resource_Font_CidFont_TrueType($fontParser, $embeddingOptions);
$font = new Zend_Pdf_Resource_Font_Type0($cidFont);
}
} catch (Zend_Pdf_Exception $exception) {
/* The following exception codes suggest that this isn't really a
* TrueType font. If we caught such an exception, simply return
* null. For all other cases, it probably is a TrueType font but has
* a problem; throw the exception again.
*/
$fontParser = null;
switch ($exception->getCode()) {
case Zend_Pdf_Exception::WRONG_FONT_TYPE: // break intentionally omitted
case Zend_Pdf_Exception::BAD_TABLE_COUNT: // break intentionally omitted
case Zend_Pdf_Exception::BAD_MAGIC_NUMBER:
return null;
default:
throw $exception;
}
}
return $font;
}
}

244
libs/Zend/Pdf/Image.php Normal file
View File

@ -0,0 +1,244 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Images
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_FileParserDataSource */
require_once 'Zend/Pdf/FileParserDataSource.php';
/** Zend_Pdf_FileParserDataSource_File */
require_once 'Zend/Pdf/FileParserDataSource/File.php';
/** Zend_Pdf_FileParserDataSource_String */
require_once 'Zend/Pdf/FileParserDataSource/String.php';
/**
* Abstract factory class which vends {@link Zend_Pdf_Resource_Image} objects.
*
* This class is also the home for image-related constants because the name of
* the true base class ({@link Zend_Pdf_Resource_Image}) is not intuitive for the
* end user.
*
* @package Zend_Pdf
* @subpackage Images
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Image
{
/**** Class Constants ****/
/* Image Types */
const TYPE_UNKNOWN = 0;
const TYPE_JPEG = 1;
const TYPE_PNG = 2;
const TYPE_TIFF = 3;
/* TIFF Constants */
const TIFF_FIELD_TYPE_BYTE=1;
const TIFF_FIELD_TYPE_ASCII=2;
const TIFF_FIELD_TYPE_SHORT=3;
const TIFF_FIELD_TYPE_LONG=4;
const TIFF_FIELD_TYPE_RATIONAL=5;
const TIFF_TAG_IMAGE_WIDTH=256;
const TIFF_TAG_IMAGE_LENGTH=257; //Height
const TIFF_TAG_BITS_PER_SAMPLE=258;
const TIFF_TAG_COMPRESSION=259;
const TIFF_TAG_PHOTOMETRIC_INTERPRETATION=262;
const TIFF_TAG_STRIP_OFFSETS=273;
const TIFF_TAG_SAMPLES_PER_PIXEL=277;
const TIFF_TAG_STRIP_BYTE_COUNTS=279;
const TIFF_COMPRESSION_UNCOMPRESSED = 1;
const TIFF_COMPRESSION_CCITT1D = 2;
const TIFF_COMPRESSION_GROUP_3_FAX = 3;
const TIFF_COMPRESSION_GROUP_4_FAX = 4;
const TIFF_COMPRESSION_LZW = 5;
const TIFF_COMPRESSION_JPEG = 6;
const TIFF_COMPRESSION_FLATE = 8;
const TIFF_COMPRESSION_FLATE_OBSOLETE_CODE = 32946;
const TIFF_COMPRESSION_PACKBITS = 32773;
const TIFF_PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO=0;
const TIFF_PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO=1;
const TIFF_PHOTOMETRIC_INTERPRETATION_RGB=2;
const TIFF_PHOTOMETRIC_INTERPRETATION_RGB_INDEXED=3;
const TIFF_PHOTOMETRIC_INTERPRETATION_CMYK=5;
const TIFF_PHOTOMETRIC_INTERPRETATION_YCBCR=6;
const TIFF_PHOTOMETRIC_INTERPRETATION_CIELAB=8;
/* PNG Constants */
const PNG_COMPRESSION_DEFAULT_STRATEGY = 0;
const PNG_COMPRESSION_FILTERED = 1;
const PNG_COMPRESSION_HUFFMAN_ONLY = 2;
const PNG_COMPRESSION_RLE = 3;
const PNG_FILTER_NONE = 0;
const PNG_FILTER_SUB = 1;
const PNG_FILTER_UP = 2;
const PNG_FILTER_AVERAGE = 3;
const PNG_FILTER_PAETH = 4;
const PNG_INTERLACING_DISABLED = 0;
const PNG_INTERLACING_ENABLED = 1;
const PNG_CHANNEL_GRAY = 0;
const PNG_CHANNEL_RGB = 2;
const PNG_CHANNEL_INDEXED = 3;
const PNG_CHANNEL_GRAY_ALPHA = 4;
const PNG_CHANNEL_RGB_ALPHA = 6;
/**** Public Interface ****/
/* Factory Methods */
/**
* Returns a {@link Zend_Pdf_Resource_Image} object by file path.
*
* @param string $filePath Full path to the image file.
* @return Zend_Pdf_Resource_Image
* @throws Zend_Pdf_Exception
*/
public static function imageWithPath($filePath)
{
/**
* use old implementation
* @todo switch to new implementation
*/
require_once 'Zend/Pdf/Resource/ImageFactory.php';
return Zend_Pdf_Resource_ImageFactory::factory($filePath);
/* Create a file parser data source object for this file. File path and
* access permission checks are handled here.
*/
$dataSource = new Zend_Pdf_FileParserDataSource_File($filePath);
/* Attempt to determine the type of image. We can't always trust file
* extensions, but try that first since it's fastest.
*/
$fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));
/* If it turns out that the file is named improperly and we guess the
* wrong type, we'll get null instead of an image object.
*/
switch ($fileExtension) {
case 'tif':
//Fall through to next case;
case 'tiff':
$image = Zend_Pdf_Image::_extractTiffImage($dataSource);
break;
case 'png':
$image = Zend_Pdf_Image::_extractPngImage($dataSource);
break;
case 'jpg':
//Fall through to next case;
case 'jpe':
//Fall through to next case;
case 'jpeg':
$image = Zend_Pdf_Image::_extractJpegImage($dataSource);
break;
default:
throw new Zend_Pdf_Exception("Cannot create image resource. File extension not known or unsupported type.");
break;
}
/* Done with the data source object.
*/
$dataSource = null;
if (! is_null($image)) {
return $image;
} else {
/* The type of image could not be determined. Give up.
*/
throw new Zend_Pdf_Exception("Cannot determine image type: $filePath",
Zend_Pdf_Exception::CANT_DETERMINE_IMAGE_TYPE);
}
}
/**** Internal Methods ****/
/* Image Extraction Methods */
/**
* Attempts to extract a JPEG Image from the data source.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @return Zend_Pdf_Resource_Image_Jpeg May also return null if
* the data source does not appear to contain valid image data.
* @throws Zend_Pdf_Exception
*/
protected static function _extractJpegImage($dataSource)
{
$imageParser = new Zend_Pdf_FileParser_Image_Jpeg($dataSource);
$image = new Zend_Pdf_Resource_Image_Jpeg($imageParser);
unset($imageParser);
return $image;
}
/**
* Attempts to extract a PNG Image from the data source.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @return Zend_Pdf_Resource_Image_Png May also return null if
* the data source does not appear to contain valid image data.
* @throws Zend_Pdf_Exception
*/
protected static function _extractPngImage($dataSource)
{
$imageParser = new Zend_Pdf_FileParser_Image_PNG($dataSource);
$image = new Zend_Pdf_Resource_Image_PNG($imageParser);
unset($imageParser);
return $image;
}
/**
* Attempts to extract a TIFF Image from the data source.
*
* @param Zend_Pdf_FileParserDataSource $dataSource
* @return Zend_Pdf_Resource_Image_Tiff May also return null if
* the data source does not appear to contain valid image data.
* @throws Zend_Pdf_Exception
*/
protected static function _extractTiffImage($dataSource)
{
$imageParser = new Zend_Pdf_FileParser_Image_Tiff($dataSource);
$image = new Zend_Pdf_Resource_Image_Tiff($imageParser);
unset($imageParser);
return $image;
}
}

1450
libs/Zend/Pdf/Page.php Normal file

File diff suppressed because it is too large Load Diff

467
libs/Zend/Pdf/Parser.php Normal file
View File

@ -0,0 +1,467 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_Element_Array */
require_once 'Zend/Pdf/Element/Array.php';
/** Zend_Pdf_Element_String_Binary */
require_once 'Zend/Pdf/Element/String/Binary.php';
/** Zend_Pdf_Element_Boolean */
require_once 'Zend/Pdf/Element/Boolean.php';
/** Zend_Pdf_Element_Dictionary */
require_once 'Zend/Pdf/Element/Dictionary.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Reference */
require_once 'Zend/Pdf/Element/Reference.php';
/** Zend_Pdf_Element_Object_Stream */
require_once 'Zend/Pdf/Element/Object/Stream.php';
/** Zend_Pdf_Element_String */
require_once 'Zend/Pdf/Element/String.php';
/** Zend_Pdf_Element_Null */
require_once 'Zend/Pdf/Element/Null.php';
/** Zend_Pdf_Element_Reference_Context */
require_once 'Zend/Pdf/Element/Reference/Context.php';
/** Zend_Pdf_Element_Reference_Table */
require_once 'Zend/Pdf/Element/Reference/Table.php';
/** Zend_Pdf_Trailer_Keeper */
require_once 'Zend/Pdf/Trailer/Keeper.php';
/** Zend_Pdf_ElementFactory_Interface */
require_once 'Zend/Pdf/ElementFactory/Interface.php';
/** Zend_Pdf_PhpArray */
require_once 'Zend/Pdf/PhpArray.php';
/** Zend_Pdf_StringParser */
require_once 'Zend/Pdf/StringParser.php';
/** Zend_Pdf_Parser_Stream */
require_once 'Zend/Pdf/Parser/Stream.php';
/**
* PDF file parser
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Parser
{
/**
* String parser
*
* @var Zend_Pdf_StringParser
*/
private $_stringParser;
/**
* Last PDF file trailer
*
* @var Zend_Pdf_Trailer_Keeper
*/
private $_trailer;
/**
* Get length of source PDF
*
* @return integer
*/
public function getPDFLength()
{
return strlen($this->_stringParser->data);
}
/**
* Get PDF String
*
* @return string
*/
public function getPDFString()
{
return $this->_stringParser->data;
}
/**
* Load XReference table and referenced objects
*
* @param integer $offset
* @throws Zend_Pdf_Exception
* @return Zend_Pdf_Trailer_Keeper
*/
private function _loadXRefTable($offset)
{
$this->_stringParser->offset = $offset;
$refTable = new Zend_Pdf_Element_Reference_Table();
$context = new Zend_Pdf_Element_Reference_Context($this->_stringParser, $refTable);
$this->_stringParser->setContext($context);
$nextLexeme = $this->_stringParser->readLexeme();
if ($nextLexeme == 'xref') {
/**
* Common cross-reference table
*/
$this->_stringParser->skipWhiteSpace();
while ( ($nextLexeme = $this->_stringParser->readLexeme()) != 'trailer' ) {
if (!ctype_digit($nextLexeme)) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference table subheader values must contain only digits.', $this->_stringParser->offset-strlen($nextLexeme)));
}
$objNum = (int)$nextLexeme;
$refCount = $this->_stringParser->readLexeme();
if (!ctype_digit($refCount)) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference table subheader values must contain only digits.', $this->_stringParser->offset-strlen($refCount)));
}
$this->_stringParser->skipWhiteSpace();
while ($refCount > 0) {
$objectOffset = substr($this->_stringParser->data, $this->_stringParser->offset, 10);
if (!ctype_digit($objectOffset)) {
throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Offset must contain only digits.', $this->_stringParser->offset));
}
// Force $objectOffset to be treated as decimal instead of octal number
for ($numStart = 0; $numStart < strlen($objectOffset)-1; $numStart++) {
if ($objectOffset[$numStart] != '0') {
break;
}
}
$objectOffset = substr($objectOffset, $numStart);
$this->_stringParser->offset += 10;
if ( !Zend_Pdf_StringParser::isWhiteSpace(ord( $this->_stringParser->data[$this->_stringParser->offset] )) ) {
throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
}
$this->_stringParser->offset++;
$genNumber = substr($this->_stringParser->data, $this->_stringParser->offset, 5);
if (!ctype_digit($objectOffset)) {
throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Offset must contain only digits.', $this->_stringParser->offset));
}
// Force $objectOffset to be treated as decimal instead of octal number
for ($numStart = 0; $numStart < strlen($genNumber)-1; $numStart++) {
if ($genNumber[$numStart] != '0') {
break;
}
}
$genNumber = substr($genNumber, $numStart);
$this->_stringParser->offset += 5;
if ( !Zend_Pdf_StringParser::isWhiteSpace(ord( $this->_stringParser->data[$this->_stringParser->offset] )) ) {
throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
}
$this->_stringParser->offset++;
$inUseKey = $this->_stringParser->data[$this->_stringParser->offset];
$this->_stringParser->offset++;
switch ($inUseKey) {
case 'f':
// free entry
unset( $this->_refTable[$objNum . ' ' . $genNumber . ' R'] );
$refTable->addReference($objNum . ' ' . $genNumber . ' R',
$objectOffset,
false);
break;
case 'n':
// in-use entry
$refTable->addReference($objNum . ' ' . $genNumber . ' R',
$objectOffset,
true);
}
if ( !Zend_Pdf_StringParser::isWhiteSpace(ord( $this->_stringParser->data[$this->_stringParser->offset] )) ) {
throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
}
$this->_stringParser->offset++;
if ( !Zend_Pdf_StringParser::isWhiteSpace(ord( $this->_stringParser->data[$this->_stringParser->offset] )) ) {
throw new Zend_Pdf_Exception(sprintf('PDF file cross-reference table syntax error. Offset - 0x%X. Value separator must be white space.', $this->_stringParser->offset));
}
$this->_stringParser->offset++;
$refCount--;
$objNum++;
}
}
$trailerDictOffset = $this->_stringParser->offset;
$trailerDict = $this->_stringParser->readElement();
if (!$trailerDict instanceof Zend_Pdf_Element_Dictionary) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Dictionary expected after \'trailer\' keyword.', $trailerDictOffset));
}
} else {
$xrefStream = $this->_stringParser->getObject($offset, $context);
if (!$xrefStream instanceof Zend_Pdf_Element_Object_Stream) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference stream expected.', $offset));
}
$trailerDict = $xrefStream->dictionary;
if ($trailerDict->Type->value != 'XRef') {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross-reference stream object must have /Type property assigned to /XRef.', $offset));
}
if ($trailerDict->W === null || $trailerDict->W->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross reference stream dictionary doesn\'t have W entry or it\'s not an array.', $offset));
}
$entryField1Size = $trailerDict->W->items[0]->value;
$entryField2Size = $trailerDict->W->items[1]->value;
$entryField3Size = $trailerDict->W->items[2]->value;
if ($entryField2Size == 0 || $entryField3Size == 0) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Wrong W dictionary entry. Only type field of stream entries has default value and could be zero length.', $offset));
}
$xrefStreamData = &$xrefStream->value;
if ($trailerDict->Index !== null) {
if ($trailerDict->Index->getType() != Zend_Pdf_Element::TYPE_ARRAY) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Cross reference stream dictionary Index entry must be an array.', $offset));
}
$sections = count($trailerDict->Index->items)/2;
} else {
$sections = 1;
}
$streamOffset = 0;
$size = $entryField1Size + $entryField2Size + $entryField3Size;
$entries = strlen($xrefStreamData)/$size;
for ($count = 0; $count < $sections; $count++) {
if ($trailerDict->Index !== null) {
$objNum = $trailerDict->Index->items[$count*2 ]->value;
$entries = $trailerDict->Index->items[$count*2 + 1]->value;
} else {
$objNum = 0;
$entries = $trailerDict->Size->value;
}
for ($count2 = 0; $count2 < $entries; $count2++) {
if ($entryField1Size == 0) {
$type = 1;
} else if ($entryField1Size == 1) { // Optimyze one-byte field case
$type = ord($xrefStreamData[$streamOffset++]);
} else {
$type = Zend_Pdf_StringParser::parseIntFromStream($xrefStreamData, $streamOffset, $entryField1Size);
$streamOffset += $entryField1Size;
}
if ($entryField2Size == 1) { // Optimyze one-byte field case
$field2 = ord($xrefStreamData[$streamOffset++]);
} else {
$field2 = Zend_Pdf_StringParser::parseIntFromStream($xrefStreamData, $streamOffset, $entryField2Size);
$streamOffset += $entryField2Size;
}
if ($entryField3Size == 1) { // Optimyze one-byte field case
$field3 = ord($xrefStreamData[$streamOffset++]);
} else {
$field3 = Zend_Pdf_StringParser::parseIntFromStream($xrefStreamData, $streamOffset, $entryField3Size);
$streamOffset += $entryField3Size;
}
switch ($type) {
case 0:
// Free object
$refTable->addReference($objNum . ' ' . $field3 . ' R', $field2, false);
// Debug output:
// echo "Free object - $objNum $field3 R, next free - $field2\n";
break;
case 1:
// In use object
$refTable->addReference($objNum . ' ' . $field3 . ' R', $field2, true);
// Debug output:
// echo "In-use object - $objNum $field3 R, offset - $field2\n";
break;
case 2:
// Object in an object stream
// Debug output:
// echo "Compressed object - $objNum 0 R, object stream - $field2 0 R, offset - $field3\n";
break;
}
$objNum++;
}
}
// $streamOffset . ' ' . strlen($xrefStreamData) . "\n";
// "$entries\n";
throw new Zend_Pdf_Exception('Cross-reference streams are not supported yet.');
}
$trailerObj = new Zend_Pdf_Trailer_Keeper($trailerDict, $context);
if ($trailerDict->Prev instanceof Zend_Pdf_Element_Numeric ||
$trailerDict->Prev instanceof Zend_Pdf_Element_Reference ) {
$trailerObj->setPrev($this->_loadXRefTable($trailerDict->Prev->value));
$context->getRefTable()->setParent($trailerObj->getPrev()->getRefTable());
}
/**
* We set '/Prev' dictionary property to the current cross-reference section offset.
* It doesn't correspond to the actual data, but is true when trailer will be used
* as a trailer for next generated PDF section.
*/
$trailerObj->Prev = new Zend_Pdf_Element_Numeric($offset);
return $trailerObj;
}
/**
* Get Trailer object
*
* @return Zend_Pdf_Trailer_Keeper
*/
public function getTrailer()
{
return $this->_trailer;
}
/**
* Object constructor
*
* Note: PHP duplicates string, which is sent by value, only of it's updated.
* Thus we don't need to care about overhead
*
* @param mixed $source
* @param Zend_Pdf_ElementFactory_Interface $factory
* @param boolean $load
* @throws Zend_Exception
*/
public function __construct($source, Zend_Pdf_ElementFactory_Interface $factory, $load)
{
if ($load) {
if (($pdfFile = @fopen($source, 'rb')) === false ) {
throw new Zend_Pdf_Exception( "Can not open '$source' file for reading." );
}
$byteCount = filesize($source);
$data = fread($pdfFile, $byteCount);
$byteCount -= strlen($data);
while ( $byteCount > 0 && ($nextBlock = fread($pdfFile, $byteCount)) != false ) {
$data .= $nextBlock;
$byteCount -= strlen($nextBlock);
}
fclose($pdfFile);
$this->_stringParser = new Zend_Pdf_StringParser($data, $factory);
} else {
$this->_stringParser = new Zend_Pdf_StringParser($source, $factory);
}
$pdfVersionComment = $this->_stringParser->readComment();
if (substr($pdfVersionComment, 0, 5) != '%PDF-') {
throw new Zend_Pdf_Exception('File is not a PDF.');
}
$pdfVersion = (float)substr($pdfVersionComment, 5);
if ($pdfVersion < 0.9 || $pdfVersion >= 1.61) {
/**
* @todo
* To support PDF versions 1.5 (Acrobat 6) and PDF version 1.7 (Acrobat 7)
* Stream compression filter must be implemented (for compressed object streams).
* Cross reference streams must be implemented
*/
throw new Zend_Pdf_Exception(sprintf('Unsupported PDF version. Zend_Pdf supports PDF 1.0-1.4. Current version - \'%f\'', $pdfVersion));
}
$this->_stringParser->offset = strrpos($this->_stringParser->data, '%%EOF');
if ($this->_stringParser->offset === false ||
strlen($this->_stringParser->data) - $this->_stringParser->offset > 7) {
throw new Zend_Pdf_Exception('Pdf file syntax error. End-of-fle marker expected at the end of file.');
}
$this->_stringParser->offset--;
/**
* Go to end of cross-reference table offset
*/
while (Zend_Pdf_StringParser::isWhiteSpace( ord($this->_stringParser->data[$this->_stringParser->offset]) )&&
($this->_stringParser->offset > 0)) {
$this->_stringParser->offset--;
}
/**
* Go to the start of cross-reference table offset
*/
while ( (!Zend_Pdf_StringParser::isWhiteSpace( ord($this->_stringParser->data[$this->_stringParser->offset]) ))&&
($this->_stringParser->offset > 0)) {
$this->_stringParser->offset--;
}
/**
* Go to the end of 'startxref' keyword
*/
while (Zend_Pdf_StringParser::isWhiteSpace( ord($this->_stringParser->data[$this->_stringParser->offset]) )&&
($this->_stringParser->offset > 0)) {
$this->_stringParser->offset--;
}
/**
* Go to the white space (eol marker) before 'startxref' keyword
*/
$this->_stringParser->offset -= 9;
$nextLexeme = $this->_stringParser->readLexeme();
if ($nextLexeme != 'startxref') {
throw new Zend_Pdf_Exception(sprintf('Pdf file syntax error. \'startxref\' keyword expected. Offset - 0x%X.', $this->_stringParser->offset-strlen($nextLexeme)));
}
$startXref = $this->_stringParser->readLexeme();
if (!ctype_digit($startXref)) {
throw new Zend_Pdf_Exception(sprintf('Pdf file syntax error. Cross-reference table offset must contain only digits. Offset - 0x%X.', $this->_stringParser->offset-strlen($nextLexeme)));
}
$this->_trailer = $this->_loadXRefTable($startXref);
$factory->setObjectCount($this->_trailer->Size->value);
}
/**
* Object destructor
*/
public function __destruct()
{
$this->_stringParser->cleanUp();
}
}

View File

@ -0,0 +1,59 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Parser */
require_once 'Zend/Pdf/Parser.php';
/**
* PDF object stream parser
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Parser_Stream extends Zend_Pdf_Parser
{
/**
* Get Trailer object
*
* @return Zend_Pdf_Trailer_Keeper
*/
public function getTrailer()
{
throw new Zend_Pdf_Exception('Stream object parser doesn\'t contain trailer information.');
}
/**
* Object constructor
*
* @param string $pdfString
* @param Zend_Pdf_ElementFactory $factory
* @throws Zend_Exception
*/
public function __construct(&$source, Zend_Pdf_ElementFactory $factory)
{
$this->_current = 0;
$this->_currentContext = null;
$this->_contextStack = array();
$this->_elements = new Zend_Pdf_PhpArray();
$this->_objFactory = $factory;
}
}

128
libs/Zend/Pdf/PhpArray.php Normal file
View File

@ -0,0 +1,128 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/**
* PHP Array (OO wrapper)
* Used to be returned by reference by __get() methods
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @todo also implement Countable for PHP 5.1 but not yet to stay 5.0 compatible
*/
class Zend_Pdf_PhpArray implements ArrayAccess, Iterator, Countable {
/**
* Array element
* @var mixed
*/
protected $_items = array();
/**
* Object constructor
*
* @param array $srcArray
*/
public function __construct($srcArray = null)
{
if ($srcArray === null) {
reset($this->_items);
} else if (is_array($srcArray)) {
$this->_items = $srcArray;
} else {
throw new Exception('Array can be initialized only by other array');
}
}
public function current()
{
return current($this->_items);
}
public function next()
{
return next($this->_items);
}
public function key()
{
return key($this->_items);
}
public function valid() {
return current($this->_items)!==false;
}
public function rewind()
{
reset($this->_items);
}
public function offsetExists($offset)
{
return array_key_exists($offset, $this->_items);
}
public function offsetGet($offset)
{
return $this->_items[$offset];
}
public function offsetSet($offset, $value)
{
if ($offset === null) {
$this->_items[] = $value;
} else {
$this->_items[$offset] = $value;
}
}
public function offsetUnset($offset)
{
unset($this->_items[$offset]);
}
public function clear()
{
$this->_items = array();
}
/**
* Defined by Countable interface
*
* @return int
*/
public function count()
{
return count($this->_items);
}
}

108
libs/Zend/Pdf/Resource.php Normal file
View File

@ -0,0 +1,108 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_ElementFactory */
require_once 'Zend/Pdf/ElementFactory.php';
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Dictionary */
require_once 'Zend/Pdf/Element/Dictionary.php';
/**
* PDF file Resource abstraction
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource
{
/**
* Each Pdf resource (fonts, images, ...) interacts with a PDF itself.
* It creates appropriate PDF objects, structures and sometime embedded files.
* Resources are referenced in content streams by names, which are stored in
* a page resource dictionaries.
*
* Thus, resources must be attached to the PDF.
*
* Resource abstraction uses own PDF object factory to store all necessary information.
* At the render time internal object factory is appended to the global PDF file
* factory.
*
* Resource abstraction also cashes information about rendered PDF files and
* doesn't duplicate resource description each time then Resource is rendered
* (referenced).
*
* @var Zend_Pdf_ElementFactory_Interface
*/
protected $_objectFactory;
/**
* Main resource object
*
* @var Zend_Pdf_Element_Object
*/
protected $_resource;
/**
* Object constructor.
*
* If resource is not a Zend_Pdf_Element object, then stream object with specified value is
* generated.
*
* @param Zend_Pdf_Element|string $resource
*/
public function __construct($resource)
{
$this->_objectFactory = Zend_Pdf_ElementFactory::createFactory(1);
if ($resource instanceof Zend_Pdf_Element) {
$this->_resource = $this->_objectFactory->newObject($resource);
} else {
$this->_resource = $this->_objectFactory->newStreamObject($resource);
}
}
/**
* Get resource.
* Used to reference resource in an internal PDF data structures (resource dictionaries)
*
* @internal
* @return Zend_Pdf_Element_Object
*/
public function getResource()
{
return $this->_resource;
}
/**
* Get factory.
*
* @internal
* @return Zend_Pdf_ElementFactory_Interface
*/
public function getFactory()
{
return $this->_objectFactory;
}
}

View File

@ -0,0 +1,524 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource */
require_once 'Zend/Pdf/Resource.php';
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/**
* Abstract class which manages PDF fonts.
*
* Defines the public interface and creates shared storage for concrete
* subclasses which are responsible for generating the font's information
* dictionaries, mapping characters to glyphs, and providing both overall font
* and glyph-specific metric data.
*
* Font objects should be normally be obtained from the factory methods
* {@link Zend_Pdf_Font::fontWithName} and {@link Zend_Pdf_Font::fontWithPath}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource
{
/**** Instance Variables ****/
/**
* The type of font. Use TYPE_ constants defined in {@link Zend_Pdf_Font}.
* @var integer
*/
protected $_fontType = Zend_Pdf_Font::TYPE_UNKNOWN;
/**
* Array containing descriptive names for the font. See {@link fontName()}.
* @var array
*/
protected $_fontNames = array();
/**
* Flag indicating whether or not this font is bold.
* @var boolean
*/
protected $_isBold = false;
/**
* Flag indicating whether or not this font is italic.
* @var boolean
*/
protected $_isItalic = false;
/**
* Flag indicating whether or not this font is monospaced.
* @var boolean
*/
protected $_isMonospace = false;
/**
* The position below the text baseline of the underline (in glyph units).
* @var integer
*/
protected $_underlinePosition = 0;
/**
* The thickness of the underline (in glyph units).
* @var integer
*/
protected $_underlineThickness = 0;
/**
* The position above the text baseline of the strikethrough (in glyph units).
* @var integer
*/
protected $_strikePosition = 0;
/**
* The thickness of the strikethrough (in glyph units).
* @var integer
*/
protected $_strikeThickness = 0;
/**
* Number of glyph units per em. See {@link getUnitsPerEm()}.
* @var integer
*/
protected $_unitsPerEm = 0;
/**
* Typographical ascent. See {@link getAscent()}.
* @var integer
*/
protected $_ascent = 0;
/**
* Typographical descent. See {@link getDescent()}.
* @var integer
*/
protected $_descent = 0;
/**
* Typographical line gap. See {@link getLineGap()}.
* @var integer
*/
protected $_lineGap = 0;
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor.
*
*/
public function __construct()
{
parent::__construct(new Zend_Pdf_Element_Dictionary());
$this->_resource->Type = new Zend_Pdf_Element_Name('Font');
}
/* Object Magic Methods */
/**
* Returns the full name of the font in the encoding method of the current
* locale. Transliterates any characters that cannot be naturally
* represented in that character set.
*
* @return string
*/
public function __toString()
{
return $this->getFontName(Zend_Pdf_Font::NAME_FULL, '', '//TRANSLIT');
}
/* Accessors */
/**
* Returns the type of font.
*
* @return integer One of the TYPE_ constants defined in
* {@link Zend_Pdf_Font}.
*/
public function getFontType()
{
return $this->_fontType;
}
/**
* Returns the specified descriptive name for the font.
*
* The font name type is usually one of the following:
* <ul>
* <li>{@link Zend_Pdf_Font::NAME_FULL}
* <li>{@link Zend_Pdf_Font::NAME_FAMILY}
* <li>{@link Zend_Pdf_Font::NAME_PREFERRED_FAMILY}
* <li>{@link Zend_Pdf_Font::NAME_STYLE}
* <li>{@link Zend_Pdf_Font::NAME_PREFERRED_STYLE}
* <li>{@link Zend_Pdf_Font::NAME_DESCRIPTION}
* <li>{@link Zend_Pdf_Font::NAME_SAMPLE_TEXT}
* <li>{@link Zend_Pdf_Font::NAME_ID}
* <li>{@link Zend_Pdf_Font::NAME_VERSION}
* <li>{@link Zend_Pdf_Font::NAME_POSTSCRIPT}
* <li>{@link Zend_Pdf_Font::NAME_CID_NAME}
* <li>{@link Zend_Pdf_Font::NAME_DESIGNER}
* <li>{@link Zend_Pdf_Font::NAME_DESIGNER_URL}
* <li>{@link Zend_Pdf_Font::NAME_MANUFACTURER}
* <li>{@link Zend_Pdf_Font::NAME_VENDOR_URL}
* <li>{@link Zend_Pdf_Font::NAME_COPYRIGHT}
* <li>{@link Zend_Pdf_Font::NAME_TRADEMARK}
* <li>{@link Zend_Pdf_Font::NAME_LICENSE}
* <li>{@link Zend_Pdf_Font::NAME_LICENSE_URL}
* </ul>
*
* Note that not all names are available for all fonts. In addition, some
* fonts may contain additional names, whose indicies are in the range
* 256 to 32767 inclusive, which are used for certain font layout features.
*
* If the preferred language translation is not available, uses the first
* available translation for the name, which is usually English.
*
* If the requested name does not exist, returns null.
*
* All names are stored internally as Unicode strings, using UTF-16BE
* encoding. You may optionally supply a different resulting character set.
*
* @param integer $nameType Type of name requested.
* @param mixed $language Preferred language (string) or array of languages
* in preferred order. Use the ISO 639 standard 2-letter language codes.
* @param string $characterSet (optional) Desired resulting character set.
* You may use any character set supported by {@link iconv()};
* @return string
*/
public function getFontName($nameType, $language, $characterSet = null)
{
if (! isset($this->_fontNames[$nameType])) {
return null;
}
$name = null;
if (is_array($language)) {
foreach ($language as $code) {
if (isset($this->_fontNames[$nameType][$code])) {
$name = $this->_fontNames[$nameType][$code];
break;
}
}
} else {
if (isset($this->_fontNames[$nameType][$language])) {
$name = $this->_fontNames[$nameType][$language];
}
}
/* If the preferred language could not be found, use whatever is first.
*/
if (is_null($name)) {
$names = $this->_fontNames[$nameType];
$name = reset($names);
}
/* Convert the character set if requested.
*/
if ((! is_null($characterSet)) && ($characterSet != 'UTF-16BE') && PHP_OS != 'AIX') { // AIX knows not this charset
$name = iconv('UTF-16BE', $characterSet, $name);
}
return $name;
}
/**
* Returns whole set of font names.
*
* @return array
*/
public function getFontNames()
{
return $this->_fontNames;
}
/**
* Returns true if font is bold.
*
* @return boolean
*/
public function isBold()
{
return $this->_isBold;
}
/**
* Returns true if font is italic.
*
* @return boolean
*/
public function isItalic()
{
return $this->_isItalic;
}
/**
* Returns true if font is monospace.
*
* @return boolean
*/
public function isMonospace()
{
return $this->_isMonospace;
}
/**
* Returns the suggested position below the text baseline of the underline
* in glyph units.
*
* This value is usually negative.
*
* @return integer
*/
public function getUnderlinePosition()
{
return $this->_underlinePosition;
}
/**
* Returns the suggested line thickness of the underline in glyph units.
*
* @return integer
*/
public function getUnderlineThickness()
{
return $this->_underlineThickness;
}
/**
* Returns the suggested position above the text baseline of the
* strikethrough in glyph units.
*
* @return integer
*/
public function getStrikePosition()
{
return $this->_strikePosition;
}
/**
* Returns the suggested line thickness of the strikethrough in glyph units.
*
* @return integer
*/
public function getStrikeThickness()
{
return $this->_strikeThickness;
}
/**
* Returns the number of glyph units per em.
*
* Used to convert glyph space to user space. Frequently used in conjunction
* with {@link widthsForGlyphs()} to calculate the with of a run of text.
*
* @return integer
*/
public function getUnitsPerEm()
{
return $this->_unitsPerEm;
}
/**
* Returns the typographic ascent in font glyph units.
*
* The typographic ascent is the distance from the font's baseline to the
* top of the text frame. It is frequently used to locate the initial
* baseline for a paragraph of text inside a given rectangle.
*
* @return integer
*/
public function getAscent()
{
return $this->_ascent;
}
/**
* Returns the typographic descent in font glyph units.
*
* The typographic descent is the distance below the font's baseline to the
* bottom of the text frame. It is always negative.
*
* @return integer
*/
public function getDescent()
{
return $this->_descent;
}
/**
* Returns the typographic line gap in font glyph units.
*
* The typographic line gap is the distance between the bottom of the text
* frame of one line to the top of the text frame of the next. It is
* typically combined with the typographical ascent and descent to determine
* the font's total line height (or leading).
*
* @return integer
*/
public function getLineGap()
{
return $this->_lineGap;
}
/**
* Returns the suggested line height (or leading) in font glyph units.
*
* This value is determined by adding together the values of the typographic
* ascent, descent, and line gap. This value yields the suggested line
* spacing as determined by the font developer.
*
* It should be noted that this is only a guideline; layout engines will
* frequently modify this value to achieve special effects such as double-
* spacing.
*
* @return integer
*/
public function getLineHeight()
{
return $this->_ascent - $this->_descent + $this->_lineGap;
}
/* Information and Conversion Methods */
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
abstract public function glyphNumbersForCharacters($characterCodes);
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
abstract public function glyphNumberForCharacter($characterCode);
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
abstract public function getCoveredPercentage($string, $charEncoding = '');
/**
* Returns the widths of the glyphs.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* See also {@link widthForGlyph()}.
*
* @param array $glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
* @throws Zend_Pdf_Exception
*/
abstract public function widthsForGlyphs($glyphNumbers);
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
abstract public function widthForGlyph($glyphNumber);
/**
* Convert string to the font encoding.
*
* The method is used to prepare string for text drawing operators
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
*/
abstract public function encodeString($string, $charEncoding);
/**
* Convert string from the font encoding.
*
* The method is used to convert strings retrieved from existing content streams
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
*/
abstract public function decodeString($string, $charEncoding);
/**** Internal Methods ****/
/**
* If the font's glyph space is not 1000 units per em, converts the value.
*
* @internal
* @param integer $value
* @return integer
*/
public function toEmSpace($value)
{
if ($this->_unitsPerEm == 1000) {
return $value;
}
return ceil(($value / $this->_unitsPerEm) * 1000); // always round up
}
}

View File

@ -0,0 +1,482 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font */
require_once 'Zend/Pdf/Resource/Font.php';
/** Zend_Pdf_FileParser_Font_OpenType */
require_once 'Zend/Pdf/FileParser/Font/OpenType.php';
/** Zend_Pdf_Cmap */
require_once 'Zend/Pdf/Cmap.php';
/**
* Adobe PDF CIDFont font object implementation
*
* A CIDFont program contains glyph descriptions that are accessed using a CID as
* the character selector. There are two types of CIDFont. A Type 0 CIDFont contains
* glyph descriptions based on Adobes Type 1 font format, whereas those in a
* Type 2 CIDFont are based on the TrueType font format.
*
* A CIDFont dictionary is a PDF object that contains information about a CIDFont program.
* Although its Type value is Font, a CIDFont is not actually a font. It does not have an Encoding
* entry, it cannot be listed in the Font subdictionary of a resource dictionary, and it cannot be
* used as the operand of the Tf operator. It is used only as a descendant of a Type 0 font.
* The CMap in the Type 0 font is what defines the encoding that maps character codes to CIDs
* in the CIDFont.
*
* Font objects should be normally be obtained from the factory methods
* {@link Zend_Pdf_Font::fontWithName} and {@link Zend_Pdf_Font::fontWithPath}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource_Font_CidFont extends Zend_Pdf_Resource_Font
{
/**
* Object representing the font's cmap (character to glyph map).
* @var Zend_Pdf_Cmap
*/
protected $_cmap = null;
/**
* Array containing the widths of each character that have entries in used character map.
*
* @var array
*/
protected $_charWidths = null;
/**
* Width for characters missed in the font
*
* @var integer
*/
protected $_missingCharWidth = 0;
/**
* Object constructor
*
* @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object
* containing OpenType file.
* @param integer $embeddingOptions Options for font embedding.
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser)
{
parent::__construct();
$fontParser->parse();
/* Object properties */
$this->_fontNames = $fontParser->names;
$this->_isBold = $fontParser->isBold;
$this->_isItalic = $fontParser->isItalic;
$this->_isMonospaced = $fontParser->isMonospaced;
$this->_underlinePosition = $fontParser->underlinePosition;
$this->_underlineThickness = $fontParser->underlineThickness;
$this->_strikePosition = $fontParser->strikePosition;
$this->_strikeThickness = $fontParser->strikeThickness;
$this->_unitsPerEm = $fontParser->unitsPerEm;
$this->_ascent = $fontParser->ascent;
$this->_descent = $fontParser->descent;
$this->_lineGap = $fontParser->lineGap;
$this->_cmap = $fontParser->cmap;
/* Resource dictionary */
$baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
$this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont);
/**
* Prepare widths array.
*/
/* Constract characters widths array using font CMap and glyphs widths array */
$glyphWidths = $fontParser->glyphWidths;
$charGlyphs = $this->_cmap->getCoveredCharactersGlyphs();
$charWidths = array();
foreach ($charGlyphs as $charCode => $glyph) {
$charWidths[$charCode] = $glyphWidths[$glyph];
}
$this->_charWidths = $charWidths;
$this->_missingCharWidth = $glyphWidths[0];
/* Width array optimization. Step1: extract default value */
$widthFrequencies = array_count_values($charWidths);
$defaultWidth = null;
$defaultWidthFrequency = -1;
foreach ($widthFrequencies as $width => $frequency) {
if ($frequency > $defaultWidthFrequency) {
$defaultWidth = $width;
$defaultWidthFrequency = $frequency;
}
}
// Store default value in the font dictionary
$this->_resource->DW = new Zend_Pdf_Element_Numeric($this->toEmSpace($defaultWidth));
// Remove characters which corresponds to default width from the widths array
$defWidthChars = array_keys($charWidths, $defaultWidth);
foreach ($defWidthChars as $charCode) {
unset($charWidths[$charCode]);
}
// Order cheracter widths aray by character codes
ksort($charWidths, SORT_NUMERIC);
/* Width array optimization. Step2: Compact character codes sequences */
$lastCharCode = -1;
$widthsSequences = array();
foreach ($charWidths as $charCode => $width) {
if ($lastCharCode == -1) {
$charCodesSequense = array();
$sequenceStartCode = $charCode;
} else if ($charCode != $lastCharCode + 1) {
// New chracters sequence detected
$widthsSequences[$sequenceStartCode] = $charCodesSequense;
$charCodesSequense = array();
$sequenceStartCode = $charCode;
}
$charCodesSequense[] = $width;
$lastCharCode = $charCode;
}
// Save last sequence, if widths array is not empty (it may happens for monospaced fonts)
if (count($charWidths) != 0) {
$widthsSequences[$sequenceStartCode] = $charCodesSequense;
}
$pdfCharsWidths = array();
foreach ($widthsSequences as $startCode => $widthsSequence) {
/* Width array optimization. Step3: Compact widths sequences */
$pdfWidths = array();
$lastWidth = -1;
$widthsInSequence = 0;
foreach ($widthsSequence as $width) {
if ($lastWidth != $width) {
// New width is detected
if ($widthsInSequence != 0) {
// Previous width value was a part of the widths sequence. Save it as 'c_1st c_last w'.
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode); // First character code
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode + $widthsInSequence - 1); // Last character code
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($lastWidth)); // Width
// Reset widths sequence
$startCode = $startCode + $widthsInSequence;
$widthsInSequence = 0;
}
// Collect new width
$pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width));
$lastWidth = $width;
} else {
// Width is equal to previous
if (count($pdfWidths) != 0) {
// We already have some widths collected
// So, we've just detected new widths sequence
// Remove last element from widths list, since it's a part of widths sequence
array_pop($pdfWidths);
// and write the rest if it's not empty
if (count($pdfWidths) != 0) {
// Save it as 'c_1st [w1 w2 ... wn]'.
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode); // First character code
$pdfCharsWidths[] = new Zend_Pdf_Element_Array($pdfWidths); // Widths array
// Reset widths collection
$startCode += count($pdfWidths);
$pdfWidths = array();
}
$widthsInSequence = 2;
} else {
// Continue widths sequence
$widthsInSequence++;
}
}
}
// Check if we have widths collection or widths sequence to wite it down
if (count($pdfWidths) != 0) {
// We have some widths collected
// Save it as 'c_1st [w1 w2 ... wn]'.
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode); // First character code
$pdfCharsWidths[] = new Zend_Pdf_Element_Array($pdfWidths); // Widths array
} else if ($widthsInSequence != 0){
// We have widths sequence
// Save it as 'c_1st c_last w'.
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode); // First character code
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($startCode + $widthsInSequence - 1); // Last character code
$pdfCharsWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($lastWidth)); // Width
}
}
/* Create the Zend_Pdf_Element_Array object and add it to the font's
* object factory and resource dictionary.
*/
$widthsArrayElement = new Zend_Pdf_Element_Array($pdfCharsWidths);
$widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
$this->_resource->W = $widthsObject;
/* CIDSystemInfo dictionary */
$cidSystemInfo = new Zend_Pdf_Element_Dictionary();
$cidSystemInfo->Registry = new Zend_Pdf_Element_String('Adobe');
$cidSystemInfo->Ordering = new Zend_Pdf_Element_String('UCS');
$cidSystemInfo->Supplement = new Zend_Pdf_Element_Numeric(0);
$cidSystemInfoObject = $this->_objectFactory->newObject($cidSystemInfo);
$this->_resource->CIDSystemInfo = $cidSystemInfoObject;
}
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
public function getCoveredPercentage($string, $charEncoding = '')
{
/* Convert the string to UTF-16BE encoding so we can match the string's
* character codes to those found in the cmap.
*/
if ($charEncoding != 'UTF-16BE') {
$string = iconv($charEncoding, 'UTF-16BE', $string);
}
$charCount = iconv_strlen($string, 'UTF-16BE');
if ($charCount == 0) {
return 0;
}
/* Calculate the score by doing a lookup for each character.
*/
$score = 0;
$maxIndex = strlen($string);
for ($i = 0; $i < $maxIndex; $i++) {
/**
* @todo Properly handle characters encoded as surrogate pairs.
*/
$charCode = (ord($string[$i]) << 8) | ord($string[++$i]);
/* This could probably be optimized a bit with a binary search...
*/
if (isset($this->_charWidths[$charCode])) {
$score++;
}
}
return $score / $charCount;
}
/**
* Returns the widths of the Chars.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* See also {@link widthForChar()}.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
*/
public function widthsForChars($charCodes)
{
$widths = array();
foreach ($charCodes as $key => $charCode) {
if (!isset($this->_charWidths[$charCode])) {
$widths[$key] = $this->_missingCharWidth;
} else {
$widths[$key] = $this->_charWidths[$charCode];
}
}
return $widths;
}
/**
* Returns the width of the character.
*
* Like {@link widthsForChars()} but used for one char at a time.
*
* @param integer $charCode
* @return integer
*/
public function widthForChar($charCode)
{
if (!isset($this->_charWidths[$charCode])) {
return $this->_missingCharWidth;
}
return $this->_charWidths[$charCode];
}
/**
* Returns the widths of the glyphs.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
* @throws Zend_Pdf_Exception
*/
public function widthsForGlyphs($glyphNumbers)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
public function widthForGlyph($glyphNumber)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Convert string to the font encoding.
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
* @throws Zend_Pdf_Exception
* */
public function encodeString($string, $charEncoding)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
/**
* Convert string from the font encoding.
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
* @throws Zend_Pdf_Exception
*/
public function decodeString($string, $charEncoding)
{
/**
* CIDFont object is not actually a font. It does not have an Encoding entry,
* it cannot be listed in the Font subdictionary of a resource dictionary, and
* it cannot be used as the operand of the Tf operator.
*
* Throw an exception.
*/
throw new Zend_Pdf_Exception('CIDFont PDF objects could not be used as the operand of the text drawing operators');
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_CidFont */
require_once 'Zend/Pdf/Resource/Font/CidFont.php';
/** Zend_Pdf_Resource_Font_FontDescriptor */
require_once 'Zend/Pdf/Resource/Font/FontDescriptor.php';
/**
* Type 2 CIDFonts implementation
*
* For Type 2, the CIDFont program is actually a TrueType font program, which has
* no native notion of CIDs. In a TrueType font program, glyph descriptions are
* identified by glyph index values. Glyph indices are internal to the font and are not
* defined consistently from one font to another. Instead, a TrueType font program
* contains a 'cmap' table that provides mappings directly from character codes to
* glyph indices for one or more predefined encodings.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_CidFont_TrueType extends Zend_Pdf_Resource_Font_CidFont
{
/**
* Object constructor
*
* @todo Joing this class with Zend_Pdf_Resource_Font_Simple_Parsed_TrueType
*
* @param Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser Font parser
* object containing parsed TrueType file.
* @param integer $embeddingOptions Options for font embedding.
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser, $embeddingOptions)
{
parent::__construct($fontParser, $embeddingOptions);
$this->_fontType = Zend_Pdf_Font::TYPE_CIDFONT_TYPE_2;
$this->_resource->Subtype = new Zend_Pdf_Element_Name('CIDFontType2');
$fontDescriptor = Zend_Pdf_Resource_Font_FontDescriptor::factory($this, $fontParser, $embeddingOptions);
$this->_resource->FontDescriptor = $this->_objectFactory->newObject($fontDescriptor);
/* Prepare CIDToGIDMap */
// Initialize 128K string of null characters (65536 2 byte integers)
$cidToGidMapData = str_repeat("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 8192);
// Fill the index
$charGlyphs = $this->_cmap->getCoveredCharactersGlyphs();
foreach ($charGlyphs as $charCode => $glyph) {
$cidToGidMapData[$charCode*2 ] = chr($glyph >> 8);
$cidToGidMapData[$charCode*2 + 1] = chr($glyph & 0xFF);
}
// Store CIDToGIDMap within compressed stream object
$cidToGidMap = $this->_objectFactory->newStreamObject($cidToGidMapData);
$cidToGidMap->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
$this->_resource->CIDToGIDMap = $cidToGidMap;
}
}

View File

@ -0,0 +1,261 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font */
require_once 'Zend/Pdf/Resource/Font.php';
/** Zend_Pdf_Cmap */
require_once 'Zend/Pdf/Cmap.php';
/**
* Extracted fonts implementation
*
* Thes class allows to extract fonts already mentioned within PDF document and use them
* for text drawing.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Extracted extends Zend_Pdf_Resource_Font
{
/**
* Extracted font encoding
*
* Only 'Identity-H' and 'WinAnsiEncoding' encodings are supported now
*
* @var string
*/
protected $_encoding = null;
/**
* Object constructor
*
* $fontDictionary is a Zend_Pdf_Element_Reference or Zend_Pdf_Element_Object object
*
* @param mixed $fontDictionary
* @throws Zend_Pdf_Exception
*/
public function __construct($fontDictionary)
{
// Extract object factory and resource object from font dirctionary object
$this->_objectFactory = $fontDictionary->getFactory();
$this->_resource = $fontDictionary;
if ($fontDictionary->Encoding !== null) {
$this->_encoding = $fontDictionary->Encoding->value;
}
switch ($fontDictionary->Subtype->value) {
case 'Type0':
// Composite type 0 font
if ($fontDictionary->DescendantFonts->items->count() != 1) {
// Multiple descendant fonts are not supported
throw new Zend_Pdf_Exception('Unsupported font type.');
}
$descFontsArrayItems = $fontDictionary->DescendantFonts->items;
$descFontsArrayItems->rewind();
$descendantFont = $descFontsArrayItems->current();
$fontDescriptor = $descendantFont->FontDescriptor;
break;
case 'Type1':
if ($fontDictionary->FontDescriptor === null) {
// That's one of the standard fonts
$standardFont = Zend_Pdf_Font::fontWithName($fontDictionary->BaseFont->value);
$this->_fontNames = $standardFont->getFontNames();
$this->_isBold = $standardFont->isBold();
$this->_isItalic = $standardFont->isItalic();
$this->_isMonospace = $standardFont->isMonospace();
$this->_underlinePosition = $standardFont->getUnderlinePosition();
$this->_underlineThickness = $standardFont->getUnderlineThickness();
$this->_strikePosition = $standardFont->getStrikePosition();
$this->_strikeThickness = $standardFont->getStrikeThickness();
$this->_unitsPerEm = $standardFont->getUnitsPerEm();
$this->_ascent = $standardFont->getAscent();
$this->_descent = $standardFont->getDescent();
$this->_lineGap = $standardFont->getLineGap();
return;
}
$fontDescriptor = $fontDictionary->FontDescriptor;
break;
case 'TrueType':
$fontDescriptor = $fontDictionary->FontDescriptor;
break;
default:
throw new Zend_Pdf_Exception('Unsupported font type.');
}
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] = iconv('UTF-8', 'UTF-16BE', $fontDictionary->BaseFont->value);
$this->_isBold = false; // this property is actually not used anywhere
$this->_isItalic = ( ($fontDescriptor->Flags->value & (1 << 6)) != 0 ); // Bit-7 is set
$this->_isMonospace = ( ($fontDescriptor->Flags->value & (1 << 0)) != 0 ); // Bit-1 is set
$this->_underlinePosition = null; // Can't be extracted
$this->_underlineThickness = null; // Can't be extracted
$this->_strikePosition = null; // Can't be extracted
$this->_strikeThickness = null; // Can't be extracted
$this->_unitsPerEm = null; // Can't be extracted
$this->_ascent = $fontDescriptor->Ascent->value;
$this->_descent = $fontDescriptor->Descent->value;
$this->_lineGap = null; // Can't be extracted
}
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
throw new Zend_Pdf_Exception('Operation is not supported for extracted fonts');
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
throw new Zend_Pdf_Exception('Operation is not supported for extracted fonts');
}
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
public function getCoveredPercentage($string, $charEncoding = '')
{
throw new Zend_Pdf_Exception('Operation is not supported for extracted fonts');
}
/**
* Returns the widths of the glyphs.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* See also {@link widthForGlyph()}.
*
* @param array $glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
* @throws Zend_Pdf_Exception
*/
public function widthsForGlyphs($glyphNumbers)
{
throw new Zend_Pdf_Exception('Operation is not supported for extracted fonts');
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
public function widthForGlyph($glyphNumber)
{
throw new Zend_Pdf_Exception('Operation is not supported for extracted fonts');
}
/**
* Convert string to the font encoding.
*
* The method is used to prepare string for text drawing operators
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
*/
public function encodeString($string, $charEncoding)
{
if ($this->_encoding == 'Identity-H') {
return iconv($charEncoding, 'UTF-16BE', $string);
}
if ($this->_encoding == 'WinAnsiEncoding') {
return iconv($charEncoding, 'CP1252//IGNORE', $string);
}
throw new Zend_Pdf_Exception('Fonf encoding is not supported');
}
/**
* Convert string from the font encoding.
*
* The method is used to convert strings retrieved from existing content streams
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
*/
public function decodeString($string, $charEncoding)
{
if ($this->_encoding == 'Identity-H') {
return iconv('UTF-16BE', $charEncoding, $string);
}
if ($this->_encoding == 'WinAnsiEncoding') {
return iconv('CP1252', $charEncoding, $string);
}
throw new Zend_Pdf_Exception('Fonf encoding is not supported');
}
}

View File

@ -0,0 +1,199 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Font */
require_once 'Zend/Pdf/Font.php';
/** Zend_Pdf_Resource_Font */
require_once 'Zend/Pdf/Resource/Font.php';
/** Zend_Pdf_FileParser_Font_OpenType */
require_once 'Zend/Pdf/FileParser/Font/OpenType.php';
/**
* FontDescriptor implementation
*
* A font descriptor specifies metrics and other attributes of a simple font or a
* CIDFont as a whole, as distinct from the metrics of individual glyphs. These font
* metrics provide information that enables a viewer application to synthesize a
* substitute font or select a similar font when the font program is unavailable. The
* font descriptor may also be used to embed the font program in the PDF file.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_FontDescriptor
{
/**
* Object constructor
* @throws Zend_Pdf_Exception
*/
public function __construct()
{
throw new Zend_Pdf_Exception('Zend_Pdf_Resource_Font_FontDescriptor is not intended to be instantiated');
}
/**
* Object constructor
*
* The $embeddingOptions parameter allows you to set certain flags related
* to font embedding. You may combine options by OR-ing them together. See
* the EMBED_ constants defined in {@link Zend_Pdf_Font} for the list of
* available options and their descriptions.
*
* Note that it is not requried that fonts be embedded within the PDF file
* to use them. If the recipient of the PDF has the font installed on their
* computer, they will see the correct fonts in the document. If they don't,
* the PDF viewer will substitute or synthesize a replacement.
*
*
* @param Zend_Pdf_Resource_Font $font Font
* @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing parsed TrueType file.
* @param integer $embeddingOptions Options for font embedding.
* @return Zend_Pdf_Element_Dictionary
* @throws Zend_Pdf_Exception
*/
static public function factory(Zend_Pdf_Resource_Font $font, Zend_Pdf_FileParser_Font_OpenType $fontParser, $embeddingOptions)
{
/* The font descriptor object contains the rest of the font metrics and
* the information about the embedded font program (if applicible).
*/
$fontDescriptor = new Zend_Pdf_Element_Dictionary();
$fontDescriptor->Type = new Zend_Pdf_Element_Name('FontDescriptor');
$fontDescriptor->FontName = new Zend_Pdf_Element_Name($font->getResource()->BaseFont->value);
/* The font flags value is a bitfield that describes the stylistic
* attributes of the font. We will set as many of the bits as can be
* determined from the font parser.
*/
$flags = 0;
if ($fontParser->isMonospaced) { // bit 1: FixedPitch
$flags |= 1 << 0;
}
if ($fontParser->isSerifFont) { // bit 2: Serif
$flags |= 1 << 1;
}
if (! $fontParser->isAdobeLatinSubset) { // bit 3: Symbolic
$flags |= 1 << 2;
}
if ($fontParser->isScriptFont) { // bit 4: Script
$flags |= 1 << 3;
}
if ($fontParser->isAdobeLatinSubset) { // bit 6: Nonsymbolic
$flags |= 1 << 5;
}
if ($fontParser->isItalic) { // bit 7: Italic
$flags |= 1 << 6;
}
// bits 17-19: AllCap, SmallCap, ForceBold; not available
$fontDescriptor->Flags = new Zend_Pdf_Element_Numeric($flags);
$fontBBox = array(new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->xMin)),
new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->yMin)),
new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->xMax)),
new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->yMax)));
$fontDescriptor->FontBBox = new Zend_Pdf_Element_Array($fontBBox);
$fontDescriptor->ItalicAngle = new Zend_Pdf_Element_Numeric($fontParser->italicAngle);
$fontDescriptor->Ascent = new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->ascent));
$fontDescriptor->Descent = new Zend_Pdf_Element_Numeric($font->toEmSpace($fontParser->descent));
$fontDescriptor->CapHeight = new Zend_Pdf_Element_Numeric($fontParser->capitalHeight);
/**
* The vertical stem width is not yet extracted from the OpenType font
* file. For now, record zero which is interpreted as 'unknown'.
* @todo Calculate value for StemV.
*/
$fontDescriptor->StemV = new Zend_Pdf_Element_Numeric(0);
$fontDescriptor->MissingWidth = new Zend_Pdf_Element_Numeric($fontParser->glyphWidths[0]);
/* Set up font embedding. This is where the actual font program itself
* is embedded within the PDF document.
*
* Note that it is not requried that fonts be embedded within the PDF
* document to use them. If the recipient of the PDF has the font
* installed on their computer, they will see the correct fonts in the
* document. If they don't, the PDF viewer will substitute or synthesize
* a replacement.
*
* There are several guidelines for font embedding:
*
* First, the developer might specifically request not to embed the font.
*/
if (!($embeddingOptions & Zend_Pdf_Font::EMBED_DONT_EMBED)) {
/* Second, the font author may have set copyright bits that prohibit
* the font program from being embedded. Yes this is controversial,
* but it's the rules:
* http://partners.adobe.com/public/developer/en/acrobat/sdk/FontPolicies.pdf
*
* To keep the developer in the loop, and to prevent surprising bug
* reports of "your PDF doesn't have the right fonts," throw an
* exception if the font cannot be embedded.
*/
if (! $fontParser->isEmbeddable) {
/* This exception may be suppressed if the developer decides that
* it's not a big deal that the font program can't be embedded.
*/
if (!($embeddingOptions & Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION)) {
$message = 'This font cannot be embedded in the PDF document. If you would like to use '
. 'it anyway, you must pass Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION '
. 'in the $options parameter of the font constructor.';
throw new Zend_Pdf_Exception($message, Zend_Pdf_Exception::FONT_CANT_BE_EMBEDDED);
}
} else {
/* Otherwise, the default behavior is to embed all custom fonts.
*/
/* This section will change soon to a stream object data
* provider model so that we don't have to keep a copy of the
* entire font in memory.
*
* We also cannot build font subsetting until the data provider
* model is in place.
*/
$fontFile = $fontParser->getDataSource()->readAllBytes();
$fontFileObject = $font->getFactory()->newStreamObject($fontFile);
$fontFileObject->dictionary->Length1 = new Zend_Pdf_Element_Numeric(strlen($fontFile));
if (!($embeddingOptions & Zend_Pdf_Font::EMBED_DONT_COMPRESS)) {
/* Compress the font file using Flate. This generally cuts file
* sizes by about half!
*/
$fontFileObject->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
}
if ($fontParser instanceof Zend_Pdf_FileParser_Font_OpenType_Type1 /* not implemented now */) {
$fontDescriptor->FontFile = $fontFileObject;
} else if ($fontParser instanceof Zend_Pdf_FileParser_Font_OpenType_TrueType) {
$fontDescriptor->FontFile2 = $fontFileObject;
} else {
$fontDescriptor->FontFile3 = $fontFileObject;
}
}
}
return $fontDescriptor;
}
}

View File

@ -0,0 +1,281 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font */
require_once 'Zend/Pdf/Resource/Font.php';
/** Zend_Pdf_Cmap */
require_once 'Zend/Pdf/Cmap.php';
/**
* Adobe PDF Simple fonts implementation
*
* PDF simple fonts functionality is presented by Adobe Type 1
* (including standard PDF Type1 built-in fonts) and TrueType fonts support.
*
* Both fonts have the following properties:
* - Glyphs in the font are selected by single-byte character codes obtained from a
* string that is shown by the text-showing operators. Logically, these codes index
* into a table of 256 glyphs; the mapping from codes to glyphs is called the fonts
* encoding.
* PDF specification provides a possibility to specify any user defined encoding in addition
* to the standard built-in encodings: Standard-Encoding, MacRomanEncoding, WinAnsiEncoding,
* and PDFDocEncoding, but Zend_Pdf simple fonts implementation operates only with
* Windows ANSI encoding (except Symbol and ZapfDingbats built-in fonts).
*
* - Each glyph has a single set of metrics, including a horizontal displacement or
* width. That is, simple fonts support only horizontal writing mode.
*
*
* The code in this class is common to both types. However, you will only deal
* directly with subclasses.
*
* Font objects should be normally be obtained from the factory methods
* {@link Zend_Pdf_Font::fontWithName} and {@link Zend_Pdf_Font::fontWithPath}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource_Font_Simple extends Zend_Pdf_Resource_Font
{
/**
* Object representing the font's cmap (character to glyph map).
* @var Zend_Pdf_Cmap
*/
protected $_cmap = null;
/**
* Array containing the widths of each of the glyphs contained in the font.
*
* Keys are integers starting from 0, which coresponds to Zend_Pdf_Cmap::MISSING_CHARACTER_GLYPH.
*
* Font character map may contain gaps for actually used glyphs, nevertheless glyphWidths array
* contains widths for all glyphs even they are unused.
*
* @var array
*/
protected $_glyphWidths = null;
/**
* Width for glyphs missed in the font
*
* Note: Adobe PDF specfication (V1.4 - V1.6) doesn't define behavior for rendering
* characters missed in the standard PDF fonts (such us 0x7F (DEL) Windows ANSI code)
* Adobe Font Metrics files doesn't also define metrics for "missed glyph".
* We provide character width as "0" for this case, but actually it depends on PDF viewer
* implementation.
*
* @var integer
*/
protected $_missingGlyphWidth = 0;
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*
*/
public function __construct()
{
parent::__construct();
/**
* @todo
* It's easy to add other encodings support now (Standard-Encoding, MacRomanEncoding,
* PDFDocEncoding, MacExpertEncoding, Symbol, and ZapfDingbats).
* Steps for the implementation:
* - completely describe all PDF single byte encodings in the documentation
* - implement non-WinAnsi encodings processing into encodeString()/decodeString() methods
*
* These encodings will be automatically supported for standard builtin PDF fonts as well
* as for external fonts.
*/
$this->_resource->Encoding = new Zend_Pdf_Element_Name('WinAnsiEncoding');
}
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
return $this->_cmap->glyphNumbersForCharacters($characterCodes);
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* If a particular character doesn't exist in this font, the special 'missing
* character glyph' will be substituted.
*
* See also {@link glyphNumbersForCharacters()} which is optimized for bulk
* operations.
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
return $this->_cmap->glyphNumberForCharacter($characterCode);
}
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
public function getCoveredPercentage($string, $charEncoding = '')
{
/* Convert the string to UTF-16BE encoding so we can match the string's
* character codes to those found in the cmap.
*/
if ($charEncoding != 'UTF-16BE') {
if (PHP_OS != 'AIX') { // AIX doesnt know what UTF-16BE is
$string = iconv($charEncoding, 'UTF-16BE', $string);
}
}
$charCount = (PHP_OS != 'AIX') ? iconv_strlen($string, 'UTF-16BE') : strlen($string);
if ($charCount == 0) {
return 0;
}
/* Fetch the covered character code list from the font's cmap.
*/
$coveredCharacters = $this->_cmap->getCoveredCharacters();
/* Calculate the score by doing a lookup for each character.
*/
$score = 0;
$maxIndex = strlen($string);
for ($i = 0; $i < $maxIndex; $i++) {
/**
* @todo Properly handle characters encoded as surrogate pairs.
*/
$charCode = (ord($string[$i]) << 8) | ord($string[++$i]);
/* This could probably be optimized a bit with a binary search...
*/
if (in_array($charCode, $coveredCharacters)) {
$score++;
}
}
return $score / $charCount;
}
/**
* Returns the widths of the glyphs.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* See also {@link widthForGlyph()}.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
*/
public function widthsForGlyphs($glyphNumbers)
{
$widths = array();
foreach ($glyphNumbers as $key => $glyphNumber) {
if (!isset($this->_glyphWidths[$glyphNumber])) {
$widths[$key] = $this->_missingGlyphWidth;
} else {
$widths[$key] = $this->_glyphWidths[$glyphNumber];
}
}
return $widths;
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
*/
public function widthForGlyph($glyphNumber)
{
if (!isset($this->_glyphWidths[$glyphNumber])) {
return $this->_missingGlyphWidth;
}
return $this->_glyphWidths[$glyphNumber];
}
/**
* Convert string to the font encoding.
*
* The method is used to prepare string for text drawing operators
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
*/
public function encodeString($string, $charEncoding)
{
if (PHP_OS == 'AIX') {
return $string; // returning here b/c AIX doesnt know what CP1252 is
}
return iconv($charEncoding, 'CP1252//IGNORE', $string);
}
/**
* Convert string from the font encoding.
*
* The method is used to convert strings retrieved from existing content streams
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
*/
public function decodeString($string, $charEncoding)
{
return iconv('CP1252', $charEncoding, $string);
}
}

View File

@ -0,0 +1,101 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple */
require_once 'Zend/Pdf/Resource/Font/Simple.php';
/** Zend_Pdf_FileParser_Font_OpenType */
require_once 'Zend/Pdf/FileParser/Font/OpenType.php';
/**
* Parsed and (optionaly) embedded fonts implementation
*
* OpenType fonts can contain either TrueType or PostScript Type 1 outlines.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource_Font_Simple_Parsed extends Zend_Pdf_Resource_Font_Simple
{
/**
* Object constructor
*
* @param Zend_Pdf_FileParser_Font_OpenType $fontParser Font parser object containing OpenType file.
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParser_Font_OpenType $fontParser)
{
parent::__construct();
$fontParser->parse();
/* Object properties */
$this->_fontNames = $fontParser->names;
$this->_isBold = $fontParser->isBold;
$this->_isItalic = $fontParser->isItalic;
$this->_isMonospaced = $fontParser->isMonospaced;
$this->_underlinePosition = $fontParser->underlinePosition;
$this->_underlineThickness = $fontParser->underlineThickness;
$this->_strikePosition = $fontParser->strikePosition;
$this->_strikeThickness = $fontParser->strikeThickness;
$this->_unitsPerEm = $fontParser->unitsPerEm;
$this->_ascent = $fontParser->ascent;
$this->_descent = $fontParser->descent;
$this->_lineGap = $fontParser->lineGap;
$this->_glyphWidths = $fontParser->glyphWidths;
$this->_missingGlyphWidth = $this->_glyphWidths[0];
$this->_cmap = $fontParser->cmap;
/* Resource dictionary */
$baseFont = $this->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT, 'en', 'UTF-8');
$this->_resource->BaseFont = new Zend_Pdf_Element_Name($baseFont);
$this->_resource->FirstChar = new Zend_Pdf_Element_Numeric(0);
$this->_resource->LastChar = new Zend_Pdf_Element_Numeric(count($this->_glyphWidths) - 1);
/* Now convert the scalar glyph widths to Zend_Pdf_Element_Numeric objects.
*/
$pdfWidths = array();
foreach ($this->_glyphWidths as $width) {
$pdfWidths[] = new Zend_Pdf_Element_Numeric($this->toEmSpace($width));
}
/* Create the Zend_Pdf_Element_Array object and add it to the font's
* object factory and resource dictionary.
*/
$widthsArrayElement = new Zend_Pdf_Element_Array($pdfWidths);
$widthsObject = $this->_objectFactory->newObject($widthsArrayElement);
$this->_resource->Widths = $widthsObject;
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Parsed */
require_once 'Zend/Pdf/Resource/Font/Simple/Parsed.php';
/** Zend_Pdf_Resource_Font_FontDescriptor */
require_once 'Zend/Pdf/Resource/Font/FontDescriptor.php';
/**
* TrueType fonts implementation
*
* Font objects should be normally be obtained from the factory methods
* {@link Zend_Pdf_Font::fontWithName} and {@link Zend_Pdf_Font::fontWithPath}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Parsed_TrueType extends Zend_Pdf_Resource_Font_Simple_Parsed
{
/**
* Object constructor
*
* @param Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser Font parser
* object containing parsed TrueType file.
* @param integer $embeddingOptions Options for font embedding.
* @throws Zend_Pdf_Exception
*/
public function __construct(Zend_Pdf_FileParser_Font_OpenType_TrueType $fontParser, $embeddingOptions)
{
parent::__construct($fontParser, $embeddingOptions);
$this->_fontType = Zend_Pdf_Font::TYPE_TRUETYPE;
$this->_resource->Subtype = new Zend_Pdf_Element_Name('TrueType');
$fontDescriptor = Zend_Pdf_Resource_Font_FontDescriptor::factory($this, $fontParser, $embeddingOptions);
$this->_resource->FontDescriptor = $this->_objectFactory->newObject($fontDescriptor);
}
}

View File

@ -0,0 +1,77 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple */
require_once 'Zend/Pdf/Resource/Font/Simple.php';
/**
* Abstract class definition for the standard 14 Type 1 PDF fonts.
*
* The standard 14 PDF fonts are guaranteed to be availble in any PDF viewer
* implementation. As such, they do not require much data for the font's
* resource dictionary. The majority of the data provided by subclasses is for
* the benefit of our own layout code.
*
* The standard fonts and the corresponding subclasses that manage them:
* <ul>
* <li>Courier - {@link Zend_Pdf_Resource_Font_Simple_Standard_Courier}
* <li>Courier-Bold - {@link Zend_Pdf_Resource_Font_Simple_Standard_CourierBold}
* <li>Courier-Oblique - {@link Zend_Pdf_Resource_Font_Simple_Standard_CourierOblique}
* <li>Courier-BoldOblique - {@link Zend_Pdf_Resource_Font_Simple_Standard_CourierBoldOblique}
* <li>Helvetica - {@link Zend_Pdf_Resource_Font_Simple_Standard_Helvetica}
* <li>Helvetica-Bold - {@link Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBold}
* <li>Helvetica-Oblique - {@link Zend_Pdf_Resource_Font_Simple_Standard_HelveticaOblique}
* <li>Helvetica-BoldOblique - {@link Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBoldOblique}
* <li>Symbol - {@link Zend_Pdf_Resource_Font_Simple_Standard_Symbol}
* <li>Times - {@link Zend_Pdf_Resource_Font_Simple_Standard_Times}
* <li>Times-Bold - {@link Zend_Pdf_Resource_Font_Simple_Standard_TimesBold}
* <li>Times-Italic - {@link Zend_Pdf_Resource_Font_Simple_Standard_TimesItalic}
* <li>Times-BoldItalic - {@link Zend_Pdf_Resource_Font_Simple_Standard_TimesBoldItalic}
* <li>ZapfDingbats - {@link Zend_Pdf_Resource_Font_Simple_Standard_ZapfDingbats}
* </ul>
*
* Font objects should be normally be obtained from the factory methods
* {@link Zend_Pdf_Font::fontWithName} and {@link Zend_Pdf_Font::fontWithPath}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource_Font_Simple_Standard extends Zend_Pdf_Resource_Font_Simple
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
$this->_fontType = Zend_Pdf_Font::TYPE_STANDARD;
parent::__construct();
$this->_resource->Subtype = new Zend_Pdf_Element_Name('Type1');
}
}

View File

@ -0,0 +1,289 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Courier.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_Courier extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x39\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x30\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x31\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x32\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x37\x00"
. "\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00\x20\x00\x53\x00"
. "\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00\x20\x00\x49\x00"
. "\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00\x41\x00\x6c\x00"
. "\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00\x73\x00"
. "\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00\x65\x00"
. "\x64\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x35\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x20\x00"
. "\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x33\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72";
$this->_isBold = false;
$this->_isItalic = false;
$this->_isMonospaced = true;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 629;
$this->_descent = -157;
$this->_lineGap = 414;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0258, 0x02 => 0x0258, 0x03 => 0x0258,
0x04 => 0x0258, 0x05 => 0x0258, 0x06 => 0x0258, 0x07 => 0x0258,
0x08 => 0x0258, 0x09 => 0x0258, 0x0a => 0x0258, 0x0b => 0x0258,
0x0c => 0x0258, 0x0d => 0x0258, 0x0e => 0x0258, 0x0f => 0x0258,
0x10 => 0x0258, 0x11 => 0x0258, 0x12 => 0x0258, 0x13 => 0x0258,
0x14 => 0x0258, 0x15 => 0x0258, 0x16 => 0x0258, 0x17 => 0x0258,
0x18 => 0x0258, 0x19 => 0x0258, 0x1a => 0x0258, 0x1b => 0x0258,
0x1c => 0x0258, 0x1d => 0x0258, 0x1e => 0x0258, 0x1f => 0x0258,
0x20 => 0x0258, 0x21 => 0x0258, 0x22 => 0x0258, 0x23 => 0x0258,
0x24 => 0x0258, 0x25 => 0x0258, 0x26 => 0x0258, 0x27 => 0x0258,
0x28 => 0x0258, 0x29 => 0x0258, 0x2a => 0x0258, 0x2b => 0x0258,
0x2c => 0x0258, 0x2d => 0x0258, 0x2e => 0x0258, 0x2f => 0x0258,
0x30 => 0x0258, 0x31 => 0x0258, 0x32 => 0x0258, 0x33 => 0x0258,
0x34 => 0x0258, 0x35 => 0x0258, 0x36 => 0x0258, 0x37 => 0x0258,
0x38 => 0x0258, 0x39 => 0x0258, 0x3a => 0x0258, 0x3b => 0x0258,
0x3c => 0x0258, 0x3d => 0x0258, 0x3e => 0x0258, 0x3f => 0x0258,
0x40 => 0x0258, 0x41 => 0x0258, 0x42 => 0x0258, 0x43 => 0x0258,
0x44 => 0x0258, 0x45 => 0x0258, 0x46 => 0x0258, 0x47 => 0x0258,
0x48 => 0x0258, 0x49 => 0x0258, 0x4a => 0x0258, 0x4b => 0x0258,
0x4c => 0x0258, 0x4d => 0x0258, 0x4e => 0x0258, 0x4f => 0x0258,
0x50 => 0x0258, 0x51 => 0x0258, 0x52 => 0x0258, 0x53 => 0x0258,
0x54 => 0x0258, 0x55 => 0x0258, 0x56 => 0x0258, 0x57 => 0x0258,
0x58 => 0x0258, 0x59 => 0x0258, 0x5a => 0x0258, 0x5b => 0x0258,
0x5c => 0x0258, 0x5d => 0x0258, 0x5e => 0x0258, 0x5f => 0x0258,
0x60 => 0x0258, 0x61 => 0x0258, 0x62 => 0x0258, 0x63 => 0x0258,
0x64 => 0x0258, 0x65 => 0x0258, 0x66 => 0x0258, 0x67 => 0x0258,
0x68 => 0x0258, 0x69 => 0x0258, 0x6a => 0x0258, 0x6b => 0x0258,
0x6c => 0x0258, 0x6d => 0x0258, 0x6e => 0x0258, 0x6f => 0x0258,
0x70 => 0x0258, 0x71 => 0x0258, 0x72 => 0x0258, 0x73 => 0x0258,
0x74 => 0x0258, 0x75 => 0x0258, 0x76 => 0x0258, 0x77 => 0x0258,
0x78 => 0x0258, 0x79 => 0x0258, 0x7a => 0x0258, 0x7b => 0x0258,
0x7c => 0x0258, 0x7d => 0x0258, 0x7e => 0x0258, 0x7f => 0x0258,
0x80 => 0x0258, 0x81 => 0x0258, 0x82 => 0x0258, 0x83 => 0x0258,
0x84 => 0x0258, 0x85 => 0x0258, 0x86 => 0x0258, 0x87 => 0x0258,
0x88 => 0x0258, 0x89 => 0x0258, 0x8a => 0x0258, 0x8b => 0x0258,
0x8c => 0x0258, 0x8d => 0x0258, 0x8e => 0x0258, 0x8f => 0x0258,
0x90 => 0x0258, 0x91 => 0x0258, 0x92 => 0x0258, 0x93 => 0x0258,
0x94 => 0x0258, 0x95 => 0x0258, 0x96 => 0x0258, 0x97 => 0x0258,
0x98 => 0x0258, 0x99 => 0x0258, 0x9a => 0x0258, 0x9b => 0x0258,
0x9c => 0x0258, 0x9d => 0x0258, 0x9e => 0x0258, 0x9f => 0x0258,
0xa0 => 0x0258, 0xa1 => 0x0258, 0xa2 => 0x0258, 0xa3 => 0x0258,
0xa4 => 0x0258, 0xa5 => 0x0258, 0xa6 => 0x0258, 0xa7 => 0x0258,
0xa8 => 0x0258, 0xa9 => 0x0258, 0xaa => 0x0258, 0xab => 0x0258,
0xac => 0x0258, 0xad => 0x0258, 0xae => 0x0258, 0xaf => 0x0258,
0xb0 => 0x0258, 0xb1 => 0x0258, 0xb2 => 0x0258, 0xb3 => 0x0258,
0xb4 => 0x0258, 0xb5 => 0x0258, 0xb6 => 0x0258, 0xb7 => 0x0258,
0xb8 => 0x0258, 0xb9 => 0x0258, 0xba => 0x0258, 0xbb => 0x0258,
0xbc => 0x0258, 0xbd => 0x0258, 0xbe => 0x0258, 0xbf => 0x0258,
0xc0 => 0x0258, 0xc1 => 0x0258, 0xc2 => 0x0258, 0xc3 => 0x0258,
0xc4 => 0x0258, 0xc5 => 0x0258, 0xc6 => 0x0258, 0xc7 => 0x0258,
0xc8 => 0x0258, 0xc9 => 0x0258, 0xca => 0x0258, 0xcb => 0x0258,
0xcc => 0x0258, 0xcd => 0x0258, 0xce => 0x0258, 0xcf => 0x0258,
0xd0 => 0x0258, 0xd1 => 0x0258, 0xd2 => 0x0258, 0xd3 => 0x0258,
0xd4 => 0x0258, 0xd5 => 0x0258, 0xd6 => 0x0258, 0xd7 => 0x0258,
0xd8 => 0x0258, 0xd9 => 0x0258, 0xda => 0x0258, 0xdb => 0x0258,
0xdc => 0x0258, 0xdd => 0x0258, 0xde => 0x0258, 0xdf => 0x0258,
0xe0 => 0x0258, 0xe1 => 0x0258, 0xe2 => 0x0258, 0xe3 => 0x0258,
0xe4 => 0x0258, 0xe5 => 0x0258, 0xe6 => 0x0258, 0xe7 => 0x0258,
0xe8 => 0x0258, 0xe9 => 0x0258, 0xea => 0x0258, 0xeb => 0x0258,
0xec => 0x0258, 0xed => 0x0258, 0xee => 0x0258, 0xef => 0x0258,
0xf0 => 0x0258, 0xf1 => 0x0258, 0xf2 => 0x0258, 0xf3 => 0x0258,
0xf4 => 0x0258, 0xf5 => 0x0258, 0xf6 => 0x0258, 0xf7 => 0x0258,
0xf8 => 0x0258, 0xf9 => 0x0258, 0xfa => 0x0258, 0xfb => 0x0258,
0xfc => 0x0258, 0xfd => 0x0258, 0xfe => 0x0258, 0xff => 0x0258,
0x0100 => 0x0258, 0x0101 => 0x0258, 0x0102 => 0x0258, 0x0103 => 0x0258,
0x0104 => 0x0258, 0x0105 => 0x0258, 0x0106 => 0x0258, 0x0107 => 0x0258,
0x0108 => 0x0258, 0x0109 => 0x0258, 0x010a => 0x0258, 0x010b => 0x0258,
0x010c => 0x0258, 0x010d => 0x0258, 0x010e => 0x0258, 0x010f => 0x0258,
0x0110 => 0x0258, 0x0111 => 0x0258, 0x0112 => 0x0258, 0x0113 => 0x0258,
0x0114 => 0x0258, 0x0115 => 0x0258, 0x0116 => 0x0258, 0x0117 => 0x0258,
0x0118 => 0x0258, 0x0119 => 0x0258, 0x011a => 0x0258, 0x011b => 0x0258,
0x011c => 0x0258, 0x011d => 0x0258, 0x011e => 0x0258, 0x011f => 0x0258,
0x0120 => 0x0258, 0x0121 => 0x0258, 0x0122 => 0x0258, 0x0123 => 0x0258,
0x0124 => 0x0258, 0x0125 => 0x0258, 0x0126 => 0x0258, 0x0127 => 0x0258,
0x0128 => 0x0258, 0x0129 => 0x0258, 0x012a => 0x0258, 0x012b => 0x0258,
0x012c => 0x0258, 0x012d => 0x0258, 0x012e => 0x0258, 0x012f => 0x0258,
0x0130 => 0x0258, 0x0131 => 0x0258, 0x0132 => 0x0258, 0x0133 => 0x0258,
0x0134 => 0x0258, 0x0135 => 0x0258, 0x0136 => 0x0258, 0x0137 => 0x0258,
0x0138 => 0x0258, 0x0139 => 0x0258, 0x013a => 0x0258, 0x013b => 0x0258,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Courier');
}
}

View File

@ -0,0 +1,290 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Courier-Bold.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_CourierBold extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x39\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x30\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x31\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00"
. "\x41\x00\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00"
. "\x76\x00\x65\x00\x64\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x34\x00\x38";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x2d\x00"
. "\x42\x00\x6f\x00\x6c\x00\x64\x00\x20\x00\x42\x00\x6f\x00\x6c\x00"
. "\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x33\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x2d\x00"
. "\x42\x00\x6f\x00\x6c\x00\x64";
$this->_isBold = true;
$this->_isItalic = false;
$this->_isMonospaced = true;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 629;
$this->_descent = -157;
$this->_lineGap = 414;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0258, 0x02 => 0x0258, 0x03 => 0x0258,
0x04 => 0x0258, 0x05 => 0x0258, 0x06 => 0x0258, 0x07 => 0x0258,
0x08 => 0x0258, 0x09 => 0x0258, 0x0a => 0x0258, 0x0b => 0x0258,
0x0c => 0x0258, 0x0d => 0x0258, 0x0e => 0x0258, 0x0f => 0x0258,
0x10 => 0x0258, 0x11 => 0x0258, 0x12 => 0x0258, 0x13 => 0x0258,
0x14 => 0x0258, 0x15 => 0x0258, 0x16 => 0x0258, 0x17 => 0x0258,
0x18 => 0x0258, 0x19 => 0x0258, 0x1a => 0x0258, 0x1b => 0x0258,
0x1c => 0x0258, 0x1d => 0x0258, 0x1e => 0x0258, 0x1f => 0x0258,
0x20 => 0x0258, 0x21 => 0x0258, 0x22 => 0x0258, 0x23 => 0x0258,
0x24 => 0x0258, 0x25 => 0x0258, 0x26 => 0x0258, 0x27 => 0x0258,
0x28 => 0x0258, 0x29 => 0x0258, 0x2a => 0x0258, 0x2b => 0x0258,
0x2c => 0x0258, 0x2d => 0x0258, 0x2e => 0x0258, 0x2f => 0x0258,
0x30 => 0x0258, 0x31 => 0x0258, 0x32 => 0x0258, 0x33 => 0x0258,
0x34 => 0x0258, 0x35 => 0x0258, 0x36 => 0x0258, 0x37 => 0x0258,
0x38 => 0x0258, 0x39 => 0x0258, 0x3a => 0x0258, 0x3b => 0x0258,
0x3c => 0x0258, 0x3d => 0x0258, 0x3e => 0x0258, 0x3f => 0x0258,
0x40 => 0x0258, 0x41 => 0x0258, 0x42 => 0x0258, 0x43 => 0x0258,
0x44 => 0x0258, 0x45 => 0x0258, 0x46 => 0x0258, 0x47 => 0x0258,
0x48 => 0x0258, 0x49 => 0x0258, 0x4a => 0x0258, 0x4b => 0x0258,
0x4c => 0x0258, 0x4d => 0x0258, 0x4e => 0x0258, 0x4f => 0x0258,
0x50 => 0x0258, 0x51 => 0x0258, 0x52 => 0x0258, 0x53 => 0x0258,
0x54 => 0x0258, 0x55 => 0x0258, 0x56 => 0x0258, 0x57 => 0x0258,
0x58 => 0x0258, 0x59 => 0x0258, 0x5a => 0x0258, 0x5b => 0x0258,
0x5c => 0x0258, 0x5d => 0x0258, 0x5e => 0x0258, 0x5f => 0x0258,
0x60 => 0x0258, 0x61 => 0x0258, 0x62 => 0x0258, 0x63 => 0x0258,
0x64 => 0x0258, 0x65 => 0x0258, 0x66 => 0x0258, 0x67 => 0x0258,
0x68 => 0x0258, 0x69 => 0x0258, 0x6a => 0x0258, 0x6b => 0x0258,
0x6c => 0x0258, 0x6d => 0x0258, 0x6e => 0x0258, 0x6f => 0x0258,
0x70 => 0x0258, 0x71 => 0x0258, 0x72 => 0x0258, 0x73 => 0x0258,
0x74 => 0x0258, 0x75 => 0x0258, 0x76 => 0x0258, 0x77 => 0x0258,
0x78 => 0x0258, 0x79 => 0x0258, 0x7a => 0x0258, 0x7b => 0x0258,
0x7c => 0x0258, 0x7d => 0x0258, 0x7e => 0x0258, 0x7f => 0x0258,
0x80 => 0x0258, 0x81 => 0x0258, 0x82 => 0x0258, 0x83 => 0x0258,
0x84 => 0x0258, 0x85 => 0x0258, 0x86 => 0x0258, 0x87 => 0x0258,
0x88 => 0x0258, 0x89 => 0x0258, 0x8a => 0x0258, 0x8b => 0x0258,
0x8c => 0x0258, 0x8d => 0x0258, 0x8e => 0x0258, 0x8f => 0x0258,
0x90 => 0x0258, 0x91 => 0x0258, 0x92 => 0x0258, 0x93 => 0x0258,
0x94 => 0x0258, 0x95 => 0x0258, 0x96 => 0x0258, 0x97 => 0x0258,
0x98 => 0x0258, 0x99 => 0x0258, 0x9a => 0x0258, 0x9b => 0x0258,
0x9c => 0x0258, 0x9d => 0x0258, 0x9e => 0x0258, 0x9f => 0x0258,
0xa0 => 0x0258, 0xa1 => 0x0258, 0xa2 => 0x0258, 0xa3 => 0x0258,
0xa4 => 0x0258, 0xa5 => 0x0258, 0xa6 => 0x0258, 0xa7 => 0x0258,
0xa8 => 0x0258, 0xa9 => 0x0258, 0xaa => 0x0258, 0xab => 0x0258,
0xac => 0x0258, 0xad => 0x0258, 0xae => 0x0258, 0xaf => 0x0258,
0xb0 => 0x0258, 0xb1 => 0x0258, 0xb2 => 0x0258, 0xb3 => 0x0258,
0xb4 => 0x0258, 0xb5 => 0x0258, 0xb6 => 0x0258, 0xb7 => 0x0258,
0xb8 => 0x0258, 0xb9 => 0x0258, 0xba => 0x0258, 0xbb => 0x0258,
0xbc => 0x0258, 0xbd => 0x0258, 0xbe => 0x0258, 0xbf => 0x0258,
0xc0 => 0x0258, 0xc1 => 0x0258, 0xc2 => 0x0258, 0xc3 => 0x0258,
0xc4 => 0x0258, 0xc5 => 0x0258, 0xc6 => 0x0258, 0xc7 => 0x0258,
0xc8 => 0x0258, 0xc9 => 0x0258, 0xca => 0x0258, 0xcb => 0x0258,
0xcc => 0x0258, 0xcd => 0x0258, 0xce => 0x0258, 0xcf => 0x0258,
0xd0 => 0x0258, 0xd1 => 0x0258, 0xd2 => 0x0258, 0xd3 => 0x0258,
0xd4 => 0x0258, 0xd5 => 0x0258, 0xd6 => 0x0258, 0xd7 => 0x0258,
0xd8 => 0x0258, 0xd9 => 0x0258, 0xda => 0x0258, 0xdb => 0x0258,
0xdc => 0x0258, 0xdd => 0x0258, 0xde => 0x0258, 0xdf => 0x0258,
0xe0 => 0x0258, 0xe1 => 0x0258, 0xe2 => 0x0258, 0xe3 => 0x0258,
0xe4 => 0x0258, 0xe5 => 0x0258, 0xe6 => 0x0258, 0xe7 => 0x0258,
0xe8 => 0x0258, 0xe9 => 0x0258, 0xea => 0x0258, 0xeb => 0x0258,
0xec => 0x0258, 0xed => 0x0258, 0xee => 0x0258, 0xef => 0x0258,
0xf0 => 0x0258, 0xf1 => 0x0258, 0xf2 => 0x0258, 0xf3 => 0x0258,
0xf4 => 0x0258, 0xf5 => 0x0258, 0xf6 => 0x0258, 0xf7 => 0x0258,
0xf8 => 0x0258, 0xf9 => 0x0258, 0xfa => 0x0258, 0xfb => 0x0258,
0xfc => 0x0258, 0xfd => 0x0258, 0xfe => 0x0258, 0xff => 0x0258,
0x0100 => 0x0258, 0x0101 => 0x0258, 0x0102 => 0x0258, 0x0103 => 0x0258,
0x0104 => 0x0258, 0x0105 => 0x0258, 0x0106 => 0x0258, 0x0107 => 0x0258,
0x0108 => 0x0258, 0x0109 => 0x0258, 0x010a => 0x0258, 0x010b => 0x0258,
0x010c => 0x0258, 0x010d => 0x0258, 0x010e => 0x0258, 0x010f => 0x0258,
0x0110 => 0x0258, 0x0111 => 0x0258, 0x0112 => 0x0258, 0x0113 => 0x0258,
0x0114 => 0x0258, 0x0115 => 0x0258, 0x0116 => 0x0258, 0x0117 => 0x0258,
0x0118 => 0x0258, 0x0119 => 0x0258, 0x011a => 0x0258, 0x011b => 0x0258,
0x011c => 0x0258, 0x011d => 0x0258, 0x011e => 0x0258, 0x011f => 0x0258,
0x0120 => 0x0258, 0x0121 => 0x0258, 0x0122 => 0x0258, 0x0123 => 0x0258,
0x0124 => 0x0258, 0x0125 => 0x0258, 0x0126 => 0x0258, 0x0127 => 0x0258,
0x0128 => 0x0258, 0x0129 => 0x0258, 0x012a => 0x0258, 0x012b => 0x0258,
0x012c => 0x0258, 0x012d => 0x0258, 0x012e => 0x0258, 0x012f => 0x0258,
0x0130 => 0x0258, 0x0131 => 0x0258, 0x0132 => 0x0258, 0x0133 => 0x0258,
0x0134 => 0x0258, 0x0135 => 0x0258, 0x0136 => 0x0258, 0x0137 => 0x0258,
0x0138 => 0x0258, 0x0139 => 0x0258, 0x013a => 0x0258, 0x013b => 0x0258,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Courier-Bold');
}
}

View File

@ -0,0 +1,291 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Courier-BoldOblique.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_CourierBoldOblique extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x39\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x30\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x31\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00"
. "\x41\x00\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00"
. "\x76\x00\x65\x00\x64\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x34\x00\x39";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x2d\x00"
. "\x42\x00\x6f\x00\x6c\x00\x64\x00\x4f\x00\x62\x00\x6c\x00\x69\x00"
. "\x71\x00\x75\x00\x65\x00\x20\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x33\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x2d\x00"
. "\x42\x00\x6f\x00\x6c\x00\x64\x00\x4f\x00\x62\x00\x6c\x00\x69\x00"
. "\x71\x00\x75\x00\x65";
$this->_isBold = true;
$this->_isItalic = true;
$this->_isMonospaced = true;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 629;
$this->_descent = -157;
$this->_lineGap = 414;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0258, 0x02 => 0x0258, 0x03 => 0x0258,
0x04 => 0x0258, 0x05 => 0x0258, 0x06 => 0x0258, 0x07 => 0x0258,
0x08 => 0x0258, 0x09 => 0x0258, 0x0a => 0x0258, 0x0b => 0x0258,
0x0c => 0x0258, 0x0d => 0x0258, 0x0e => 0x0258, 0x0f => 0x0258,
0x10 => 0x0258, 0x11 => 0x0258, 0x12 => 0x0258, 0x13 => 0x0258,
0x14 => 0x0258, 0x15 => 0x0258, 0x16 => 0x0258, 0x17 => 0x0258,
0x18 => 0x0258, 0x19 => 0x0258, 0x1a => 0x0258, 0x1b => 0x0258,
0x1c => 0x0258, 0x1d => 0x0258, 0x1e => 0x0258, 0x1f => 0x0258,
0x20 => 0x0258, 0x21 => 0x0258, 0x22 => 0x0258, 0x23 => 0x0258,
0x24 => 0x0258, 0x25 => 0x0258, 0x26 => 0x0258, 0x27 => 0x0258,
0x28 => 0x0258, 0x29 => 0x0258, 0x2a => 0x0258, 0x2b => 0x0258,
0x2c => 0x0258, 0x2d => 0x0258, 0x2e => 0x0258, 0x2f => 0x0258,
0x30 => 0x0258, 0x31 => 0x0258, 0x32 => 0x0258, 0x33 => 0x0258,
0x34 => 0x0258, 0x35 => 0x0258, 0x36 => 0x0258, 0x37 => 0x0258,
0x38 => 0x0258, 0x39 => 0x0258, 0x3a => 0x0258, 0x3b => 0x0258,
0x3c => 0x0258, 0x3d => 0x0258, 0x3e => 0x0258, 0x3f => 0x0258,
0x40 => 0x0258, 0x41 => 0x0258, 0x42 => 0x0258, 0x43 => 0x0258,
0x44 => 0x0258, 0x45 => 0x0258, 0x46 => 0x0258, 0x47 => 0x0258,
0x48 => 0x0258, 0x49 => 0x0258, 0x4a => 0x0258, 0x4b => 0x0258,
0x4c => 0x0258, 0x4d => 0x0258, 0x4e => 0x0258, 0x4f => 0x0258,
0x50 => 0x0258, 0x51 => 0x0258, 0x52 => 0x0258, 0x53 => 0x0258,
0x54 => 0x0258, 0x55 => 0x0258, 0x56 => 0x0258, 0x57 => 0x0258,
0x58 => 0x0258, 0x59 => 0x0258, 0x5a => 0x0258, 0x5b => 0x0258,
0x5c => 0x0258, 0x5d => 0x0258, 0x5e => 0x0258, 0x5f => 0x0258,
0x60 => 0x0258, 0x61 => 0x0258, 0x62 => 0x0258, 0x63 => 0x0258,
0x64 => 0x0258, 0x65 => 0x0258, 0x66 => 0x0258, 0x67 => 0x0258,
0x68 => 0x0258, 0x69 => 0x0258, 0x6a => 0x0258, 0x6b => 0x0258,
0x6c => 0x0258, 0x6d => 0x0258, 0x6e => 0x0258, 0x6f => 0x0258,
0x70 => 0x0258, 0x71 => 0x0258, 0x72 => 0x0258, 0x73 => 0x0258,
0x74 => 0x0258, 0x75 => 0x0258, 0x76 => 0x0258, 0x77 => 0x0258,
0x78 => 0x0258, 0x79 => 0x0258, 0x7a => 0x0258, 0x7b => 0x0258,
0x7c => 0x0258, 0x7d => 0x0258, 0x7e => 0x0258, 0x7f => 0x0258,
0x80 => 0x0258, 0x81 => 0x0258, 0x82 => 0x0258, 0x83 => 0x0258,
0x84 => 0x0258, 0x85 => 0x0258, 0x86 => 0x0258, 0x87 => 0x0258,
0x88 => 0x0258, 0x89 => 0x0258, 0x8a => 0x0258, 0x8b => 0x0258,
0x8c => 0x0258, 0x8d => 0x0258, 0x8e => 0x0258, 0x8f => 0x0258,
0x90 => 0x0258, 0x91 => 0x0258, 0x92 => 0x0258, 0x93 => 0x0258,
0x94 => 0x0258, 0x95 => 0x0258, 0x96 => 0x0258, 0x97 => 0x0258,
0x98 => 0x0258, 0x99 => 0x0258, 0x9a => 0x0258, 0x9b => 0x0258,
0x9c => 0x0258, 0x9d => 0x0258, 0x9e => 0x0258, 0x9f => 0x0258,
0xa0 => 0x0258, 0xa1 => 0x0258, 0xa2 => 0x0258, 0xa3 => 0x0258,
0xa4 => 0x0258, 0xa5 => 0x0258, 0xa6 => 0x0258, 0xa7 => 0x0258,
0xa8 => 0x0258, 0xa9 => 0x0258, 0xaa => 0x0258, 0xab => 0x0258,
0xac => 0x0258, 0xad => 0x0258, 0xae => 0x0258, 0xaf => 0x0258,
0xb0 => 0x0258, 0xb1 => 0x0258, 0xb2 => 0x0258, 0xb3 => 0x0258,
0xb4 => 0x0258, 0xb5 => 0x0258, 0xb6 => 0x0258, 0xb7 => 0x0258,
0xb8 => 0x0258, 0xb9 => 0x0258, 0xba => 0x0258, 0xbb => 0x0258,
0xbc => 0x0258, 0xbd => 0x0258, 0xbe => 0x0258, 0xbf => 0x0258,
0xc0 => 0x0258, 0xc1 => 0x0258, 0xc2 => 0x0258, 0xc3 => 0x0258,
0xc4 => 0x0258, 0xc5 => 0x0258, 0xc6 => 0x0258, 0xc7 => 0x0258,
0xc8 => 0x0258, 0xc9 => 0x0258, 0xca => 0x0258, 0xcb => 0x0258,
0xcc => 0x0258, 0xcd => 0x0258, 0xce => 0x0258, 0xcf => 0x0258,
0xd0 => 0x0258, 0xd1 => 0x0258, 0xd2 => 0x0258, 0xd3 => 0x0258,
0xd4 => 0x0258, 0xd5 => 0x0258, 0xd6 => 0x0258, 0xd7 => 0x0258,
0xd8 => 0x0258, 0xd9 => 0x0258, 0xda => 0x0258, 0xdb => 0x0258,
0xdc => 0x0258, 0xdd => 0x0258, 0xde => 0x0258, 0xdf => 0x0258,
0xe0 => 0x0258, 0xe1 => 0x0258, 0xe2 => 0x0258, 0xe3 => 0x0258,
0xe4 => 0x0258, 0xe5 => 0x0258, 0xe6 => 0x0258, 0xe7 => 0x0258,
0xe8 => 0x0258, 0xe9 => 0x0258, 0xea => 0x0258, 0xeb => 0x0258,
0xec => 0x0258, 0xed => 0x0258, 0xee => 0x0258, 0xef => 0x0258,
0xf0 => 0x0258, 0xf1 => 0x0258, 0xf2 => 0x0258, 0xf3 => 0x0258,
0xf4 => 0x0258, 0xf5 => 0x0258, 0xf6 => 0x0258, 0xf7 => 0x0258,
0xf8 => 0x0258, 0xf9 => 0x0258, 0xfa => 0x0258, 0xfb => 0x0258,
0xfc => 0x0258, 0xfd => 0x0258, 0xfe => 0x0258, 0xff => 0x0258,
0x0100 => 0x0258, 0x0101 => 0x0258, 0x0102 => 0x0258, 0x0103 => 0x0258,
0x0104 => 0x0258, 0x0105 => 0x0258, 0x0106 => 0x0258, 0x0107 => 0x0258,
0x0108 => 0x0258, 0x0109 => 0x0258, 0x010a => 0x0258, 0x010b => 0x0258,
0x010c => 0x0258, 0x010d => 0x0258, 0x010e => 0x0258, 0x010f => 0x0258,
0x0110 => 0x0258, 0x0111 => 0x0258, 0x0112 => 0x0258, 0x0113 => 0x0258,
0x0114 => 0x0258, 0x0115 => 0x0258, 0x0116 => 0x0258, 0x0117 => 0x0258,
0x0118 => 0x0258, 0x0119 => 0x0258, 0x011a => 0x0258, 0x011b => 0x0258,
0x011c => 0x0258, 0x011d => 0x0258, 0x011e => 0x0258, 0x011f => 0x0258,
0x0120 => 0x0258, 0x0121 => 0x0258, 0x0122 => 0x0258, 0x0123 => 0x0258,
0x0124 => 0x0258, 0x0125 => 0x0258, 0x0126 => 0x0258, 0x0127 => 0x0258,
0x0128 => 0x0258, 0x0129 => 0x0258, 0x012a => 0x0258, 0x012b => 0x0258,
0x012c => 0x0258, 0x012d => 0x0258, 0x012e => 0x0258, 0x012f => 0x0258,
0x0130 => 0x0258, 0x0131 => 0x0258, 0x0132 => 0x0258, 0x0133 => 0x0258,
0x0134 => 0x0258, 0x0135 => 0x0258, 0x0136 => 0x0258, 0x0137 => 0x0258,
0x0138 => 0x0258, 0x0139 => 0x0258, 0x013a => 0x0258, 0x013b => 0x0258,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Courier-BoldOblique');
}
}

View File

@ -0,0 +1,291 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Courier-Oblique.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_CourierOblique extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x39\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x30\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x31\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x32\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x37\x00"
. "\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00\x20\x00\x53\x00"
. "\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00\x20\x00\x49\x00"
. "\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00\x41\x00\x6c\x00"
. "\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00\x73\x00"
. "\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00\x65\x00"
. "\x64\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x35\x00\x31";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x2d\x00"
. "\x4f\x00\x62\x00\x6c\x00\x69\x00\x71\x00\x75\x00\x65\x00\x20\x00"
. "\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x33\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x43\x00\x6f\x00\x75\x00\x72\x00\x69\x00\x65\x00\x72\x00\x2d\x00"
. "\x4f\x00\x62\x00\x6c\x00\x69\x00\x71\x00\x75\x00\x65";
$this->_isBold = false;
$this->_isItalic = true;
$this->_isMonospaced = true;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 629;
$this->_descent = -157;
$this->_lineGap = 414;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0258, 0x02 => 0x0258, 0x03 => 0x0258,
0x04 => 0x0258, 0x05 => 0x0258, 0x06 => 0x0258, 0x07 => 0x0258,
0x08 => 0x0258, 0x09 => 0x0258, 0x0a => 0x0258, 0x0b => 0x0258,
0x0c => 0x0258, 0x0d => 0x0258, 0x0e => 0x0258, 0x0f => 0x0258,
0x10 => 0x0258, 0x11 => 0x0258, 0x12 => 0x0258, 0x13 => 0x0258,
0x14 => 0x0258, 0x15 => 0x0258, 0x16 => 0x0258, 0x17 => 0x0258,
0x18 => 0x0258, 0x19 => 0x0258, 0x1a => 0x0258, 0x1b => 0x0258,
0x1c => 0x0258, 0x1d => 0x0258, 0x1e => 0x0258, 0x1f => 0x0258,
0x20 => 0x0258, 0x21 => 0x0258, 0x22 => 0x0258, 0x23 => 0x0258,
0x24 => 0x0258, 0x25 => 0x0258, 0x26 => 0x0258, 0x27 => 0x0258,
0x28 => 0x0258, 0x29 => 0x0258, 0x2a => 0x0258, 0x2b => 0x0258,
0x2c => 0x0258, 0x2d => 0x0258, 0x2e => 0x0258, 0x2f => 0x0258,
0x30 => 0x0258, 0x31 => 0x0258, 0x32 => 0x0258, 0x33 => 0x0258,
0x34 => 0x0258, 0x35 => 0x0258, 0x36 => 0x0258, 0x37 => 0x0258,
0x38 => 0x0258, 0x39 => 0x0258, 0x3a => 0x0258, 0x3b => 0x0258,
0x3c => 0x0258, 0x3d => 0x0258, 0x3e => 0x0258, 0x3f => 0x0258,
0x40 => 0x0258, 0x41 => 0x0258, 0x42 => 0x0258, 0x43 => 0x0258,
0x44 => 0x0258, 0x45 => 0x0258, 0x46 => 0x0258, 0x47 => 0x0258,
0x48 => 0x0258, 0x49 => 0x0258, 0x4a => 0x0258, 0x4b => 0x0258,
0x4c => 0x0258, 0x4d => 0x0258, 0x4e => 0x0258, 0x4f => 0x0258,
0x50 => 0x0258, 0x51 => 0x0258, 0x52 => 0x0258, 0x53 => 0x0258,
0x54 => 0x0258, 0x55 => 0x0258, 0x56 => 0x0258, 0x57 => 0x0258,
0x58 => 0x0258, 0x59 => 0x0258, 0x5a => 0x0258, 0x5b => 0x0258,
0x5c => 0x0258, 0x5d => 0x0258, 0x5e => 0x0258, 0x5f => 0x0258,
0x60 => 0x0258, 0x61 => 0x0258, 0x62 => 0x0258, 0x63 => 0x0258,
0x64 => 0x0258, 0x65 => 0x0258, 0x66 => 0x0258, 0x67 => 0x0258,
0x68 => 0x0258, 0x69 => 0x0258, 0x6a => 0x0258, 0x6b => 0x0258,
0x6c => 0x0258, 0x6d => 0x0258, 0x6e => 0x0258, 0x6f => 0x0258,
0x70 => 0x0258, 0x71 => 0x0258, 0x72 => 0x0258, 0x73 => 0x0258,
0x74 => 0x0258, 0x75 => 0x0258, 0x76 => 0x0258, 0x77 => 0x0258,
0x78 => 0x0258, 0x79 => 0x0258, 0x7a => 0x0258, 0x7b => 0x0258,
0x7c => 0x0258, 0x7d => 0x0258, 0x7e => 0x0258, 0x7f => 0x0258,
0x80 => 0x0258, 0x81 => 0x0258, 0x82 => 0x0258, 0x83 => 0x0258,
0x84 => 0x0258, 0x85 => 0x0258, 0x86 => 0x0258, 0x87 => 0x0258,
0x88 => 0x0258, 0x89 => 0x0258, 0x8a => 0x0258, 0x8b => 0x0258,
0x8c => 0x0258, 0x8d => 0x0258, 0x8e => 0x0258, 0x8f => 0x0258,
0x90 => 0x0258, 0x91 => 0x0258, 0x92 => 0x0258, 0x93 => 0x0258,
0x94 => 0x0258, 0x95 => 0x0258, 0x96 => 0x0258, 0x97 => 0x0258,
0x98 => 0x0258, 0x99 => 0x0258, 0x9a => 0x0258, 0x9b => 0x0258,
0x9c => 0x0258, 0x9d => 0x0258, 0x9e => 0x0258, 0x9f => 0x0258,
0xa0 => 0x0258, 0xa1 => 0x0258, 0xa2 => 0x0258, 0xa3 => 0x0258,
0xa4 => 0x0258, 0xa5 => 0x0258, 0xa6 => 0x0258, 0xa7 => 0x0258,
0xa8 => 0x0258, 0xa9 => 0x0258, 0xaa => 0x0258, 0xab => 0x0258,
0xac => 0x0258, 0xad => 0x0258, 0xae => 0x0258, 0xaf => 0x0258,
0xb0 => 0x0258, 0xb1 => 0x0258, 0xb2 => 0x0258, 0xb3 => 0x0258,
0xb4 => 0x0258, 0xb5 => 0x0258, 0xb6 => 0x0258, 0xb7 => 0x0258,
0xb8 => 0x0258, 0xb9 => 0x0258, 0xba => 0x0258, 0xbb => 0x0258,
0xbc => 0x0258, 0xbd => 0x0258, 0xbe => 0x0258, 0xbf => 0x0258,
0xc0 => 0x0258, 0xc1 => 0x0258, 0xc2 => 0x0258, 0xc3 => 0x0258,
0xc4 => 0x0258, 0xc5 => 0x0258, 0xc6 => 0x0258, 0xc7 => 0x0258,
0xc8 => 0x0258, 0xc9 => 0x0258, 0xca => 0x0258, 0xcb => 0x0258,
0xcc => 0x0258, 0xcd => 0x0258, 0xce => 0x0258, 0xcf => 0x0258,
0xd0 => 0x0258, 0xd1 => 0x0258, 0xd2 => 0x0258, 0xd3 => 0x0258,
0xd4 => 0x0258, 0xd5 => 0x0258, 0xd6 => 0x0258, 0xd7 => 0x0258,
0xd8 => 0x0258, 0xd9 => 0x0258, 0xda => 0x0258, 0xdb => 0x0258,
0xdc => 0x0258, 0xdd => 0x0258, 0xde => 0x0258, 0xdf => 0x0258,
0xe0 => 0x0258, 0xe1 => 0x0258, 0xe2 => 0x0258, 0xe3 => 0x0258,
0xe4 => 0x0258, 0xe5 => 0x0258, 0xe6 => 0x0258, 0xe7 => 0x0258,
0xe8 => 0x0258, 0xe9 => 0x0258, 0xea => 0x0258, 0xeb => 0x0258,
0xec => 0x0258, 0xed => 0x0258, 0xee => 0x0258, 0xef => 0x0258,
0xf0 => 0x0258, 0xf1 => 0x0258, 0xf2 => 0x0258, 0xf3 => 0x0258,
0xf4 => 0x0258, 0xf5 => 0x0258, 0xf6 => 0x0258, 0xf7 => 0x0258,
0xf8 => 0x0258, 0xf9 => 0x0258, 0xfa => 0x0258, 0xfb => 0x0258,
0xfc => 0x0258, 0xfd => 0x0258, 0xfe => 0x0258, 0xff => 0x0258,
0x0100 => 0x0258, 0x0101 => 0x0258, 0x0102 => 0x0258, 0x0103 => 0x0258,
0x0104 => 0x0258, 0x0105 => 0x0258, 0x0106 => 0x0258, 0x0107 => 0x0258,
0x0108 => 0x0258, 0x0109 => 0x0258, 0x010a => 0x0258, 0x010b => 0x0258,
0x010c => 0x0258, 0x010d => 0x0258, 0x010e => 0x0258, 0x010f => 0x0258,
0x0110 => 0x0258, 0x0111 => 0x0258, 0x0112 => 0x0258, 0x0113 => 0x0258,
0x0114 => 0x0258, 0x0115 => 0x0258, 0x0116 => 0x0258, 0x0117 => 0x0258,
0x0118 => 0x0258, 0x0119 => 0x0258, 0x011a => 0x0258, 0x011b => 0x0258,
0x011c => 0x0258, 0x011d => 0x0258, 0x011e => 0x0258, 0x011f => 0x0258,
0x0120 => 0x0258, 0x0121 => 0x0258, 0x0122 => 0x0258, 0x0123 => 0x0258,
0x0124 => 0x0258, 0x0125 => 0x0258, 0x0126 => 0x0258, 0x0127 => 0x0258,
0x0128 => 0x0258, 0x0129 => 0x0258, 0x012a => 0x0258, 0x012b => 0x0258,
0x012c => 0x0258, 0x012d => 0x0258, 0x012e => 0x0258, 0x012f => 0x0258,
0x0130 => 0x0258, 0x0131 => 0x0258, 0x0132 => 0x0258, 0x0133 => 0x0258,
0x0134 => 0x0258, 0x0135 => 0x0258, 0x0136 => 0x0258, 0x0137 => 0x0258,
0x0138 => 0x0258, 0x0139 => 0x0258, 0x013a => 0x0258, 0x013b => 0x0258,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Courier-Oblique');
}
}

View File

@ -0,0 +1,299 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Helvetica.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_Helvetica extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00"
. "\x41\x00\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00"
. "\x76\x00\x65\x00\x64\x00\x2e\x00\x48\x00\x65\x00\x6c\x00\x76\x00"
. "\x65\x00\x74\x00\x69\x00\x63\x00\x61\x00\x20\x00\x69\x00\x73\x00"
. "\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00\x64\x00\x65\x00"
. "\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00\x66\x00\x20\x00"
. "\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00\x70\x00\x65\x00"
. "\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00\x41\x00\x47\x00"
. "\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00\x72\x00\x20\x00"
. "\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00\x62\x00\x73\x00"
. "\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00\x65\x00\x73\x00"
. "\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x35\x00\x34";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x20\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61";
$this->_isBold = false;
$this->_isItalic = false;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 718;
$this->_descent = -207;
$this->_lineGap = 275;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0116, 0x02 => 0x0116, 0x03 => 0x0163,
0x04 => 0x022c, 0x05 => 0x022c, 0x06 => 0x0379, 0x07 => 0x029b,
0x08 => 0xde, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x0185,
0x0c => 0x0248, 0x0d => 0x0116, 0x0e => 0x014d, 0x0f => 0x0116,
0x10 => 0x0116, 0x11 => 0x022c, 0x12 => 0x022c, 0x13 => 0x022c,
0x14 => 0x022c, 0x15 => 0x022c, 0x16 => 0x022c, 0x17 => 0x022c,
0x18 => 0x022c, 0x19 => 0x022c, 0x1a => 0x022c, 0x1b => 0x0116,
0x1c => 0x0116, 0x1d => 0x0248, 0x1e => 0x0248, 0x1f => 0x0248,
0x20 => 0x022c, 0x21 => 0x03f7, 0x22 => 0x029b, 0x23 => 0x029b,
0x24 => 0x02d2, 0x25 => 0x02d2, 0x26 => 0x029b, 0x27 => 0x0263,
0x28 => 0x030a, 0x29 => 0x02d2, 0x2a => 0x0116, 0x2b => 0x01f4,
0x2c => 0x029b, 0x2d => 0x022c, 0x2e => 0x0341, 0x2f => 0x02d2,
0x30 => 0x030a, 0x31 => 0x029b, 0x32 => 0x030a, 0x33 => 0x02d2,
0x34 => 0x029b, 0x35 => 0x0263, 0x36 => 0x02d2, 0x37 => 0x029b,
0x38 => 0x03b0, 0x39 => 0x029b, 0x3a => 0x029b, 0x3b => 0x0263,
0x3c => 0x0116, 0x3d => 0x0116, 0x3e => 0x0116, 0x3f => 0x01d5,
0x40 => 0x022c, 0x41 => 0xde, 0x42 => 0x022c, 0x43 => 0x022c,
0x44 => 0x01f4, 0x45 => 0x022c, 0x46 => 0x022c, 0x47 => 0x0116,
0x48 => 0x022c, 0x49 => 0x022c, 0x4a => 0xde, 0x4b => 0xde,
0x4c => 0x01f4, 0x4d => 0xde, 0x4e => 0x0341, 0x4f => 0x022c,
0x50 => 0x022c, 0x51 => 0x022c, 0x52 => 0x022c, 0x53 => 0x014d,
0x54 => 0x01f4, 0x55 => 0x0116, 0x56 => 0x022c, 0x57 => 0x01f4,
0x58 => 0x02d2, 0x59 => 0x01f4, 0x5a => 0x01f4, 0x5b => 0x01f4,
0x5c => 0x014e, 0x5d => 0x0104, 0x5e => 0x014e, 0x5f => 0x0248,
0x60 => 0x014d, 0x61 => 0x022c, 0x62 => 0x022c, 0x63 => 0xa7,
0x64 => 0x022c, 0x65 => 0x022c, 0x66 => 0x022c, 0x67 => 0x022c,
0x68 => 0xbf, 0x69 => 0x014d, 0x6a => 0x022c, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x01f4, 0x6e => 0x01f4, 0x6f => 0x022c,
0x70 => 0x022c, 0x71 => 0x022c, 0x72 => 0x0116, 0x73 => 0x0219,
0x74 => 0x015e, 0x75 => 0xde, 0x76 => 0x014d, 0x77 => 0x014d,
0x78 => 0x022c, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x0263,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x03e8, 0x8b => 0x0172,
0x8c => 0x022c, 0x8d => 0x030a, 0x8e => 0x03e8, 0x8f => 0x016d,
0x90 => 0x0379, 0x91 => 0x0116, 0x92 => 0xde, 0x93 => 0x0263,
0x94 => 0x03b0, 0x95 => 0x0263, 0x96 => 0x0116, 0x97 => 0x022c,
0x98 => 0x022c, 0x99 => 0x022c, 0x9a => 0x022c, 0x9b => 0x029b,
0x9c => 0x0248, 0x9d => 0x029b, 0x9e => 0x029b, 0x9f => 0x022c,
0xa0 => 0x02d2, 0xa1 => 0x01f4, 0xa2 => 0x01f4, 0xa3 => 0x022c,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x022c, 0xa7 => 0x02d2,
0xa8 => 0x022c, 0xa9 => 0x029b, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02e1, 0xad => 0x029b, 0xae => 0x01f4, 0xaf => 0x022c,
0xb0 => 0x02d2, 0xb1 => 0xde, 0xb2 => 0x022c, 0xb3 => 0x0263,
0xb4 => 0x02d2, 0xb5 => 0x022c, 0xb6 => 0x029b, 0xb7 => 0x01f4,
0xb8 => 0x01f4, 0xb9 => 0x0116, 0xba => 0x01d7, 0xbb => 0x02d2,
0xbc => 0x030a, 0xbd => 0x022c, 0xbe => 0x022c, 0xbf => 0x029b,
0xc0 => 0x014d, 0xc1 => 0x01f4, 0xc2 => 0x0263, 0xc3 => 0x029b,
0xc4 => 0x030a, 0xc5 => 0x02d2, 0xc6 => 0x029b, 0xc7 => 0x0283,
0xc8 => 0x02d2, 0xc9 => 0x022c, 0xca => 0x014d, 0xcb => 0x030a,
0xcc => 0x029b, 0xcd => 0x029b, 0xce => 0x0248, 0xcf => 0x022c,
0xd0 => 0x0263, 0xd1 => 0x01dc, 0xd2 => 0x01f4, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x029b, 0xd6 => 0x022c, 0xd7 => 0x022c,
0xd8 => 0x01f4, 0xd9 => 0x022c, 0xda => 0x022c, 0xdb => 0x02d2,
0xdc => 0x0116, 0xdd => 0x0248, 0xde => 0x0104, 0xdf => 0x02e1,
0xe0 => 0x030a, 0xe1 => 0x0116, 0xe2 => 0x0258, 0xe3 => 0x029b,
0xe4 => 0x014d, 0xe5 => 0x022c, 0xe6 => 0x0263, 0xe7 => 0x0263,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x02d2, 0xeb => 0xde,
0xec => 0x013d, 0xed => 0x022c, 0xee => 0x02d2, 0xef => 0x029b,
0xf0 => 0x029b, 0xf1 => 0x022c, 0xf2 => 0x01f4, 0xf3 => 0xde,
0xf4 => 0x030a, 0xf5 => 0x022c, 0xf6 => 0x022c, 0xf7 => 0x01f4,
0xf8 => 0x0116, 0xf9 => 0x030a, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x022c, 0xfd => 0x014d, 0xfe => 0x030a, 0xff => 0x022c,
0x0100 => 0x0116, 0x0101 => 0x022c, 0x0102 => 0x029b, 0x0103 => 0x022c,
0x0104 => 0x0342, 0x0105 => 0x029b, 0x0106 => 0x012b, 0x0107 => 0x029b,
0x0108 => 0x022c, 0x0109 => 0x03e8, 0x010a => 0x022c, 0x010b => 0x0116,
0x010c => 0x0116, 0x010d => 0x022c, 0x010e => 0x0342, 0x010f => 0x0225,
0x0110 => 0x022c, 0x0111 => 0x022c, 0x0112 => 0x02d2, 0x0113 => 0x029b,
0x0114 => 0x022c, 0x0115 => 0x022c, 0x0116 => 0x0342, 0x0117 => 0x029b,
0x0118 => 0x029b, 0x0119 => 0x030a, 0x011a => 0x0190, 0x011b => 0x022c,
0x011c => 0x02d2, 0x011d => 0x022c, 0x011e => 0x01c5, 0x011f => 0x02d2,
0x0120 => 0x014d, 0x0121 => 0x02d2, 0x0122 => 0x022c, 0x0123 => 0x02d2,
0x0124 => 0x022c, 0x0125 => 0x029b, 0x0126 => 0x029b, 0x0127 => 0x029b,
0x0128 => 0x030a, 0x0129 => 0x01f4, 0x012a => 0x029b, 0x012b => 0x0116,
0x012c => 0x01f4, 0x012d => 0x0248, 0x012e => 0x0116, 0x012f => 0x022c,
0x0130 => 0x0116, 0x0131 => 0x0248, 0x0132 => 0x022c, 0x0133 => 0x022c,
0x0134 => 0x0225, 0x0135 => 0x022c, 0x0136 => 0x022c, 0x0137 => 0x01f4,
0x0138 => 0x022c, 0x0139 => 0x014d, 0x013a => 0x0116, 0x013b => 0x022c,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Helvetica');
}
}

View File

@ -0,0 +1,300 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Helvetica-Bold.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBold extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00"
. "\x41\x00\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00"
. "\x76\x00\x65\x00\x64\x00\x2e\x00\x48\x00\x65\x00\x6c\x00\x76\x00"
. "\x65\x00\x74\x00\x69\x00\x63\x00\x61\x00\x20\x00\x69\x00\x73\x00"
. "\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00\x64\x00\x65\x00"
. "\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00\x66\x00\x20\x00"
. "\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00\x70\x00\x65\x00"
. "\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00\x41\x00\x47\x00"
. "\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00\x72\x00\x20\x00"
. "\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00\x62\x00\x73\x00"
. "\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00\x65\x00\x73\x00"
. "\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x35\x00\x32";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x2d\x00\x42\x00\x6f\x00\x6c\x00\x64\x00\x20\x00\x42\x00"
. "\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x2d\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_isBold = true;
$this->_isItalic = false;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 718;
$this->_descent = -207;
$this->_lineGap = 275;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0116, 0x02 => 0x014d, 0x03 => 0x01da,
0x04 => 0x022c, 0x05 => 0x022c, 0x06 => 0x0379, 0x07 => 0x02d2,
0x08 => 0x0116, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x0185,
0x0c => 0x0248, 0x0d => 0x0116, 0x0e => 0x014d, 0x0f => 0x0116,
0x10 => 0x0116, 0x11 => 0x022c, 0x12 => 0x022c, 0x13 => 0x022c,
0x14 => 0x022c, 0x15 => 0x022c, 0x16 => 0x022c, 0x17 => 0x022c,
0x18 => 0x022c, 0x19 => 0x022c, 0x1a => 0x022c, 0x1b => 0x014d,
0x1c => 0x014d, 0x1d => 0x0248, 0x1e => 0x0248, 0x1f => 0x0248,
0x20 => 0x0263, 0x21 => 0x03cf, 0x22 => 0x02d2, 0x23 => 0x02d2,
0x24 => 0x02d2, 0x25 => 0x02d2, 0x26 => 0x029b, 0x27 => 0x0263,
0x28 => 0x030a, 0x29 => 0x02d2, 0x2a => 0x0116, 0x2b => 0x022c,
0x2c => 0x02d2, 0x2d => 0x0263, 0x2e => 0x0341, 0x2f => 0x02d2,
0x30 => 0x030a, 0x31 => 0x029b, 0x32 => 0x030a, 0x33 => 0x02d2,
0x34 => 0x029b, 0x35 => 0x0263, 0x36 => 0x02d2, 0x37 => 0x029b,
0x38 => 0x03b0, 0x39 => 0x029b, 0x3a => 0x029b, 0x3b => 0x0263,
0x3c => 0x014d, 0x3d => 0x0116, 0x3e => 0x014d, 0x3f => 0x0248,
0x40 => 0x022c, 0x41 => 0x0116, 0x42 => 0x022c, 0x43 => 0x0263,
0x44 => 0x022c, 0x45 => 0x0263, 0x46 => 0x022c, 0x47 => 0x014d,
0x48 => 0x0263, 0x49 => 0x0263, 0x4a => 0x0116, 0x4b => 0x0116,
0x4c => 0x022c, 0x4d => 0x0116, 0x4e => 0x0379, 0x4f => 0x0263,
0x50 => 0x0263, 0x51 => 0x0263, 0x52 => 0x0263, 0x53 => 0x0185,
0x54 => 0x022c, 0x55 => 0x014d, 0x56 => 0x0263, 0x57 => 0x022c,
0x58 => 0x030a, 0x59 => 0x022c, 0x5a => 0x022c, 0x5b => 0x01f4,
0x5c => 0x0185, 0x5d => 0x0118, 0x5e => 0x0185, 0x5f => 0x0248,
0x60 => 0x014d, 0x61 => 0x022c, 0x62 => 0x022c, 0x63 => 0xa7,
0x64 => 0x022c, 0x65 => 0x022c, 0x66 => 0x022c, 0x67 => 0x022c,
0x68 => 0xee, 0x69 => 0x01f4, 0x6a => 0x022c, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x0263, 0x6e => 0x0263, 0x6f => 0x022c,
0x70 => 0x022c, 0x71 => 0x022c, 0x72 => 0x0116, 0x73 => 0x022c,
0x74 => 0x015e, 0x75 => 0x0116, 0x76 => 0x01f4, 0x77 => 0x01f4,
0x78 => 0x022c, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x0263,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x03e8, 0x8b => 0x0172,
0x8c => 0x0263, 0x8d => 0x030a, 0x8e => 0x03e8, 0x8f => 0x016d,
0x90 => 0x0379, 0x91 => 0x0116, 0x92 => 0x0116, 0x93 => 0x0263,
0x94 => 0x03b0, 0x95 => 0x0263, 0x96 => 0x0116, 0x97 => 0x022c,
0x98 => 0x022c, 0x99 => 0x0263, 0x9a => 0x022c, 0x9b => 0x029b,
0x9c => 0x0248, 0x9d => 0x029b, 0x9e => 0x02d2, 0x9f => 0x022c,
0xa0 => 0x02d2, 0xa1 => 0x022c, 0xa2 => 0x022c, 0xa3 => 0x022c,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x022c, 0xa7 => 0x02d2,
0xa8 => 0x0263, 0xa9 => 0x029b, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02e1, 0xad => 0x029b, 0xae => 0x022c, 0xaf => 0x022c,
0xb0 => 0x02d2, 0xb1 => 0x0116, 0xb2 => 0x022c, 0xb3 => 0x0263,
0xb4 => 0x02d2, 0xb5 => 0x022c, 0xb6 => 0x029b, 0xb7 => 0x022c,
0xb8 => 0x022c, 0xb9 => 0x0116, 0xba => 0x01ee, 0xbb => 0x02d2,
0xbc => 0x030a, 0xbd => 0x0263, 0xbe => 0x022c, 0xbf => 0x02d2,
0xc0 => 0x0185, 0xc1 => 0x022c, 0xc2 => 0x0263, 0xc3 => 0x029b,
0xc4 => 0x030a, 0xc5 => 0x02d2, 0xc6 => 0x029b, 0xc7 => 0x02e7,
0xc8 => 0x02d2, 0xc9 => 0x0263, 0xca => 0x014d, 0xcb => 0x030a,
0xcc => 0x02d2, 0xcd => 0x02d2, 0xce => 0x0248, 0xcf => 0x0263,
0xd0 => 0x0263, 0xd1 => 0x01ee, 0xd2 => 0x022c, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x029b, 0xd6 => 0x022c, 0xd7 => 0x022c,
0xd8 => 0x022c, 0xd9 => 0x0263, 0xda => 0x0263, 0xdb => 0x02d2,
0xdc => 0x0116, 0xdd => 0x0248, 0xde => 0x0118, 0xdf => 0x02e1,
0xe0 => 0x030a, 0xe1 => 0x0116, 0xe2 => 0x0258, 0xe3 => 0x029b,
0xe4 => 0x0185, 0xe5 => 0x0263, 0xe6 => 0x0263, 0xe7 => 0x0263,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x02d2, 0xeb => 0x0116,
0xec => 0x0185, 0xed => 0x022c, 0xee => 0x02d2, 0xef => 0x02d2,
0xf0 => 0x02d2, 0xf1 => 0x022c, 0xf2 => 0x01f4, 0xf3 => 0x0116,
0xf4 => 0x030a, 0xf5 => 0x0263, 0xf6 => 0x022c, 0xf7 => 0x022c,
0xf8 => 0x0116, 0xf9 => 0x030a, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x0263, 0xfd => 0x014d, 0xfe => 0x030a, 0xff => 0x0263,
0x0100 => 0x0116, 0x0101 => 0x0263, 0x0102 => 0x029b, 0x0103 => 0x0263,
0x0104 => 0x0342, 0x0105 => 0x029b, 0x0106 => 0x0190, 0x0107 => 0x02d2,
0x0108 => 0x0263, 0x0109 => 0x03e8, 0x010a => 0x022c, 0x010b => 0x0116,
0x010c => 0x0116, 0x010d => 0x0263, 0x010e => 0x0342, 0x010f => 0x0225,
0x0110 => 0x0263, 0x0111 => 0x0263, 0x0112 => 0x02d2, 0x0113 => 0x029b,
0x0114 => 0x022c, 0x0115 => 0x0263, 0x0116 => 0x0342, 0x0117 => 0x029b,
0x0118 => 0x029b, 0x0119 => 0x030a, 0x011a => 0x0190, 0x011b => 0x0263,
0x011c => 0x02d2, 0x011d => 0x0263, 0x011e => 0x0225, 0x011f => 0x02d2,
0x0120 => 0x0185, 0x0121 => 0x02d2, 0x0122 => 0x0263, 0x0123 => 0x02d2,
0x0124 => 0x0263, 0x0125 => 0x02d2, 0x0126 => 0x02d2, 0x0127 => 0x02d2,
0x0128 => 0x030a, 0x0129 => 0x01f4, 0x012a => 0x029b, 0x012b => 0x0116,
0x012c => 0x022c, 0x012d => 0x0248, 0x012e => 0x0116, 0x012f => 0x0263,
0x0130 => 0x014d, 0x0131 => 0x0248, 0x0132 => 0x0263, 0x0133 => 0x0263,
0x0134 => 0x0225, 0x0135 => 0x0263, 0x0136 => 0x0263, 0x0137 => 0x01f4,
0x0138 => 0x0263, 0x0139 => 0x014d, 0x013a => 0x0116, 0x013b => 0x022c,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Helvetica-Bold');
}
}

View File

@ -0,0 +1,302 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Helvetica-BoldOblique.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_HelveticaBoldOblique extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00"
. "\x41\x00\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00"
. "\x76\x00\x65\x00\x64\x00\x2e\x00\x48\x00\x65\x00\x6c\x00\x76\x00"
. "\x65\x00\x74\x00\x69\x00\x63\x00\x61\x00\x20\x00\x69\x00\x73\x00"
. "\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00\x64\x00\x65\x00"
. "\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00\x66\x00\x20\x00"
. "\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00\x70\x00\x65\x00"
. "\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00\x41\x00\x47\x00"
. "\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00\x72\x00\x20\x00"
. "\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00\x62\x00\x73\x00"
. "\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00\x65\x00\x73\x00"
. "\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x35\x00\x33";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x2d\x00\x42\x00\x6f\x00\x6c\x00\x64\x00\x4f\x00\x62\x00"
. "\x6c\x00\x69\x00\x71\x00\x75\x00\x65\x00\x20\x00\x42\x00\x6f\x00"
. "\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x2d\x00\x42\x00\x6f\x00\x6c\x00\x64\x00\x4f\x00\x62\x00"
. "\x6c\x00\x69\x00\x71\x00\x75\x00\x65";
$this->_isBold = true;
$this->_isItalic = true;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 718;
$this->_descent = -207;
$this->_lineGap = 275;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0116, 0x02 => 0x014d, 0x03 => 0x01da,
0x04 => 0x022c, 0x05 => 0x022c, 0x06 => 0x0379, 0x07 => 0x02d2,
0x08 => 0x0116, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x0185,
0x0c => 0x0248, 0x0d => 0x0116, 0x0e => 0x014d, 0x0f => 0x0116,
0x10 => 0x0116, 0x11 => 0x022c, 0x12 => 0x022c, 0x13 => 0x022c,
0x14 => 0x022c, 0x15 => 0x022c, 0x16 => 0x022c, 0x17 => 0x022c,
0x18 => 0x022c, 0x19 => 0x022c, 0x1a => 0x022c, 0x1b => 0x014d,
0x1c => 0x014d, 0x1d => 0x0248, 0x1e => 0x0248, 0x1f => 0x0248,
0x20 => 0x0263, 0x21 => 0x03cf, 0x22 => 0x02d2, 0x23 => 0x02d2,
0x24 => 0x02d2, 0x25 => 0x02d2, 0x26 => 0x029b, 0x27 => 0x0263,
0x28 => 0x030a, 0x29 => 0x02d2, 0x2a => 0x0116, 0x2b => 0x022c,
0x2c => 0x02d2, 0x2d => 0x0263, 0x2e => 0x0341, 0x2f => 0x02d2,
0x30 => 0x030a, 0x31 => 0x029b, 0x32 => 0x030a, 0x33 => 0x02d2,
0x34 => 0x029b, 0x35 => 0x0263, 0x36 => 0x02d2, 0x37 => 0x029b,
0x38 => 0x03b0, 0x39 => 0x029b, 0x3a => 0x029b, 0x3b => 0x0263,
0x3c => 0x014d, 0x3d => 0x0116, 0x3e => 0x014d, 0x3f => 0x0248,
0x40 => 0x022c, 0x41 => 0x0116, 0x42 => 0x022c, 0x43 => 0x0263,
0x44 => 0x022c, 0x45 => 0x0263, 0x46 => 0x022c, 0x47 => 0x014d,
0x48 => 0x0263, 0x49 => 0x0263, 0x4a => 0x0116, 0x4b => 0x0116,
0x4c => 0x022c, 0x4d => 0x0116, 0x4e => 0x0379, 0x4f => 0x0263,
0x50 => 0x0263, 0x51 => 0x0263, 0x52 => 0x0263, 0x53 => 0x0185,
0x54 => 0x022c, 0x55 => 0x014d, 0x56 => 0x0263, 0x57 => 0x022c,
0x58 => 0x030a, 0x59 => 0x022c, 0x5a => 0x022c, 0x5b => 0x01f4,
0x5c => 0x0185, 0x5d => 0x0118, 0x5e => 0x0185, 0x5f => 0x0248,
0x60 => 0x014d, 0x61 => 0x022c, 0x62 => 0x022c, 0x63 => 0xa7,
0x64 => 0x022c, 0x65 => 0x022c, 0x66 => 0x022c, 0x67 => 0x022c,
0x68 => 0xee, 0x69 => 0x01f4, 0x6a => 0x022c, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x0263, 0x6e => 0x0263, 0x6f => 0x022c,
0x70 => 0x022c, 0x71 => 0x022c, 0x72 => 0x0116, 0x73 => 0x022c,
0x74 => 0x015e, 0x75 => 0x0116, 0x76 => 0x01f4, 0x77 => 0x01f4,
0x78 => 0x022c, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x0263,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x03e8, 0x8b => 0x0172,
0x8c => 0x0263, 0x8d => 0x030a, 0x8e => 0x03e8, 0x8f => 0x016d,
0x90 => 0x0379, 0x91 => 0x0116, 0x92 => 0x0116, 0x93 => 0x0263,
0x94 => 0x03b0, 0x95 => 0x0263, 0x96 => 0x0116, 0x97 => 0x022c,
0x98 => 0x022c, 0x99 => 0x0263, 0x9a => 0x022c, 0x9b => 0x029b,
0x9c => 0x0248, 0x9d => 0x029b, 0x9e => 0x02d2, 0x9f => 0x022c,
0xa0 => 0x02d2, 0xa1 => 0x022c, 0xa2 => 0x022c, 0xa3 => 0x022c,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x022c, 0xa7 => 0x02d2,
0xa8 => 0x0263, 0xa9 => 0x029b, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02e1, 0xad => 0x029b, 0xae => 0x022c, 0xaf => 0x022c,
0xb0 => 0x02d2, 0xb1 => 0x0116, 0xb2 => 0x022c, 0xb3 => 0x0263,
0xb4 => 0x02d2, 0xb5 => 0x022c, 0xb6 => 0x029b, 0xb7 => 0x022c,
0xb8 => 0x022c, 0xb9 => 0x0116, 0xba => 0x01ee, 0xbb => 0x02d2,
0xbc => 0x030a, 0xbd => 0x0263, 0xbe => 0x022c, 0xbf => 0x02d2,
0xc0 => 0x0185, 0xc1 => 0x022c, 0xc2 => 0x0263, 0xc3 => 0x029b,
0xc4 => 0x030a, 0xc5 => 0x02d2, 0xc6 => 0x029b, 0xc7 => 0x02e7,
0xc8 => 0x02d2, 0xc9 => 0x0263, 0xca => 0x014d, 0xcb => 0x030a,
0xcc => 0x02d2, 0xcd => 0x02d2, 0xce => 0x0248, 0xcf => 0x0263,
0xd0 => 0x0263, 0xd1 => 0x01ee, 0xd2 => 0x022c, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x029b, 0xd6 => 0x022c, 0xd7 => 0x022c,
0xd8 => 0x022c, 0xd9 => 0x0263, 0xda => 0x0263, 0xdb => 0x02d2,
0xdc => 0x0116, 0xdd => 0x0248, 0xde => 0x0118, 0xdf => 0x02e1,
0xe0 => 0x030a, 0xe1 => 0x0116, 0xe2 => 0x0258, 0xe3 => 0x029b,
0xe4 => 0x0185, 0xe5 => 0x0263, 0xe6 => 0x0263, 0xe7 => 0x0263,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x02d2, 0xeb => 0x0116,
0xec => 0x0185, 0xed => 0x022c, 0xee => 0x02d2, 0xef => 0x02d2,
0xf0 => 0x02d2, 0xf1 => 0x022c, 0xf2 => 0x01f4, 0xf3 => 0x0116,
0xf4 => 0x030a, 0xf5 => 0x0263, 0xf6 => 0x022c, 0xf7 => 0x022c,
0xf8 => 0x0116, 0xf9 => 0x030a, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x0263, 0xfd => 0x014d, 0xfe => 0x030a, 0xff => 0x0263,
0x0100 => 0x0116, 0x0101 => 0x0263, 0x0102 => 0x029b, 0x0103 => 0x0263,
0x0104 => 0x0342, 0x0105 => 0x029b, 0x0106 => 0x0190, 0x0107 => 0x02d2,
0x0108 => 0x0263, 0x0109 => 0x03e8, 0x010a => 0x022c, 0x010b => 0x0116,
0x010c => 0x0116, 0x010d => 0x0263, 0x010e => 0x0342, 0x010f => 0x0225,
0x0110 => 0x0263, 0x0111 => 0x0263, 0x0112 => 0x02d2, 0x0113 => 0x029b,
0x0114 => 0x022c, 0x0115 => 0x0263, 0x0116 => 0x0342, 0x0117 => 0x029b,
0x0118 => 0x029b, 0x0119 => 0x030a, 0x011a => 0x0190, 0x011b => 0x0263,
0x011c => 0x02d2, 0x011d => 0x0263, 0x011e => 0x0225, 0x011f => 0x02d2,
0x0120 => 0x0185, 0x0121 => 0x02d2, 0x0122 => 0x0263, 0x0123 => 0x02d2,
0x0124 => 0x0263, 0x0125 => 0x02d2, 0x0126 => 0x02d2, 0x0127 => 0x02d2,
0x0128 => 0x030a, 0x0129 => 0x01f4, 0x012a => 0x029b, 0x012b => 0x0116,
0x012c => 0x022c, 0x012d => 0x0248, 0x012e => 0x0116, 0x012f => 0x0263,
0x0130 => 0x014d, 0x0131 => 0x0248, 0x0132 => 0x0263, 0x0133 => 0x0263,
0x0134 => 0x0225, 0x0135 => 0x0263, 0x0136 => 0x0263, 0x0137 => 0x01f4,
0x0138 => 0x0263, 0x0139 => 0x014d, 0x013a => 0x0116, 0x013b => 0x022c,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Helvetica-BoldOblique');
}
}

View File

@ -0,0 +1,301 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Helvetica-Oblique.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_HelveticaOblique extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00"
. "\x41\x00\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00"
. "\x76\x00\x65\x00\x64\x00\x2e\x00\x48\x00\x65\x00\x6c\x00\x76\x00"
. "\x65\x00\x74\x00\x69\x00\x63\x00\x61\x00\x20\x00\x69\x00\x73\x00"
. "\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00\x64\x00\x65\x00"
. "\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00\x66\x00\x20\x00"
. "\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00\x70\x00\x65\x00"
. "\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00\x41\x00\x47\x00"
. "\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00\x72\x00\x20\x00"
. "\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00\x62\x00\x73\x00"
. "\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00\x65\x00\x73\x00"
. "\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x35\x00\x35";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x2d\x00\x4f\x00\x62\x00\x6c\x00\x69\x00\x71\x00\x75\x00"
. "\x65\x00\x20\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x48\x00\x65\x00\x6c\x00\x76\x00\x65\x00\x74\x00\x69\x00\x63\x00"
. "\x61\x00\x2d\x00\x4f\x00\x62\x00\x6c\x00\x69\x00\x71\x00\x75\x00"
. "\x65";
$this->_isBold = false;
$this->_isItalic = true;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 718;
$this->_descent = -207;
$this->_lineGap = 275;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0116, 0x02 => 0x0116, 0x03 => 0x0163,
0x04 => 0x022c, 0x05 => 0x022c, 0x06 => 0x0379, 0x07 => 0x029b,
0x08 => 0xde, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x0185,
0x0c => 0x0248, 0x0d => 0x0116, 0x0e => 0x014d, 0x0f => 0x0116,
0x10 => 0x0116, 0x11 => 0x022c, 0x12 => 0x022c, 0x13 => 0x022c,
0x14 => 0x022c, 0x15 => 0x022c, 0x16 => 0x022c, 0x17 => 0x022c,
0x18 => 0x022c, 0x19 => 0x022c, 0x1a => 0x022c, 0x1b => 0x0116,
0x1c => 0x0116, 0x1d => 0x0248, 0x1e => 0x0248, 0x1f => 0x0248,
0x20 => 0x022c, 0x21 => 0x03f7, 0x22 => 0x029b, 0x23 => 0x029b,
0x24 => 0x02d2, 0x25 => 0x02d2, 0x26 => 0x029b, 0x27 => 0x0263,
0x28 => 0x030a, 0x29 => 0x02d2, 0x2a => 0x0116, 0x2b => 0x01f4,
0x2c => 0x029b, 0x2d => 0x022c, 0x2e => 0x0341, 0x2f => 0x02d2,
0x30 => 0x030a, 0x31 => 0x029b, 0x32 => 0x030a, 0x33 => 0x02d2,
0x34 => 0x029b, 0x35 => 0x0263, 0x36 => 0x02d2, 0x37 => 0x029b,
0x38 => 0x03b0, 0x39 => 0x029b, 0x3a => 0x029b, 0x3b => 0x0263,
0x3c => 0x0116, 0x3d => 0x0116, 0x3e => 0x0116, 0x3f => 0x01d5,
0x40 => 0x022c, 0x41 => 0xde, 0x42 => 0x022c, 0x43 => 0x022c,
0x44 => 0x01f4, 0x45 => 0x022c, 0x46 => 0x022c, 0x47 => 0x0116,
0x48 => 0x022c, 0x49 => 0x022c, 0x4a => 0xde, 0x4b => 0xde,
0x4c => 0x01f4, 0x4d => 0xde, 0x4e => 0x0341, 0x4f => 0x022c,
0x50 => 0x022c, 0x51 => 0x022c, 0x52 => 0x022c, 0x53 => 0x014d,
0x54 => 0x01f4, 0x55 => 0x0116, 0x56 => 0x022c, 0x57 => 0x01f4,
0x58 => 0x02d2, 0x59 => 0x01f4, 0x5a => 0x01f4, 0x5b => 0x01f4,
0x5c => 0x014e, 0x5d => 0x0104, 0x5e => 0x014e, 0x5f => 0x0248,
0x60 => 0x014d, 0x61 => 0x022c, 0x62 => 0x022c, 0x63 => 0xa7,
0x64 => 0x022c, 0x65 => 0x022c, 0x66 => 0x022c, 0x67 => 0x022c,
0x68 => 0xbf, 0x69 => 0x014d, 0x6a => 0x022c, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x01f4, 0x6e => 0x01f4, 0x6f => 0x022c,
0x70 => 0x022c, 0x71 => 0x022c, 0x72 => 0x0116, 0x73 => 0x0219,
0x74 => 0x015e, 0x75 => 0xde, 0x76 => 0x014d, 0x77 => 0x014d,
0x78 => 0x022c, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x0263,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x03e8, 0x8b => 0x0172,
0x8c => 0x022c, 0x8d => 0x030a, 0x8e => 0x03e8, 0x8f => 0x016d,
0x90 => 0x0379, 0x91 => 0x0116, 0x92 => 0xde, 0x93 => 0x0263,
0x94 => 0x03b0, 0x95 => 0x0263, 0x96 => 0x0116, 0x97 => 0x022c,
0x98 => 0x022c, 0x99 => 0x022c, 0x9a => 0x022c, 0x9b => 0x029b,
0x9c => 0x0248, 0x9d => 0x029b, 0x9e => 0x029b, 0x9f => 0x022c,
0xa0 => 0x02d2, 0xa1 => 0x01f4, 0xa2 => 0x01f4, 0xa3 => 0x022c,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x022c, 0xa7 => 0x02d2,
0xa8 => 0x022c, 0xa9 => 0x029b, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02e1, 0xad => 0x029b, 0xae => 0x01f4, 0xaf => 0x022c,
0xb0 => 0x02d2, 0xb1 => 0xde, 0xb2 => 0x022c, 0xb3 => 0x0263,
0xb4 => 0x02d2, 0xb5 => 0x022c, 0xb6 => 0x029b, 0xb7 => 0x01f4,
0xb8 => 0x01f4, 0xb9 => 0x0116, 0xba => 0x01d7, 0xbb => 0x02d2,
0xbc => 0x030a, 0xbd => 0x022c, 0xbe => 0x022c, 0xbf => 0x029b,
0xc0 => 0x014d, 0xc1 => 0x01f4, 0xc2 => 0x0263, 0xc3 => 0x029b,
0xc4 => 0x030a, 0xc5 => 0x02d2, 0xc6 => 0x029b, 0xc7 => 0x0283,
0xc8 => 0x02d2, 0xc9 => 0x022c, 0xca => 0x014d, 0xcb => 0x030a,
0xcc => 0x029b, 0xcd => 0x029b, 0xce => 0x0248, 0xcf => 0x022c,
0xd0 => 0x0263, 0xd1 => 0x01dc, 0xd2 => 0x01f4, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x029b, 0xd6 => 0x022c, 0xd7 => 0x022c,
0xd8 => 0x01f4, 0xd9 => 0x022c, 0xda => 0x022c, 0xdb => 0x02d2,
0xdc => 0x0116, 0xdd => 0x0248, 0xde => 0x0104, 0xdf => 0x02e1,
0xe0 => 0x030a, 0xe1 => 0x0116, 0xe2 => 0x0258, 0xe3 => 0x029b,
0xe4 => 0x014d, 0xe5 => 0x022c, 0xe6 => 0x0263, 0xe7 => 0x0263,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x02d2, 0xeb => 0xde,
0xec => 0x013d, 0xed => 0x022c, 0xee => 0x02d2, 0xef => 0x029b,
0xf0 => 0x029b, 0xf1 => 0x022c, 0xf2 => 0x01f4, 0xf3 => 0xde,
0xf4 => 0x030a, 0xf5 => 0x022c, 0xf6 => 0x022c, 0xf7 => 0x01f4,
0xf8 => 0x0116, 0xf9 => 0x030a, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x022c, 0xfd => 0x014d, 0xfe => 0x030a, 0xff => 0x022c,
0x0100 => 0x0116, 0x0101 => 0x022c, 0x0102 => 0x029b, 0x0103 => 0x022c,
0x0104 => 0x0342, 0x0105 => 0x029b, 0x0106 => 0x012b, 0x0107 => 0x029b,
0x0108 => 0x022c, 0x0109 => 0x03e8, 0x010a => 0x022c, 0x010b => 0x0116,
0x010c => 0x0116, 0x010d => 0x022c, 0x010e => 0x0342, 0x010f => 0x0225,
0x0110 => 0x022c, 0x0111 => 0x022c, 0x0112 => 0x02d2, 0x0113 => 0x029b,
0x0114 => 0x022c, 0x0115 => 0x022c, 0x0116 => 0x0342, 0x0117 => 0x029b,
0x0118 => 0x029b, 0x0119 => 0x030a, 0x011a => 0x0190, 0x011b => 0x022c,
0x011c => 0x02d2, 0x011d => 0x022c, 0x011e => 0x01c5, 0x011f => 0x02d2,
0x0120 => 0x014d, 0x0121 => 0x02d2, 0x0122 => 0x022c, 0x0123 => 0x02d2,
0x0124 => 0x022c, 0x0125 => 0x029b, 0x0126 => 0x029b, 0x0127 => 0x029b,
0x0128 => 0x030a, 0x0129 => 0x01f4, 0x012a => 0x029b, 0x012b => 0x0116,
0x012c => 0x01f4, 0x012d => 0x0248, 0x012e => 0x0116, 0x012f => 0x022c,
0x0130 => 0x0116, 0x0131 => 0x0248, 0x0132 => 0x022c, 0x0133 => 0x022c,
0x0134 => 0x0225, 0x0135 => 0x022c, 0x0136 => 0x022c, 0x0137 => 0x01f4,
0x0138 => 0x022c, 0x0139 => 0x014d, 0x013a => 0x0116, 0x013b => 0x022c,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Helvetica-Oblique');
}
}

View File

@ -0,0 +1,459 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Symbol.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_Symbol extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Instance Variables ****/
/**
* Array for conversion from local encoding to special font encoding.
* See {@link encodeString()}.
* @var array
*/
protected $_toFontEncoding = array(
0x20 => "\x20", 0x21 => "\x21", 0x2200 => "\x22", 0x23 => "\x23",
0x2203 => "\x24", 0x25 => "\x25", 0x26 => "\x26", 0x220b => "\x27",
0x28 => "\x28", 0x29 => "\x29", 0x2217 => "\x2a", 0x2b => "\x2b",
0x2c => "\x2c", 0x2212 => "\x2d", 0x2e => "\x2e", 0x2f => "\x2f",
0x30 => "\x30", 0x31 => "\x31", 0x32 => "\x32", 0x33 => "\x33",
0x34 => "\x34", 0x35 => "\x35", 0x36 => "\x36", 0x37 => "\x37",
0x38 => "\x38", 0x39 => "\x39", 0x3a => "\x3a", 0x3b => "\x3b",
0x3c => "\x3c", 0x3d => "\x3d", 0x3e => "\x3e", 0x3f => "\x3f",
0x2245 => "\x40", 0x0391 => "\x41", 0x0392 => "\x42", 0x03a7 => "\x43",
0x2206 => "\x44", 0x0395 => "\x45", 0x03a6 => "\x46", 0x0393 => "\x47",
0x0397 => "\x48", 0x0399 => "\x49", 0x03d1 => "\x4a", 0x039a => "\x4b",
0x039b => "\x4c", 0x039c => "\x4d", 0x039d => "\x4e", 0x039f => "\x4f",
0x03a0 => "\x50", 0x0398 => "\x51", 0x03a1 => "\x52", 0x03a3 => "\x53",
0x03a4 => "\x54", 0x03a5 => "\x55", 0x03c2 => "\x56", 0x2126 => "\x57",
0x039e => "\x58", 0x03a8 => "\x59", 0x0396 => "\x5a", 0x5b => "\x5b",
0x2234 => "\x5c", 0x5d => "\x5d", 0x22a5 => "\x5e", 0x5f => "\x5f",
0xf8e5 => "\x60", 0x03b1 => "\x61", 0x03b2 => "\x62", 0x03c7 => "\x63",
0x03b4 => "\x64", 0x03b5 => "\x65", 0x03c6 => "\x66", 0x03b3 => "\x67",
0x03b7 => "\x68", 0x03b9 => "\x69", 0x03d5 => "\x6a", 0x03ba => "\x6b",
0x03bb => "\x6c", 0xb5 => "\x6d", 0x03bd => "\x6e", 0x03bf => "\x6f",
0x03c0 => "\x70", 0x03b8 => "\x71", 0x03c1 => "\x72", 0x03c3 => "\x73",
0x03c4 => "\x74", 0x03c5 => "\x75", 0x03d6 => "\x76", 0x03c9 => "\x77",
0x03be => "\x78", 0x03c8 => "\x79", 0x03b6 => "\x7a", 0x7b => "\x7b",
0x7c => "\x7c", 0x7d => "\x7d", 0x223c => "\x7e", 0x20ac => "\xa0",
0x03d2 => "\xa1", 0x2032 => "\xa2", 0x2264 => "\xa3", 0x2044 => "\xa4",
0x221e => "\xa5", 0x0192 => "\xa6", 0x2663 => "\xa7", 0x2666 => "\xa8",
0x2665 => "\xa9", 0x2660 => "\xaa", 0x2194 => "\xab", 0x2190 => "\xac",
0x2191 => "\xad", 0x2192 => "\xae", 0x2193 => "\xaf", 0xb0 => "\xb0",
0xb1 => "\xb1", 0x2033 => "\xb2", 0x2265 => "\xb3", 0xd7 => "\xb4",
0x221d => "\xb5", 0x2202 => "\xb6", 0x2022 => "\xb7", 0xf7 => "\xb8",
0x2260 => "\xb9", 0x2261 => "\xba", 0x2248 => "\xbb", 0x2026 => "\xbc",
0xf8e6 => "\xbd", 0xf8e7 => "\xbe", 0x21b5 => "\xbf", 0x2135 => "\xc0",
0x2111 => "\xc1", 0x211c => "\xc2", 0x2118 => "\xc3", 0x2297 => "\xc4",
0x2295 => "\xc5", 0x2205 => "\xc6", 0x2229 => "\xc7", 0x222a => "\xc8",
0x2283 => "\xc9", 0x2287 => "\xca", 0x2284 => "\xcb", 0x2282 => "\xcc",
0x2286 => "\xcd", 0x2208 => "\xce", 0x2209 => "\xcf", 0x2220 => "\xd0",
0x2207 => "\xd1", 0xf6da => "\xd2", 0xf6d9 => "\xd3", 0xf6db => "\xd4",
0x220f => "\xd5", 0x221a => "\xd6", 0x22c5 => "\xd7", 0xac => "\xd8",
0x2227 => "\xd9", 0x2228 => "\xda", 0x21d4 => "\xdb", 0x21d0 => "\xdc",
0x21d1 => "\xdd", 0x21d2 => "\xde", 0x21d3 => "\xdf", 0x25ca => "\xe0",
0x2329 => "\xe1", 0xf8e8 => "\xe2", 0xf8e9 => "\xe3", 0xf8ea => "\xe4",
0x2211 => "\xe5", 0xf8eb => "\xe6", 0xf8ec => "\xe7", 0xf8ed => "\xe8",
0xf8ee => "\xe9", 0xf8ef => "\xea", 0xf8f0 => "\xeb", 0xf8f1 => "\xec",
0xf8f2 => "\xed", 0xf8f3 => "\xee", 0xf8f4 => "\xef", 0x232a => "\xf1",
0x222b => "\xf2", 0x2320 => "\xf3", 0xf8f5 => "\xf4", 0x2321 => "\xf5",
0xf8f6 => "\xf6", 0xf8f7 => "\xf7", 0xf8f8 => "\xf8", 0xf8f9 => "\xf9",
0xf8fa => "\xfa", 0xf8fb => "\xfb", 0xf8fc => "\xfc", 0xf8fd => "\xfd",
0xf8fe => "\xfe");
/**
* Array for conversion from special font encoding to local encoding.
* See {@link decodeString()}.
* @var array
*/
protected $_fromFontEncoding = array(
0x20 => "\x00\x20", 0x21 => "\x00\x21", 0x22 => "\x22\x00",
0x23 => "\x00\x23", 0x24 => "\x22\x03", 0x25 => "\x00\x25",
0x26 => "\x00\x26", 0x27 => "\x22\x0b", 0x28 => "\x00\x28",
0x29 => "\x00\x29", 0x2a => "\x22\x17", 0x2b => "\x00\x2b",
0x2c => "\x00\x2c", 0x2d => "\x22\x12", 0x2e => "\x00\x2e",
0x2f => "\x00\x2f", 0x30 => "\x00\x30", 0x31 => "\x00\x31",
0x32 => "\x00\x32", 0x33 => "\x00\x33", 0x34 => "\x00\x34",
0x35 => "\x00\x35", 0x36 => "\x00\x36", 0x37 => "\x00\x37",
0x38 => "\x00\x38", 0x39 => "\x00\x39", 0x3a => "\x00\x3a",
0x3b => "\x00\x3b", 0x3c => "\x00\x3c", 0x3d => "\x00\x3d",
0x3e => "\x00\x3e", 0x3f => "\x00\x3f", 0x40 => "\x22\x45",
0x41 => "\x03\x91", 0x42 => "\x03\x92", 0x43 => "\x03\xa7",
0x44 => "\x22\x06", 0x45 => "\x03\x95", 0x46 => "\x03\xa6",
0x47 => "\x03\x93", 0x48 => "\x03\x97", 0x49 => "\x03\x99",
0x4a => "\x03\xd1", 0x4b => "\x03\x9a", 0x4c => "\x03\x9b",
0x4d => "\x03\x9c", 0x4e => "\x03\x9d", 0x4f => "\x03\x9f",
0x50 => "\x03\xa0", 0x51 => "\x03\x98", 0x52 => "\x03\xa1",
0x53 => "\x03\xa3", 0x54 => "\x03\xa4", 0x55 => "\x03\xa5",
0x56 => "\x03\xc2", 0x57 => "\x21\x26", 0x58 => "\x03\x9e",
0x59 => "\x03\xa8", 0x5a => "\x03\x96", 0x5b => "\x00\x5b",
0x5c => "\x22\x34", 0x5d => "\x00\x5d", 0x5e => "\x22\xa5",
0x5f => "\x00\x5f", 0x60 => "\xf8\xe5", 0x61 => "\x03\xb1",
0x62 => "\x03\xb2", 0x63 => "\x03\xc7", 0x64 => "\x03\xb4",
0x65 => "\x03\xb5", 0x66 => "\x03\xc6", 0x67 => "\x03\xb3",
0x68 => "\x03\xb7", 0x69 => "\x03\xb9", 0x6a => "\x03\xd5",
0x6b => "\x03\xba", 0x6c => "\x03\xbb", 0x6d => "\x00\xb5",
0x6e => "\x03\xbd", 0x6f => "\x03\xbf", 0x70 => "\x03\xc0",
0x71 => "\x03\xb8", 0x72 => "\x03\xc1", 0x73 => "\x03\xc3",
0x74 => "\x03\xc4", 0x75 => "\x03\xc5", 0x76 => "\x03\xd6",
0x77 => "\x03\xc9", 0x78 => "\x03\xbe", 0x79 => "\x03\xc8",
0x7a => "\x03\xb6", 0x7b => "\x00\x7b", 0x7c => "\x00\x7c",
0x7d => "\x00\x7d", 0x7e => "\x22\x3c", 0xa0 => "\x20\xac",
0xa1 => "\x03\xd2", 0xa2 => "\x20\x32", 0xa3 => "\x22\x64",
0xa4 => "\x20\x44", 0xa5 => "\x22\x1e", 0xa6 => "\x01\x92",
0xa7 => "\x26\x63", 0xa8 => "\x26\x66", 0xa9 => "\x26\x65",
0xaa => "\x26\x60", 0xab => "\x21\x94", 0xac => "\x21\x90",
0xad => "\x21\x91", 0xae => "\x21\x92", 0xaf => "\x21\x93",
0xb0 => "\x00\xb0", 0xb1 => "\x00\xb1", 0xb2 => "\x20\x33",
0xb3 => "\x22\x65", 0xb4 => "\x00\xd7", 0xb5 => "\x22\x1d",
0xb6 => "\x22\x02", 0xb7 => "\x20\x22", 0xb8 => "\x00\xf7",
0xb9 => "\x22\x60", 0xba => "\x22\x61", 0xbb => "\x22\x48",
0xbc => "\x20\x26", 0xbd => "\xf8\xe6", 0xbe => "\xf8\xe7",
0xbf => "\x21\xb5", 0xc0 => "\x21\x35", 0xc1 => "\x21\x11",
0xc2 => "\x21\x1c", 0xc3 => "\x21\x18", 0xc4 => "\x22\x97",
0xc5 => "\x22\x95", 0xc6 => "\x22\x05", 0xc7 => "\x22\x29",
0xc8 => "\x22\x2a", 0xc9 => "\x22\x83", 0xca => "\x22\x87",
0xcb => "\x22\x84", 0xcc => "\x22\x82", 0xcd => "\x22\x86",
0xce => "\x22\x08", 0xcf => "\x22\x09", 0xd0 => "\x22\x20",
0xd1 => "\x22\x07", 0xd2 => "\xf6\xda", 0xd3 => "\xf6\xd9",
0xd4 => "\xf6\xdb", 0xd5 => "\x22\x0f", 0xd6 => "\x22\x1a",
0xd7 => "\x22\xc5", 0xd8 => "\x00\xac", 0xd9 => "\x22\x27",
0xda => "\x22\x28", 0xdb => "\x21\xd4", 0xdc => "\x21\xd0",
0xdd => "\x21\xd1", 0xde => "\x21\xd2", 0xdf => "\x21\xd3",
0xe0 => "\x25\xca", 0xe1 => "\x23\x29", 0xe2 => "\xf8\xe8",
0xe3 => "\xf8\xe9", 0xe4 => "\xf8\xea", 0xe5 => "\x22\x11",
0xe6 => "\xf8\xeb", 0xe7 => "\xf8\xec", 0xe8 => "\xf8\xed",
0xe9 => "\xf8\xee", 0xea => "\xf8\xef", 0xeb => "\xf8\xf0",
0xec => "\xf8\xf1", 0xed => "\xf8\xf2", 0xee => "\xf8\xf3",
0xef => "\xf8\xf4", 0xf1 => "\x23\x2a", 0xf2 => "\x22\x2b",
0xf3 => "\x23\x20", 0xf4 => "\xf8\xf5", 0xf5 => "\x23\x21",
0xf6 => "\xf8\xf6", 0xf7 => "\xf8\xf7", 0xf8 => "\xf8\xf8",
0xf9 => "\xf8\xf9", 0xfa => "\xf8\xfa", 0xfb => "\xf8\xfb",
0xfc => "\xf8\xfc", 0xfd => "\xf8\xfd", 0xfe => "\xf8\xfe",
);
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x41\x00"
. "\x6c\x00\x6c\x00\x20\x00\x72\x00\x69\x00\x67\x00\x68\x00\x74\x00"
. "\x73\x00\x20\x00\x72\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00"
. "\x65\x00\x64\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x53\x00\x79\x00\x6d\x00\x62\x00\x6f\x00\x6c";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x36\x00\x34";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x53\x00\x79\x00\x6d\x00\x62\x00\x6f\x00\x6c\x00\x20\x00\x4d\x00"
. "\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x31\x00\x2e\x00\x30\x00\x30\x00\x38";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x53\x00\x79\x00\x6d\x00\x62\x00\x6f\x00\x6c";
$this->_isBold = false;
$this->_isItalic = false;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 1000;
$this->_descent = 0;
$this->_lineGap = 200;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0xfa, 0x02 => 0x014d, 0x03 => 0x02c9,
0x04 => 0x01f4, 0x05 => 0x0225, 0x06 => 0x0341, 0x07 => 0x030a,
0x08 => 0x01b7, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x01f4,
0x0c => 0x0225, 0x0d => 0xfa, 0x0e => 0x0225, 0x0f => 0xfa,
0x10 => 0x0116, 0x11 => 0x01f4, 0x12 => 0x01f4, 0x13 => 0x01f4,
0x14 => 0x01f4, 0x15 => 0x01f4, 0x16 => 0x01f4, 0x17 => 0x01f4,
0x18 => 0x01f4, 0x19 => 0x01f4, 0x1a => 0x01f4, 0x1b => 0x0116,
0x1c => 0x0116, 0x1d => 0x0225, 0x1e => 0x0225, 0x1f => 0x0225,
0x20 => 0x01bc, 0x21 => 0x0225, 0x22 => 0x02d2, 0x23 => 0x029b,
0x24 => 0x02d2, 0x25 => 0x0264, 0x26 => 0x0263, 0x27 => 0x02fb,
0x28 => 0x025b, 0x29 => 0x02d2, 0x2a => 0x014d, 0x2b => 0x0277,
0x2c => 0x02d2, 0x2d => 0x02ae, 0x2e => 0x0379, 0x2f => 0x02d2,
0x30 => 0x02d2, 0x31 => 0x0300, 0x32 => 0x02e5, 0x33 => 0x022c,
0x34 => 0x0250, 0x35 => 0x0263, 0x36 => 0x02b2, 0x37 => 0x01b7,
0x38 => 0x0300, 0x39 => 0x0285, 0x3a => 0x031b, 0x3b => 0x0263,
0x3c => 0x014d, 0x3d => 0x035f, 0x3e => 0x014d, 0x3f => 0x0292,
0x40 => 0x01f4, 0x41 => 0x01f4, 0x42 => 0x0277, 0x43 => 0x0225,
0x44 => 0x0225, 0x45 => 0x01ee, 0x46 => 0x01b7, 0x47 => 0x0209,
0x48 => 0x019b, 0x49 => 0x025b, 0x4a => 0x0149, 0x4b => 0x025b,
0x4c => 0x0225, 0x4d => 0x0225, 0x4e => 0x0240, 0x4f => 0x0209,
0x50 => 0x0225, 0x51 => 0x0225, 0x52 => 0x0209, 0x53 => 0x0225,
0x54 => 0x025b, 0x55 => 0x01b7, 0x56 => 0x0240, 0x57 => 0x02c9,
0x58 => 0x02ae, 0x59 => 0x01ed, 0x5a => 0x02ae, 0x5b => 0x01ee,
0x5c => 0x01e0, 0x5d => 0xc8, 0x5e => 0x01e0, 0x5f => 0x0225,
0x60 => 0x02ee, 0x61 => 0x026c, 0x62 => 0xf7, 0x63 => 0x0225,
0x64 => 0xa7, 0x65 => 0x02c9, 0x66 => 0x01f4, 0x67 => 0x02f1,
0x68 => 0x02f1, 0x69 => 0x02f1, 0x6a => 0x02f1, 0x6b => 0x0412,
0x6c => 0x03db, 0x6d => 0x025b, 0x6e => 0x03db, 0x6f => 0x025b,
0x70 => 0x0190, 0x71 => 0x0225, 0x72 => 0x019b, 0x73 => 0x0225,
0x74 => 0x0225, 0x75 => 0x02c9, 0x76 => 0x01ee, 0x77 => 0x01cc,
0x78 => 0x0225, 0x79 => 0x0225, 0x7a => 0x0225, 0x7b => 0x0225,
0x7c => 0x03e8, 0x7d => 0x025b, 0x7e => 0x03e8, 0x7f => 0x0292,
0x80 => 0x0337, 0x81 => 0x02ae, 0x82 => 0x031b, 0x83 => 0x03db,
0x84 => 0x0300, 0x85 => 0x0300, 0x86 => 0x0337, 0x87 => 0x0300,
0x88 => 0x0300, 0x89 => 0x02c9, 0x8a => 0x02c9, 0x8b => 0x02c9,
0x8c => 0x02c9, 0x8d => 0x02c9, 0x8e => 0x02c9, 0x8f => 0x02c9,
0x90 => 0x0300, 0x91 => 0x02c9, 0x92 => 0x0316, 0x93 => 0x0316,
0x94 => 0x037a, 0x95 => 0x0337, 0x96 => 0x0225, 0x97 => 0xfa,
0x98 => 0x02c9, 0x99 => 0x025b, 0x9a => 0x025b, 0x9b => 0x0412,
0x9c => 0x03db, 0x9d => 0x025b, 0x9e => 0x03db, 0x9f => 0x025b,
0xa0 => 0x01ee, 0xa1 => 0x0149, 0xa2 => 0x0316, 0xa3 => 0x0316,
0xa4 => 0x0312, 0xa5 => 0x02c9, 0xa6 => 0x0180, 0xa7 => 0x0180,
0xa8 => 0x0180, 0xa9 => 0x0180, 0xaa => 0x0180, 0xab => 0x0180,
0xac => 0x01ee, 0xad => 0x01ee, 0xae => 0x01ee, 0xaf => 0x01ee,
0xb0 => 0x0149, 0xb1 => 0x0112, 0xb2 => 0x02ae, 0xb3 => 0x02ae,
0xb4 => 0x02ae, 0xb5 => 0x0180, 0xb6 => 0x0180, 0xb7 => 0x0180,
0xb8 => 0x0180, 0xb9 => 0x0180, 0xba => 0x0180, 0xbb => 0x01ee,
0xbc => 0x01ee, 0xbd => 0x01ee, 0xbe => 0x0316);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x2200 => 0x03, 0x23 => 0x04,
0x2203 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x220b => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2217 => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2212 => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x2245 => 0x21, 0x0391 => 0x22, 0x0392 => 0x23, 0x03a7 => 0x24,
0x2206 => 0x25, 0x0395 => 0x26, 0x03a6 => 0x27, 0x0393 => 0x28,
0x0397 => 0x29, 0x0399 => 0x2a, 0x03d1 => 0x2b, 0x039a => 0x2c,
0x039b => 0x2d, 0x039c => 0x2e, 0x039d => 0x2f, 0x039f => 0x30,
0x03a0 => 0x31, 0x0398 => 0x32, 0x03a1 => 0x33, 0x03a3 => 0x34,
0x03a4 => 0x35, 0x03a5 => 0x36, 0x03c2 => 0x37, 0x2126 => 0x38,
0x039e => 0x39, 0x03a8 => 0x3a, 0x0396 => 0x3b, 0x5b => 0x3c,
0x2234 => 0x3d, 0x5d => 0x3e, 0x22a5 => 0x3f, 0x5f => 0x40,
0xf8e5 => 0x41, 0x03b1 => 0x42, 0x03b2 => 0x43, 0x03c7 => 0x44,
0x03b4 => 0x45, 0x03b5 => 0x46, 0x03c6 => 0x47, 0x03b3 => 0x48,
0x03b7 => 0x49, 0x03b9 => 0x4a, 0x03d5 => 0x4b, 0x03ba => 0x4c,
0x03bb => 0x4d, 0xb5 => 0x4e, 0x03bd => 0x4f, 0x03bf => 0x50,
0x03c0 => 0x51, 0x03b8 => 0x52, 0x03c1 => 0x53, 0x03c3 => 0x54,
0x03c4 => 0x55, 0x03c5 => 0x56, 0x03d6 => 0x57, 0x03c9 => 0x58,
0x03be => 0x59, 0x03c8 => 0x5a, 0x03b6 => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x223c => 0x5f, 0x20ac => 0x60,
0x03d2 => 0x61, 0x2032 => 0x62, 0x2264 => 0x63, 0x2044 => 0x64,
0x221e => 0x65, 0x0192 => 0x66, 0x2663 => 0x67, 0x2666 => 0x68,
0x2665 => 0x69, 0x2660 => 0x6a, 0x2194 => 0x6b, 0x2190 => 0x6c,
0x2191 => 0x6d, 0x2192 => 0x6e, 0x2193 => 0x6f, 0xb0 => 0x70,
0xb1 => 0x71, 0x2033 => 0x72, 0x2265 => 0x73, 0xd7 => 0x74,
0x221d => 0x75, 0x2202 => 0x76, 0x2022 => 0x77, 0xf7 => 0x78,
0x2260 => 0x79, 0x2261 => 0x7a, 0x2248 => 0x7b, 0x2026 => 0x7c,
0xf8e6 => 0x7d, 0xf8e7 => 0x7e, 0x21b5 => 0x7f, 0x2135 => 0x80,
0x2111 => 0x81, 0x211c => 0x82, 0x2118 => 0x83, 0x2297 => 0x84,
0x2295 => 0x85, 0x2205 => 0x86, 0x2229 => 0x87, 0x222a => 0x88,
0x2283 => 0x89, 0x2287 => 0x8a, 0x2284 => 0x8b, 0x2282 => 0x8c,
0x2286 => 0x8d, 0x2208 => 0x8e, 0x2209 => 0x8f, 0x2220 => 0x90,
0x2207 => 0x91, 0xf6da => 0x92, 0xf6d9 => 0x93, 0xf6db => 0x94,
0x220f => 0x95, 0x221a => 0x96, 0x22c5 => 0x97, 0xac => 0x98,
0x2227 => 0x99, 0x2228 => 0x9a, 0x21d4 => 0x9b, 0x21d0 => 0x9c,
0x21d1 => 0x9d, 0x21d2 => 0x9e, 0x21d3 => 0x9f, 0x25ca => 0xa0,
0x2329 => 0xa1, 0xf8e8 => 0xa2, 0xf8e9 => 0xa3, 0xf8ea => 0xa4,
0x2211 => 0xa5, 0xf8eb => 0xa6, 0xf8ec => 0xa7, 0xf8ed => 0xa8,
0xf8ee => 0xa9, 0xf8ef => 0xaa, 0xf8f0 => 0xab, 0xf8f1 => 0xac,
0xf8f2 => 0xad, 0xf8f3 => 0xae, 0xf8f4 => 0xaf, 0x232a => 0xb0,
0x222b => 0xb1, 0x2320 => 0xb2, 0xf8f5 => 0xb3, 0x2321 => 0xb4,
0xf8f6 => 0xb5, 0xf8f7 => 0xb6, 0xf8f8 => 0xb7, 0xf8f9 => 0xb8,
0xf8fa => 0xb9, 0xf8fb => 0xba, 0xf8fc => 0xbb, 0xf8fd => 0xbc,
0xf8fe => 0xbd, 0xf8ff => 0xbe);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Symbol');
/* This font has a built-in custom character encoding method. Don't
* override with WinAnsi like the other built-in fonts or else it will
* not work as expected.
*/
$this->_resource->Encoding = null;
}
/* Information and Conversion Methods */
/**
* Convert string encoding from local encoding to font encoding. Overridden
* to defeat the conversion behavior for this ornamental font.
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
*/
public function encodeString($string, $charEncoding)
{
/* This isn't the optimal time to perform this conversion, but it must
* live here until the remainder of the layout code is completed. This,
* and the $charEncoding parameter, will go away soon...
*/
if ($charEncoding != 'UTF-16BE') {
$string = iconv($charEncoding, 'UTF-16BE', $string);
}
/**
* @todo Properly handle characters encoded as surrogate pairs.
*/
$encodedString = '';
for ($i = 0; $i < strlen($string); $i++) {
$characterCode = (ord($string[$i++]) << 8) | ord($string[$i]);
if (isset($this->_toFontEncoding[$characterCode])) {
$encodedString .= $this->_toFontEncoding[$characterCode];
} else {
/* For now, mimic the behavior in Zend_Pdf_Font::encodeString()
* where unknown characters are removed completely. This is not
* perfect, but we should be consistent. In a future revision,
* we will use the well-known substitution character 0x1a
* (Control-Z).
*/
}
}
return $encodedString;
}
/**
* Convert string encoding from font encoding to local encoding. Overridden
* to defeat the conversion behavior for this ornamental font.
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
*/
public function decodeString($string, $charEncoding)
{
$decodedString = '';
for ($i = 0; $i < strlen($string); $i++) {
$characterCode = ord($string[$i]);
if (isset($this->_fromFontEncoding[$characterCode])) {
$decodedString .= $this->_fromFontEncoding[$characterCode];
} else {
/* For now, mimic the behavior in Zend_Pdf_Font::encodeString()
* where unknown characters are removed completely. This is not
* perfect, but we should be consistent. In a future revision,
* we will use the Unicode substitution character (U+FFFD).
*/
}
}
if ($charEncoding != 'UTF-16BE') {
$decodedString = iconv('UTF-16BE', $charEncoding, $decodedString);
}
return $decodedString;
}
/**
* Converts a Latin-encoded string that fakes the font's internal encoding
* to the proper Unicode characters, in UTF-16BE encoding.
*
* Used to maintain backwards compatibility with the 20 year-old legacy
* method of using this font, which is still employed by recent versions of
* some popular word processors.
*
* Note that using this method adds overhead due to the additional
* character conversion. Don't use this for new code; it is more efficient
* to use the appropriate Unicode characters directly.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source
* string. Defaults to current locale.
* @return string
*/
public function toUnicode($string, $charEncoding = '')
{
/* When using these faked strings, the closest match to the font's
* internal encoding is ISO-8859-1.
*/
if ($charEncoding != 'ISO-8859-1') {
$string = iconv($charEncoding, 'ISO-8859-1', $string);
}
return $this->decodeString($string, 'UTF-16BE');
}
}

View File

@ -0,0 +1,298 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Times-Bold.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_TimesBold extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x37\x00"
. "\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00\x20\x00\x53\x00"
. "\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00\x20\x00\x49\x00"
. "\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00\x41\x00\x6c\x00"
. "\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00\x73\x00"
. "\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00\x65\x00"
. "\x64\x00\x2e\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x20\x00"
. "\x69\x00\x73\x00\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00"
. "\x64\x00\x65\x00\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00"
. "\x66\x00\x20\x00\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00"
. "\x70\x00\x65\x00\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00"
. "\x41\x00\x47\x00\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00"
. "\x72\x00\x20\x00\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00"
. "\x62\x00\x73\x00\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00"
. "\x65\x00\x73\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x36\x00\x35";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x42\x00\x6f\x00"
. "\x6c\x00\x64\x00\x20\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x42\x00\x6f\x00"
. "\x6c\x00\x64";
$this->_isBold = true;
$this->_isItalic = false;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 683;
$this->_descent = -217;
$this->_lineGap = 300;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0xfa, 0x02 => 0x014d, 0x03 => 0x022b,
0x04 => 0x01f4, 0x05 => 0x01f4, 0x06 => 0x03e8, 0x07 => 0x0341,
0x08 => 0x014d, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x01f4,
0x0c => 0x023a, 0x0d => 0xfa, 0x0e => 0x014d, 0x0f => 0xfa,
0x10 => 0x0116, 0x11 => 0x01f4, 0x12 => 0x01f4, 0x13 => 0x01f4,
0x14 => 0x01f4, 0x15 => 0x01f4, 0x16 => 0x01f4, 0x17 => 0x01f4,
0x18 => 0x01f4, 0x19 => 0x01f4, 0x1a => 0x01f4, 0x1b => 0x014d,
0x1c => 0x014d, 0x1d => 0x023a, 0x1e => 0x023a, 0x1f => 0x023a,
0x20 => 0x01f4, 0x21 => 0x03a2, 0x22 => 0x02d2, 0x23 => 0x029b,
0x24 => 0x02d2, 0x25 => 0x02d2, 0x26 => 0x029b, 0x27 => 0x0263,
0x28 => 0x030a, 0x29 => 0x030a, 0x2a => 0x0185, 0x2b => 0x01f4,
0x2c => 0x030a, 0x2d => 0x029b, 0x2e => 0x03b0, 0x2f => 0x02d2,
0x30 => 0x030a, 0x31 => 0x0263, 0x32 => 0x030a, 0x33 => 0x02d2,
0x34 => 0x022c, 0x35 => 0x029b, 0x36 => 0x02d2, 0x37 => 0x02d2,
0x38 => 0x03e8, 0x39 => 0x02d2, 0x3a => 0x02d2, 0x3b => 0x029b,
0x3c => 0x014d, 0x3d => 0x0116, 0x3e => 0x014d, 0x3f => 0x0245,
0x40 => 0x01f4, 0x41 => 0x014d, 0x42 => 0x01f4, 0x43 => 0x022c,
0x44 => 0x01bc, 0x45 => 0x022c, 0x46 => 0x01bc, 0x47 => 0x014d,
0x48 => 0x01f4, 0x49 => 0x022c, 0x4a => 0x0116, 0x4b => 0x014d,
0x4c => 0x022c, 0x4d => 0x0116, 0x4e => 0x0341, 0x4f => 0x022c,
0x50 => 0x01f4, 0x51 => 0x022c, 0x52 => 0x022c, 0x53 => 0x01bc,
0x54 => 0x0185, 0x55 => 0x014d, 0x56 => 0x022c, 0x57 => 0x01f4,
0x58 => 0x02d2, 0x59 => 0x01f4, 0x5a => 0x01f4, 0x5b => 0x01bc,
0x5c => 0x018a, 0x5d => 0xdc, 0x5e => 0x018a, 0x5f => 0x0208,
0x60 => 0x014d, 0x61 => 0x01f4, 0x62 => 0x01f4, 0x63 => 0xa7,
0x64 => 0x01f4, 0x65 => 0x01f4, 0x66 => 0x01f4, 0x67 => 0x01f4,
0x68 => 0x0116, 0x69 => 0x01f4, 0x6a => 0x01f4, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x022c, 0x6e => 0x022c, 0x6f => 0x01f4,
0x70 => 0x01f4, 0x71 => 0x01f4, 0x72 => 0xfa, 0x73 => 0x021c,
0x74 => 0x015e, 0x75 => 0x014d, 0x76 => 0x01f4, 0x77 => 0x01f4,
0x78 => 0x01f4, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x01f4,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x03e8, 0x8b => 0x012c,
0x8c => 0x029b, 0x8d => 0x030a, 0x8e => 0x03e8, 0x8f => 0x014a,
0x90 => 0x02d2, 0x91 => 0x0116, 0x92 => 0x0116, 0x93 => 0x01f4,
0x94 => 0x02d2, 0x95 => 0x022c, 0x96 => 0x0185, 0x97 => 0x01bc,
0x98 => 0x01f4, 0x99 => 0x022c, 0x9a => 0x01bc, 0x9b => 0x02d2,
0x9c => 0x023a, 0x9d => 0x02d2, 0x9e => 0x02d2, 0x9f => 0x01f4,
0xa0 => 0x02d2, 0xa1 => 0x01f4, 0xa2 => 0x0185, 0xa3 => 0x01bc,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x01f4, 0xa7 => 0x02d2,
0xa8 => 0x022c, 0xa9 => 0x029b, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02eb, 0xad => 0x029b, 0xae => 0x01bc, 0xaf => 0x01f4,
0xb0 => 0x02d2, 0xb1 => 0x0116, 0xb2 => 0x01f4, 0xb3 => 0x029b,
0xb4 => 0x02d2, 0xb5 => 0x01f4, 0xb6 => 0x029b, 0xb7 => 0x0185,
0xb8 => 0x0185, 0xb9 => 0x0116, 0xba => 0x01ee, 0xbb => 0x02d2,
0xbc => 0x030a, 0xbd => 0x022c, 0xbe => 0x01f4, 0xbf => 0x02d2,
0xc0 => 0x01bc, 0xc1 => 0x01bc, 0xc2 => 0x029b, 0xc3 => 0x0263,
0xc4 => 0x030a, 0xc5 => 0x02d2, 0xc6 => 0x022c, 0xc7 => 0x02a0,
0xc8 => 0x02d2, 0xc9 => 0x022c, 0xca => 0x012c, 0xcb => 0x030a,
0xcc => 0x02d2, 0xcd => 0x02d2, 0xce => 0x023a, 0xcf => 0x022c,
0xd0 => 0x029b, 0xd1 => 0x01ee, 0xd2 => 0x01f4, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x029b, 0xd6 => 0x01f4, 0xd7 => 0x01bc,
0xd8 => 0x01bc, 0xd9 => 0x022c, 0xda => 0x022c, 0xdb => 0x02d2,
0xdc => 0x0185, 0xdd => 0x023a, 0xde => 0xdc, 0xdf => 0x02eb,
0xe0 => 0x030a, 0xe1 => 0x0185, 0xe2 => 0x0258, 0xe3 => 0x029b,
0xe4 => 0x01bc, 0xe5 => 0x01f4, 0xe6 => 0x029b, 0xe7 => 0x029b,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x02d2, 0xeb => 0x0116,
0xec => 0x01a0, 0xed => 0x01bc, 0xee => 0x02d2, 0xef => 0x02d2,
0xf0 => 0x02d2, 0xf1 => 0x01bc, 0xf2 => 0x01bc, 0xf3 => 0x0116,
0xf4 => 0x030a, 0xf5 => 0x01f4, 0xf6 => 0x01f4, 0xf7 => 0x0185,
0xf8 => 0x0116, 0xf9 => 0x030a, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x022c, 0xfd => 0x012c, 0xfe => 0x030a, 0xff => 0x022c,
0x0100 => 0x0116, 0x0101 => 0x01f4, 0x0102 => 0x029b, 0x0103 => 0x022c,
0x0104 => 0x02ee, 0x0105 => 0x022c, 0x0106 => 0x018a, 0x0107 => 0x030a,
0x0108 => 0x029b, 0x0109 => 0x03e8, 0x010a => 0x01bc, 0x010b => 0x0185,
0x010c => 0x0185, 0x010d => 0x029b, 0x010e => 0x02ee, 0x010f => 0x0225,
0x0110 => 0x01f4, 0x0111 => 0x022c, 0x0112 => 0x02d2, 0x0113 => 0x029b,
0x0114 => 0x01bc, 0x0115 => 0x01f4, 0x0116 => 0x02ee, 0x0117 => 0x022c,
0x0118 => 0x022c, 0x0119 => 0x030a, 0x011a => 0x0190, 0x011b => 0x01f4,
0x011c => 0x02d2, 0x011d => 0x022c, 0x011e => 0x0225, 0x011f => 0x02d2,
0x0120 => 0x01bc, 0x0121 => 0x02d2, 0x0122 => 0x01f4, 0x0123 => 0x02d2,
0x0124 => 0x029b, 0x0125 => 0x02d2, 0x0126 => 0x02d2, 0x0127 => 0x02d2,
0x0128 => 0x030a, 0x0129 => 0x01bc, 0x012a => 0x029b, 0x012b => 0x0185,
0x012c => 0x022c, 0x012d => 0x023a, 0x012e => 0x0185, 0x012f => 0x022c,
0x0130 => 0x014d, 0x0131 => 0x023a, 0x0132 => 0x01f4, 0x0133 => 0x022c,
0x0134 => 0x0225, 0x0135 => 0x01f4, 0x0136 => 0x01f4, 0x0137 => 0x01bc,
0x0138 => 0x022c, 0x0139 => 0x012c, 0x013a => 0x0116, 0x013b => 0x01f4,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Times-Bold');
}
}

View File

@ -0,0 +1,299 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Times-BoldItalic.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_TimesBoldItalic extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x37\x00"
. "\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00\x20\x00\x53\x00"
. "\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00\x20\x00\x49\x00"
. "\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00\x41\x00\x6c\x00"
. "\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00\x73\x00"
. "\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00\x65\x00"
. "\x64\x00\x2e\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x20\x00"
. "\x69\x00\x73\x00\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00"
. "\x64\x00\x65\x00\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00"
. "\x66\x00\x20\x00\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00"
. "\x70\x00\x65\x00\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00"
. "\x41\x00\x47\x00\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00"
. "\x72\x00\x20\x00\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00"
. "\x62\x00\x73\x00\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00"
. "\x65\x00\x73\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x36\x00\x36";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x42\x00\x6f\x00"
. "\x6c\x00\x64\x00\x49\x00\x74\x00\x61\x00\x6c\x00\x69\x00\x63\x00"
. "\x20\x00\x42\x00\x6f\x00\x6c\x00\x64";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x42\x00\x6f\x00"
. "\x6c\x00\x64\x00\x49\x00\x74\x00\x61\x00\x6c\x00\x69\x00\x63";
$this->_isBold = true;
$this->_isItalic = true;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 683;
$this->_descent = -217;
$this->_lineGap = 300;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0xfa, 0x02 => 0x0185, 0x03 => 0x022b,
0x04 => 0x01f4, 0x05 => 0x01f4, 0x06 => 0x0341, 0x07 => 0x030a,
0x08 => 0x014d, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x01f4,
0x0c => 0x023a, 0x0d => 0xfa, 0x0e => 0x014d, 0x0f => 0xfa,
0x10 => 0x0116, 0x11 => 0x01f4, 0x12 => 0x01f4, 0x13 => 0x01f4,
0x14 => 0x01f4, 0x15 => 0x01f4, 0x16 => 0x01f4, 0x17 => 0x01f4,
0x18 => 0x01f4, 0x19 => 0x01f4, 0x1a => 0x01f4, 0x1b => 0x014d,
0x1c => 0x014d, 0x1d => 0x023a, 0x1e => 0x023a, 0x1f => 0x023a,
0x20 => 0x01f4, 0x21 => 0x0340, 0x22 => 0x029b, 0x23 => 0x029b,
0x24 => 0x029b, 0x25 => 0x02d2, 0x26 => 0x029b, 0x27 => 0x029b,
0x28 => 0x02d2, 0x29 => 0x030a, 0x2a => 0x0185, 0x2b => 0x01f4,
0x2c => 0x029b, 0x2d => 0x0263, 0x2e => 0x0379, 0x2f => 0x02d2,
0x30 => 0x02d2, 0x31 => 0x0263, 0x32 => 0x02d2, 0x33 => 0x029b,
0x34 => 0x022c, 0x35 => 0x0263, 0x36 => 0x02d2, 0x37 => 0x029b,
0x38 => 0x0379, 0x39 => 0x029b, 0x3a => 0x0263, 0x3b => 0x0263,
0x3c => 0x014d, 0x3d => 0x0116, 0x3e => 0x014d, 0x3f => 0x023a,
0x40 => 0x01f4, 0x41 => 0x014d, 0x42 => 0x01f4, 0x43 => 0x01f4,
0x44 => 0x01bc, 0x45 => 0x01f4, 0x46 => 0x01bc, 0x47 => 0x014d,
0x48 => 0x01f4, 0x49 => 0x022c, 0x4a => 0x0116, 0x4b => 0x0116,
0x4c => 0x01f4, 0x4d => 0x0116, 0x4e => 0x030a, 0x4f => 0x022c,
0x50 => 0x01f4, 0x51 => 0x01f4, 0x52 => 0x01f4, 0x53 => 0x0185,
0x54 => 0x0185, 0x55 => 0x0116, 0x56 => 0x022c, 0x57 => 0x01bc,
0x58 => 0x029b, 0x59 => 0x01f4, 0x5a => 0x01bc, 0x5b => 0x0185,
0x5c => 0x015c, 0x5d => 0xdc, 0x5e => 0x015c, 0x5f => 0x023a,
0x60 => 0x0185, 0x61 => 0x01f4, 0x62 => 0x01f4, 0x63 => 0xa7,
0x64 => 0x01f4, 0x65 => 0x01f4, 0x66 => 0x01f4, 0x67 => 0x01f4,
0x68 => 0x0116, 0x69 => 0x01f4, 0x6a => 0x01f4, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x022c, 0x6e => 0x022c, 0x6f => 0x01f4,
0x70 => 0x01f4, 0x71 => 0x01f4, 0x72 => 0xfa, 0x73 => 0x01f4,
0x74 => 0x015e, 0x75 => 0x014d, 0x76 => 0x01f4, 0x77 => 0x01f4,
0x78 => 0x01f4, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x01f4,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x03b0, 0x8b => 0x010a,
0x8c => 0x0263, 0x8d => 0x02d2, 0x8e => 0x03b0, 0x8f => 0x012c,
0x90 => 0x02d2, 0x91 => 0x0116, 0x92 => 0x0116, 0x93 => 0x01f4,
0x94 => 0x02d2, 0x95 => 0x01f4, 0x96 => 0x0185, 0x97 => 0x01bc,
0x98 => 0x01f4, 0x99 => 0x022c, 0x9a => 0x01bc, 0x9b => 0x0263,
0x9c => 0x023a, 0x9d => 0x0263, 0x9e => 0x029b, 0x9f => 0x01f4,
0xa0 => 0x02d2, 0xa1 => 0x01bc, 0xa2 => 0x0185, 0xa3 => 0x01bc,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x01f4, 0xa7 => 0x02d2,
0xa8 => 0x022c, 0xa9 => 0x029b, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02eb, 0xad => 0x029b, 0xae => 0x01bc, 0xaf => 0x01f4,
0xb0 => 0x02d2, 0xb1 => 0x0116, 0xb2 => 0x01f4, 0xb3 => 0x0263,
0xb4 => 0x029b, 0xb5 => 0x01f4, 0xb6 => 0x029b, 0xb7 => 0x0185,
0xb8 => 0x0185, 0xb9 => 0x0116, 0xba => 0x01ee, 0xbb => 0x029b,
0xbc => 0x02d2, 0xbd => 0x022c, 0xbe => 0x01f4, 0xbf => 0x029b,
0xc0 => 0x0185, 0xc1 => 0x01bc, 0xc2 => 0x0263, 0xc3 => 0x0263,
0xc4 => 0x02d2, 0xc5 => 0x029b, 0xc6 => 0x022c, 0xc7 => 0x0260,
0xc8 => 0x02d2, 0xc9 => 0x022c, 0xca => 0x012c, 0xcb => 0x02d2,
0xcc => 0x029b, 0xcd => 0x029b, 0xce => 0x023a, 0xcf => 0x022c,
0xd0 => 0x0263, 0xd1 => 0x01ee, 0xd2 => 0x01bc, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x029b, 0xd6 => 0x01f4, 0xd7 => 0x01bc,
0xd8 => 0x01bc, 0xd9 => 0x022c, 0xda => 0x022c, 0xdb => 0x02d2,
0xdc => 0x0185, 0xdd => 0x023a, 0xde => 0xdc, 0xdf => 0x02eb,
0xe0 => 0x02d2, 0xe1 => 0x0185, 0xe2 => 0x0258, 0xe3 => 0x029b,
0xe4 => 0x0185, 0xe5 => 0x01f4, 0xe6 => 0x0263, 0xe7 => 0x0263,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x029b, 0xeb => 0x0116,
0xec => 0x016e, 0xed => 0x01bc, 0xee => 0x02d2, 0xef => 0x029b,
0xf0 => 0x029b, 0xf1 => 0x01bc, 0xf2 => 0x0185, 0xf3 => 0x0116,
0xf4 => 0x02d2, 0xf5 => 0x01f4, 0xf6 => 0x01f4, 0xf7 => 0x0185,
0xf8 => 0x0116, 0xf9 => 0x02d2, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x01f4, 0xfd => 0x012c, 0xfe => 0x02d2, 0xff => 0x0240,
0x0100 => 0x0116, 0x0101 => 0x01f4, 0x0102 => 0x029b, 0x0103 => 0x01f4,
0x0104 => 0x02ee, 0x0105 => 0x022c, 0x0106 => 0x017e, 0x0107 => 0x029b,
0x0108 => 0x0263, 0x0109 => 0x03e8, 0x010a => 0x01bc, 0x010b => 0x0185,
0x010c => 0x0185, 0x010d => 0x0263, 0x010e => 0x02ee, 0x010f => 0x0225,
0x0110 => 0x01f4, 0x0111 => 0x022c, 0x0112 => 0x02d2, 0x0113 => 0x029b,
0x0114 => 0x01bc, 0x0115 => 0x01f4, 0x0116 => 0x02ee, 0x0117 => 0x022c,
0x0118 => 0x022c, 0x0119 => 0x02d2, 0x011a => 0x0190, 0x011b => 0x01f4,
0x011c => 0x029b, 0x011d => 0x022c, 0x011e => 0x0225, 0x011f => 0x02d2,
0x0120 => 0x0185, 0x0121 => 0x02d2, 0x0122 => 0x01f4, 0x0123 => 0x029b,
0x0124 => 0x0263, 0x0125 => 0x029b, 0x0126 => 0x029b, 0x0127 => 0x029b,
0x0128 => 0x02d2, 0x0129 => 0x0185, 0x012a => 0x029b, 0x012b => 0x0185,
0x012c => 0x01f4, 0x012d => 0x025e, 0x012e => 0x0185, 0x012f => 0x022c,
0x0130 => 0x0116, 0x0131 => 0x025e, 0x0132 => 0x01f4, 0x0133 => 0x022c,
0x0134 => 0x0225, 0x0135 => 0x01f4, 0x0136 => 0x01f4, 0x0137 => 0x0185,
0x0138 => 0x022c, 0x0139 => 0x012c, 0x013a => 0x0116, 0x013b => 0x01f4,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Times-BoldItalic');
}
}

View File

@ -0,0 +1,299 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Times-Italic.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_TimesItalic extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x37\x00"
. "\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00\x20\x00\x53\x00"
. "\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00\x20\x00\x49\x00"
. "\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00\x41\x00\x6c\x00"
. "\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00\x73\x00"
. "\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00\x65\x00"
. "\x64\x00\x2e\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x20\x00"
. "\x69\x00\x73\x00\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00"
. "\x64\x00\x65\x00\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00"
. "\x66\x00\x20\x00\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00"
. "\x70\x00\x65\x00\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00"
. "\x41\x00\x47\x00\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00"
. "\x72\x00\x20\x00\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00"
. "\x62\x00\x73\x00\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00"
. "\x65\x00\x73\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x36\x00\x37";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x49\x00\x74\x00"
. "\x61\x00\x6c\x00\x69\x00\x63\x00\x20\x00\x4d\x00\x65\x00\x64\x00"
. "\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x49\x00\x74\x00"
. "\x61\x00\x6c\x00\x69\x00\x63";
$this->_isBold = false;
$this->_isItalic = true;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 683;
$this->_descent = -217;
$this->_lineGap = 300;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0xfa, 0x02 => 0x014d, 0x03 => 0x01a4,
0x04 => 0x01f4, 0x05 => 0x01f4, 0x06 => 0x0341, 0x07 => 0x030a,
0x08 => 0x014d, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x01f4,
0x0c => 0x02a3, 0x0d => 0xfa, 0x0e => 0x014d, 0x0f => 0xfa,
0x10 => 0x0116, 0x11 => 0x01f4, 0x12 => 0x01f4, 0x13 => 0x01f4,
0x14 => 0x01f4, 0x15 => 0x01f4, 0x16 => 0x01f4, 0x17 => 0x01f4,
0x18 => 0x01f4, 0x19 => 0x01f4, 0x1a => 0x01f4, 0x1b => 0x014d,
0x1c => 0x014d, 0x1d => 0x02a3, 0x1e => 0x02a3, 0x1f => 0x02a3,
0x20 => 0x01f4, 0x21 => 0x0398, 0x22 => 0x0263, 0x23 => 0x0263,
0x24 => 0x029b, 0x25 => 0x02d2, 0x26 => 0x0263, 0x27 => 0x0263,
0x28 => 0x02d2, 0x29 => 0x02d2, 0x2a => 0x014d, 0x2b => 0x01bc,
0x2c => 0x029b, 0x2d => 0x022c, 0x2e => 0x0341, 0x2f => 0x029b,
0x30 => 0x02d2, 0x31 => 0x0263, 0x32 => 0x02d2, 0x33 => 0x0263,
0x34 => 0x01f4, 0x35 => 0x022c, 0x36 => 0x02d2, 0x37 => 0x0263,
0x38 => 0x0341, 0x39 => 0x0263, 0x3a => 0x022c, 0x3b => 0x022c,
0x3c => 0x0185, 0x3d => 0x0116, 0x3e => 0x0185, 0x3f => 0x01a6,
0x40 => 0x01f4, 0x41 => 0x014d, 0x42 => 0x01f4, 0x43 => 0x01f4,
0x44 => 0x01bc, 0x45 => 0x01f4, 0x46 => 0x01bc, 0x47 => 0x0116,
0x48 => 0x01f4, 0x49 => 0x01f4, 0x4a => 0x0116, 0x4b => 0x0116,
0x4c => 0x01bc, 0x4d => 0x0116, 0x4e => 0x02d2, 0x4f => 0x01f4,
0x50 => 0x01f4, 0x51 => 0x01f4, 0x52 => 0x01f4, 0x53 => 0x0185,
0x54 => 0x0185, 0x55 => 0x0116, 0x56 => 0x01f4, 0x57 => 0x01bc,
0x58 => 0x029b, 0x59 => 0x01bc, 0x5a => 0x01bc, 0x5b => 0x0185,
0x5c => 0x0190, 0x5d => 0x0113, 0x5e => 0x0190, 0x5f => 0x021d,
0x60 => 0x0185, 0x61 => 0x01f4, 0x62 => 0x01f4, 0x63 => 0xa7,
0x64 => 0x01f4, 0x65 => 0x01f4, 0x66 => 0x01f4, 0x67 => 0x01f4,
0x68 => 0xd6, 0x69 => 0x022c, 0x6a => 0x01f4, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x01f4, 0x6e => 0x01f4, 0x6f => 0x01f4,
0x70 => 0x01f4, 0x71 => 0x01f4, 0x72 => 0xfa, 0x73 => 0x020b,
0x74 => 0x015e, 0x75 => 0x014d, 0x76 => 0x022c, 0x77 => 0x022c,
0x78 => 0x01f4, 0x79 => 0x0379, 0x7a => 0x03e8, 0x7b => 0x01f4,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x0379, 0x8a => 0x0379, 0x8b => 0x0114,
0x8c => 0x022c, 0x8d => 0x02d2, 0x8e => 0x03b0, 0x8f => 0x0136,
0x90 => 0x029b, 0x91 => 0x0116, 0x92 => 0x0116, 0x93 => 0x01f4,
0x94 => 0x029b, 0x95 => 0x01f4, 0x96 => 0x014d, 0x97 => 0x01bc,
0x98 => 0x01f4, 0x99 => 0x01f4, 0x9a => 0x01bc, 0x9b => 0x022c,
0x9c => 0x02a3, 0x9d => 0x022c, 0x9e => 0x0263, 0x9f => 0x01f4,
0xa0 => 0x02d2, 0xa1 => 0x01bc, 0xa2 => 0x0185, 0xa3 => 0x01bc,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x01f4, 0xa7 => 0x02d2,
0xa8 => 0x01f4, 0xa9 => 0x0263, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02f8, 0xad => 0x0263, 0xae => 0x01bc, 0xaf => 0x01f4,
0xb0 => 0x029b, 0xb1 => 0x0116, 0xb2 => 0x01f4, 0xb3 => 0x022c,
0xb4 => 0x029b, 0xb5 => 0x01f4, 0xb6 => 0x0263, 0xb7 => 0x0185,
0xb8 => 0x0185, 0xb9 => 0x0116, 0xba => 0x01d7, 0xbb => 0x0263,
0xbc => 0x02d2, 0xbd => 0x01f4, 0xbe => 0x01f4, 0xbf => 0x0263,
0xc0 => 0x0185, 0xc1 => 0x01bc, 0xc2 => 0x022c, 0xc3 => 0x0263,
0xc4 => 0x02d2, 0xc5 => 0x0263, 0xc6 => 0x01f4, 0xc7 => 0x0220,
0xc8 => 0x02d2, 0xc9 => 0x01f4, 0xca => 0x012c, 0xcb => 0x02d2,
0xcc => 0x0263, 0xcd => 0x0263, 0xce => 0x02a3, 0xcf => 0x01f4,
0xd0 => 0x022c, 0xd1 => 0x01dc, 0xd2 => 0x01bc, 0xd3 => 0x029b,
0xd4 => 0x0116, 0xd5 => 0x0263, 0xd6 => 0x01f4, 0xd7 => 0x01bc,
0xd8 => 0x01bc, 0xd9 => 0x01f4, 0xda => 0x01f4, 0xdb => 0x029b,
0xdc => 0x014d, 0xdd => 0x02a3, 0xde => 0x0113, 0xdf => 0x02f8,
0xe0 => 0x02d2, 0xe1 => 0x014d, 0xe2 => 0x0258, 0xe3 => 0x0263,
0xe4 => 0x0185, 0xe5 => 0x01f4, 0xe6 => 0x022c, 0xe7 => 0x022c,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x029b, 0xeb => 0x0116,
0xec => 0x012c, 0xed => 0x01bc, 0xee => 0x02d2, 0xef => 0x0263,
0xf0 => 0x0263, 0xf1 => 0x01bc, 0xf2 => 0x0185, 0xf3 => 0x0116,
0xf4 => 0x02d2, 0xf5 => 0x01f4, 0xf6 => 0x01f4, 0xf7 => 0x0185,
0xf8 => 0x0116, 0xf9 => 0x02d2, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x01f4, 0xfd => 0x012c, 0xfe => 0x02d2, 0xff => 0x01f4,
0x0100 => 0x0116, 0x0101 => 0x01f4, 0x0102 => 0x0263, 0x0103 => 0x01f4,
0x0104 => 0x02ee, 0x0105 => 0x01f4, 0x0106 => 0x012c, 0x0107 => 0x029b,
0x0108 => 0x022c, 0x0109 => 0x03d4, 0x010a => 0x01bc, 0x010b => 0x014d,
0x010c => 0x014d, 0x010d => 0x0263, 0x010e => 0x02ee, 0x010f => 0x0225,
0x0110 => 0x01f4, 0x0111 => 0x01f4, 0x0112 => 0x02d2, 0x0113 => 0x0263,
0x0114 => 0x01bc, 0x0115 => 0x01f4, 0x0116 => 0x02ee, 0x0117 => 0x01f4,
0x0118 => 0x01f4, 0x0119 => 0x02d2, 0x011a => 0x0190, 0x011b => 0x01f4,
0x011c => 0x029b, 0x011d => 0x01f4, 0x011e => 0x01c5, 0x011f => 0x02d2,
0x0120 => 0x0185, 0x0121 => 0x029b, 0x0122 => 0x01f4, 0x0123 => 0x0263,
0x0124 => 0x022c, 0x0125 => 0x0263, 0x0126 => 0x0263, 0x0127 => 0x0263,
0x0128 => 0x02d2, 0x0129 => 0x0185, 0x012a => 0x0263, 0x012b => 0x014d,
0x012c => 0x01bc, 0x012d => 0x02a3, 0x012e => 0x014d, 0x012f => 0x01f4,
0x0130 => 0x0116, 0x0131 => 0x02a3, 0x0132 => 0x01f4, 0x0133 => 0x01f4,
0x0134 => 0x0225, 0x0135 => 0x01f4, 0x0136 => 0x01f4, 0x0137 => 0x0185,
0x0138 => 0x01f4, 0x0139 => 0x012c, 0x013a => 0x0116, 0x013b => 0x01f4,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Times-Italic');
}
}

View File

@ -0,0 +1,299 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font Times-Roman.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_TimesRoman extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x33\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x39\x00\x37\x00"
. "\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00\x20\x00\x53\x00"
. "\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00\x20\x00\x49\x00"
. "\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x20\x00\x41\x00\x6c\x00"
. "\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00\x73\x00"
. "\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00\x65\x00"
. "\x64\x00\x2e\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x20\x00"
. "\x69\x00\x73\x00\x20\x00\x61\x00\x20\x00\x74\x00\x72\x00\x61\x00"
. "\x64\x00\x65\x00\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00"
. "\x66\x00\x20\x00\x4c\x00\x69\x00\x6e\x00\x6f\x00\x74\x00\x79\x00"
. "\x70\x00\x65\x00\x2d\x00\x48\x00\x65\x00\x6c\x00\x6c\x00\x20\x00"
. "\x41\x00\x47\x00\x20\x00\x61\x00\x6e\x00\x64\x00\x2f\x00\x6f\x00"
. "\x72\x00\x20\x00\x69\x00\x74\x00\x73\x00\x20\x00\x73\x00\x75\x00"
. "\x62\x00\x73\x00\x69\x00\x64\x00\x69\x00\x61\x00\x72\x00\x69\x00"
. "\x65\x00\x73\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x52\x00\x6f\x00\x6d\x00\x61\x00\x6e";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x36\x00\x38";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x52\x00\x6f\x00"
. "\x6d\x00\x61\x00\x6e\x00\x20\x00\x52\x00\x6f\x00\x6d\x00\x61\x00"
. "\x6e";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x54\x00\x69\x00\x6d\x00\x65\x00\x73\x00\x2d\x00\x52\x00\x6f\x00"
. "\x6d\x00\x61\x00\x6e";
$this->_isBold = false;
$this->_isItalic = false;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 683;
$this->_descent = -217;
$this->_lineGap = 300;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0xfa, 0x02 => 0x014d, 0x03 => 0x0198,
0x04 => 0x01f4, 0x05 => 0x01f4, 0x06 => 0x0341, 0x07 => 0x030a,
0x08 => 0x014d, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x01f4,
0x0c => 0x0234, 0x0d => 0xfa, 0x0e => 0x014d, 0x0f => 0xfa,
0x10 => 0x0116, 0x11 => 0x01f4, 0x12 => 0x01f4, 0x13 => 0x01f4,
0x14 => 0x01f4, 0x15 => 0x01f4, 0x16 => 0x01f4, 0x17 => 0x01f4,
0x18 => 0x01f4, 0x19 => 0x01f4, 0x1a => 0x01f4, 0x1b => 0x0116,
0x1c => 0x0116, 0x1d => 0x0234, 0x1e => 0x0234, 0x1f => 0x0234,
0x20 => 0x01bc, 0x21 => 0x0399, 0x22 => 0x02d2, 0x23 => 0x029b,
0x24 => 0x029b, 0x25 => 0x02d2, 0x26 => 0x0263, 0x27 => 0x022c,
0x28 => 0x02d2, 0x29 => 0x02d2, 0x2a => 0x014d, 0x2b => 0x0185,
0x2c => 0x02d2, 0x2d => 0x0263, 0x2e => 0x0379, 0x2f => 0x02d2,
0x30 => 0x02d2, 0x31 => 0x022c, 0x32 => 0x02d2, 0x33 => 0x029b,
0x34 => 0x022c, 0x35 => 0x0263, 0x36 => 0x02d2, 0x37 => 0x02d2,
0x38 => 0x03b0, 0x39 => 0x02d2, 0x3a => 0x02d2, 0x3b => 0x0263,
0x3c => 0x014d, 0x3d => 0x0116, 0x3e => 0x014d, 0x3f => 0x01d5,
0x40 => 0x01f4, 0x41 => 0x014d, 0x42 => 0x01bc, 0x43 => 0x01f4,
0x44 => 0x01bc, 0x45 => 0x01f4, 0x46 => 0x01bc, 0x47 => 0x014d,
0x48 => 0x01f4, 0x49 => 0x01f4, 0x4a => 0x0116, 0x4b => 0x0116,
0x4c => 0x01f4, 0x4d => 0x0116, 0x4e => 0x030a, 0x4f => 0x01f4,
0x50 => 0x01f4, 0x51 => 0x01f4, 0x52 => 0x01f4, 0x53 => 0x014d,
0x54 => 0x0185, 0x55 => 0x0116, 0x56 => 0x01f4, 0x57 => 0x01f4,
0x58 => 0x02d2, 0x59 => 0x01f4, 0x5a => 0x01f4, 0x5b => 0x01bc,
0x5c => 0x01e0, 0x5d => 0xc8, 0x5e => 0x01e0, 0x5f => 0x021d,
0x60 => 0x014d, 0x61 => 0x01f4, 0x62 => 0x01f4, 0x63 => 0xa7,
0x64 => 0x01f4, 0x65 => 0x01f4, 0x66 => 0x01f4, 0x67 => 0x01f4,
0x68 => 0xb4, 0x69 => 0x01bc, 0x6a => 0x01f4, 0x6b => 0x014d,
0x6c => 0x014d, 0x6d => 0x022c, 0x6e => 0x022c, 0x6f => 0x01f4,
0x70 => 0x01f4, 0x71 => 0x01f4, 0x72 => 0xfa, 0x73 => 0x01c5,
0x74 => 0x015e, 0x75 => 0x014d, 0x76 => 0x01bc, 0x77 => 0x01bc,
0x78 => 0x01f4, 0x79 => 0x03e8, 0x7a => 0x03e8, 0x7b => 0x01bc,
0x7c => 0x014d, 0x7d => 0x014d, 0x7e => 0x014d, 0x7f => 0x014d,
0x80 => 0x014d, 0x81 => 0x014d, 0x82 => 0x014d, 0x83 => 0x014d,
0x84 => 0x014d, 0x85 => 0x014d, 0x86 => 0x014d, 0x87 => 0x014d,
0x88 => 0x014d, 0x89 => 0x03e8, 0x8a => 0x0379, 0x8b => 0x0114,
0x8c => 0x0263, 0x8d => 0x02d2, 0x8e => 0x0379, 0x8f => 0x0136,
0x90 => 0x029b, 0x91 => 0x0116, 0x92 => 0x0116, 0x93 => 0x01f4,
0x94 => 0x02d2, 0x95 => 0x01f4, 0x96 => 0x014d, 0x97 => 0x01bc,
0x98 => 0x01bc, 0x99 => 0x01f4, 0x9a => 0x01bc, 0x9b => 0x02d2,
0x9c => 0x0234, 0x9d => 0x02d2, 0x9e => 0x02d2, 0x9f => 0x01bc,
0xa0 => 0x02d2, 0xa1 => 0x01f4, 0xa2 => 0x0185, 0xa3 => 0x01bc,
0xa4 => 0x02d2, 0xa5 => 0x02d2, 0xa6 => 0x01bc, 0xa7 => 0x02d2,
0xa8 => 0x01f4, 0xa9 => 0x0263, 0xaa => 0x02d2, 0xab => 0xfa,
0xac => 0x02f8, 0xad => 0x0263, 0xae => 0x01bc, 0xaf => 0x01bc,
0xb0 => 0x02d2, 0xb1 => 0x0116, 0xb2 => 0x01bc, 0xb3 => 0x0263,
0xb4 => 0x029b, 0xb5 => 0x01bc, 0xb6 => 0x0263, 0xb7 => 0x0185,
0xb8 => 0x0185, 0xb9 => 0x0116, 0xba => 0x01d7, 0xbb => 0x029b,
0xbc => 0x02d2, 0xbd => 0x01f4, 0xbe => 0x01bc, 0xbf => 0x02d2,
0xc0 => 0x014d, 0xc1 => 0x01bc, 0xc2 => 0x0263, 0xc3 => 0x022c,
0xc4 => 0x02d2, 0xc5 => 0x029b, 0xc6 => 0x022c, 0xc7 => 0x024c,
0xc8 => 0x02d2, 0xc9 => 0x01f4, 0xca => 0x012c, 0xcb => 0x02d2,
0xcc => 0x02d2, 0xcd => 0x02d2, 0xce => 0x0234, 0xcf => 0x01f4,
0xd0 => 0x0263, 0xd1 => 0x01dc, 0xd2 => 0x01f4, 0xd3 => 0x02d2,
0xd4 => 0x0116, 0xd5 => 0x0263, 0xd6 => 0x01bc, 0xd7 => 0x01bc,
0xd8 => 0x01bc, 0xd9 => 0x01f4, 0xda => 0x01f4, 0xdb => 0x02d2,
0xdc => 0x014d, 0xdd => 0x0234, 0xde => 0xc8, 0xdf => 0x02f8,
0xe0 => 0x02d2, 0xe1 => 0x014d, 0xe2 => 0x0258, 0xe3 => 0x0263,
0xe4 => 0x014d, 0xe5 => 0x01f4, 0xe6 => 0x0263, 0xe7 => 0x0263,
0xe8 => 0x0225, 0xe9 => 0x02d2, 0xea => 0x029b, 0xeb => 0x0116,
0xec => 0x0146, 0xed => 0x01bc, 0xee => 0x02d2, 0xef => 0x02d2,
0xf0 => 0x02d2, 0xf1 => 0x01bc, 0xf2 => 0x01bc, 0xf3 => 0x0116,
0xf4 => 0x02d2, 0xf5 => 0x01f4, 0xf6 => 0x01bc, 0xf7 => 0x0185,
0xf8 => 0x0116, 0xf9 => 0x02d2, 0xfa => 0x02d2, 0xfb => 0x0264,
0xfc => 0x01f4, 0xfd => 0x012c, 0xfe => 0x02d2, 0xff => 0x01f4,
0x0100 => 0x0116, 0x0101 => 0x01f4, 0x0102 => 0x0263, 0x0103 => 0x01f4,
0x0104 => 0x02ee, 0x0105 => 0x022c, 0x0106 => 0x0158, 0x0107 => 0x02d2,
0x0108 => 0x0263, 0x0109 => 0x03d4, 0x010a => 0x01bc, 0x010b => 0x014d,
0x010c => 0x014d, 0x010d => 0x0263, 0x010e => 0x02ee, 0x010f => 0x0225,
0x0110 => 0x01f4, 0x0111 => 0x01f4, 0x0112 => 0x02d2, 0x0113 => 0x0263,
0x0114 => 0x01bc, 0x0115 => 0x01f4, 0x0116 => 0x02ee, 0x0117 => 0x022c,
0x0118 => 0x022c, 0x0119 => 0x02d2, 0x011a => 0x0190, 0x011b => 0x01f4,
0x011c => 0x029b, 0x011d => 0x01f4, 0x011e => 0x01c5, 0x011f => 0x02d2,
0x0120 => 0x014d, 0x0121 => 0x02d2, 0x0122 => 0x01f4, 0x0123 => 0x029b,
0x0124 => 0x0263, 0x0125 => 0x02d2, 0x0126 => 0x02d2, 0x0127 => 0x02d2,
0x0128 => 0x02d2, 0x0129 => 0x01bc, 0x012a => 0x0263, 0x012b => 0x014d,
0x012c => 0x01f4, 0x012d => 0x0234, 0x012e => 0x014d, 0x012f => 0x01f4,
0x0130 => 0x0116, 0x0131 => 0x0234, 0x0132 => 0x01f4, 0x0133 => 0x01f4,
0x0134 => 0x0225, 0x0135 => 0x01f4, 0x0136 => 0x01f4, 0x0137 => 0x01bc,
0x0138 => 0x01f4, 0x0139 => 0x012c, 0x013a => 0x0116, 0x013b => 0x01f4,
);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x21 => 0x02, 0x22 => 0x03, 0x23 => 0x04,
0x24 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x2019 => 0x08,
0x28 => 0x09, 0x29 => 0x0a, 0x2a => 0x0b, 0x2b => 0x0c,
0x2c => 0x0d, 0x2d => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
0x40 => 0x21, 0x41 => 0x22, 0x42 => 0x23, 0x43 => 0x24,
0x44 => 0x25, 0x45 => 0x26, 0x46 => 0x27, 0x47 => 0x28,
0x48 => 0x29, 0x49 => 0x2a, 0x4a => 0x2b, 0x4b => 0x2c,
0x4c => 0x2d, 0x4d => 0x2e, 0x4e => 0x2f, 0x4f => 0x30,
0x50 => 0x31, 0x51 => 0x32, 0x52 => 0x33, 0x53 => 0x34,
0x54 => 0x35, 0x55 => 0x36, 0x56 => 0x37, 0x57 => 0x38,
0x58 => 0x39, 0x59 => 0x3a, 0x5a => 0x3b, 0x5b => 0x3c,
0x5c => 0x3d, 0x5d => 0x3e, 0x5e => 0x3f, 0x5f => 0x40,
0x2018 => 0x41, 0x61 => 0x42, 0x62 => 0x43, 0x63 => 0x44,
0x64 => 0x45, 0x65 => 0x46, 0x66 => 0x47, 0x67 => 0x48,
0x68 => 0x49, 0x69 => 0x4a, 0x6a => 0x4b, 0x6b => 0x4c,
0x6c => 0x4d, 0x6d => 0x4e, 0x6e => 0x4f, 0x6f => 0x50,
0x70 => 0x51, 0x71 => 0x52, 0x72 => 0x53, 0x73 => 0x54,
0x74 => 0x55, 0x75 => 0x56, 0x76 => 0x57, 0x77 => 0x58,
0x78 => 0x59, 0x79 => 0x5a, 0x7a => 0x5b, 0x7b => 0x5c,
0x7c => 0x5d, 0x7d => 0x5e, 0x7e => 0x5f, 0xa1 => 0x60,
0xa2 => 0x61, 0xa3 => 0x62, 0x2044 => 0x63, 0xa5 => 0x64,
0x0192 => 0x65, 0xa7 => 0x66, 0xa4 => 0x67, 0x27 => 0x68,
0x201c => 0x69, 0xab => 0x6a, 0x2039 => 0x6b, 0x203a => 0x6c,
0xfb01 => 0x6d, 0xfb02 => 0x6e, 0x2013 => 0x6f, 0x2020 => 0x70,
0x2021 => 0x71, 0xb7 => 0x72, 0xb6 => 0x73, 0x2022 => 0x74,
0x201a => 0x75, 0x201e => 0x76, 0x201d => 0x77, 0xbb => 0x78,
0x2026 => 0x79, 0x2030 => 0x7a, 0xbf => 0x7b, 0x60 => 0x7c,
0xb4 => 0x7d, 0x02c6 => 0x7e, 0x02dc => 0x7f, 0xaf => 0x80,
0x02d8 => 0x81, 0x02d9 => 0x82, 0xa8 => 0x83, 0x02da => 0x84,
0xb8 => 0x85, 0x02dd => 0x86, 0x02db => 0x87, 0x02c7 => 0x88,
0x2014 => 0x89, 0xc6 => 0x8a, 0xaa => 0x8b, 0x0141 => 0x8c,
0xd8 => 0x8d, 0x0152 => 0x8e, 0xba => 0x8f, 0xe6 => 0x90,
0x0131 => 0x91, 0x0142 => 0x92, 0xf8 => 0x93, 0x0153 => 0x94,
0xdf => 0x95, 0xcf => 0x96, 0xe9 => 0x97, 0x0103 => 0x98,
0x0171 => 0x99, 0x011b => 0x9a, 0x0178 => 0x9b, 0xf7 => 0x9c,
0xdd => 0x9d, 0xc2 => 0x9e, 0xe1 => 0x9f, 0xdb => 0xa0,
0xfd => 0xa1, 0x0219 => 0xa2, 0xea => 0xa3, 0x016e => 0xa4,
0xdc => 0xa5, 0x0105 => 0xa6, 0xda => 0xa7, 0x0173 => 0xa8,
0xcb => 0xa9, 0x0110 => 0xaa, 0xf6c3 => 0xab, 0xa9 => 0xac,
0x0112 => 0xad, 0x010d => 0xae, 0xe5 => 0xaf, 0x0145 => 0xb0,
0x013a => 0xb1, 0xe0 => 0xb2, 0x0162 => 0xb3, 0x0106 => 0xb4,
0xe3 => 0xb5, 0x0116 => 0xb6, 0x0161 => 0xb7, 0x015f => 0xb8,
0xed => 0xb9, 0x25ca => 0xba, 0x0158 => 0xbb, 0x0122 => 0xbc,
0xfb => 0xbd, 0xe2 => 0xbe, 0x0100 => 0xbf, 0x0159 => 0xc0,
0xe7 => 0xc1, 0x017b => 0xc2, 0xde => 0xc3, 0x014c => 0xc4,
0x0154 => 0xc5, 0x015a => 0xc6, 0x010f => 0xc7, 0x016a => 0xc8,
0x016f => 0xc9, 0xb3 => 0xca, 0xd2 => 0xcb, 0xc0 => 0xcc,
0x0102 => 0xcd, 0xd7 => 0xce, 0xfa => 0xcf, 0x0164 => 0xd0,
0x2202 => 0xd1, 0xff => 0xd2, 0x0143 => 0xd3, 0xee => 0xd4,
0xca => 0xd5, 0xe4 => 0xd6, 0xeb => 0xd7, 0x0107 => 0xd8,
0x0144 => 0xd9, 0x016b => 0xda, 0x0147 => 0xdb, 0xcd => 0xdc,
0xb1 => 0xdd, 0xa6 => 0xde, 0xae => 0xdf, 0x011e => 0xe0,
0x0130 => 0xe1, 0x2211 => 0xe2, 0xc8 => 0xe3, 0x0155 => 0xe4,
0x014d => 0xe5, 0x0179 => 0xe6, 0x017d => 0xe7, 0x2265 => 0xe8,
0xd0 => 0xe9, 0xc7 => 0xea, 0x013c => 0xeb, 0x0165 => 0xec,
0x0119 => 0xed, 0x0172 => 0xee, 0xc1 => 0xef, 0xc4 => 0xf0,
0xe8 => 0xf1, 0x017a => 0xf2, 0x012f => 0xf3, 0xd3 => 0xf4,
0xf3 => 0xf5, 0x0101 => 0xf6, 0x015b => 0xf7, 0xef => 0xf8,
0xd4 => 0xf9, 0xd9 => 0xfa, 0x2206 => 0xfb, 0xfe => 0xfc,
0xb2 => 0xfd, 0xd6 => 0xfe, 0xb5 => 0xff, 0xec => 0x0100,
0x0151 => 0x0101, 0x0118 => 0x0102, 0x0111 => 0x0103, 0xbe => 0x0104,
0x015e => 0x0105, 0x013e => 0x0106, 0x0136 => 0x0107, 0x0139 => 0x0108,
0x2122 => 0x0109, 0x0117 => 0x010a, 0xcc => 0x010b, 0x012a => 0x010c,
0x013d => 0x010d, 0xbd => 0x010e, 0x2264 => 0x010f, 0xf4 => 0x0110,
0xf1 => 0x0111, 0x0170 => 0x0112, 0xc9 => 0x0113, 0x0113 => 0x0114,
0x011f => 0x0115, 0xbc => 0x0116, 0x0160 => 0x0117, 0x0218 => 0x0118,
0x0150 => 0x0119, 0xb0 => 0x011a, 0xf2 => 0x011b, 0x010c => 0x011c,
0xf9 => 0x011d, 0x221a => 0x011e, 0x010e => 0x011f, 0x0157 => 0x0120,
0xd1 => 0x0121, 0xf5 => 0x0122, 0x0156 => 0x0123, 0x013b => 0x0124,
0xc3 => 0x0125, 0x0104 => 0x0126, 0xc5 => 0x0127, 0xd5 => 0x0128,
0x017c => 0x0129, 0x011a => 0x012a, 0x012e => 0x012b, 0x0137 => 0x012c,
0x2212 => 0x012d, 0xce => 0x012e, 0x0148 => 0x012f, 0x0163 => 0x0130,
0xac => 0x0131, 0xf6 => 0x0132, 0xfc => 0x0133, 0x2260 => 0x0134,
0x0123 => 0x0135, 0xf0 => 0x0136, 0x017e => 0x0137, 0x0146 => 0x0138,
0xb9 => 0x0139, 0x012b => 0x013a, 0x20ac => 0x013b);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('Times-Roman');
}
}

View File

@ -0,0 +1,485 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font_Simple_Standard */
require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
/**
* Implementation for the standard PDF font ZapfDingbats.
*
* This class was generated automatically using the font information and metric
* data contained in the Adobe Font Metric (AFM) files, available here:
* {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
*
* The PHP script used to generate this class can be found in the /tools
* directory of the framework distribution. If you need to make modifications to
* this class, chances are the same modifications are needed for the rest of the
* standard fonts. You should modify the script and regenerate the classes
* instead of changing this class file by hand.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Simple_Standard_ZapfDingbats extends Zend_Pdf_Resource_Font_Simple_Standard
{
/**** Instance Variables ****/
/**
* Array for conversion from local encoding to special font encoding.
* See {@link encodeString()}.
* @var array
*/
protected $_toFontEncoding = array(
0x20 => "\x20", 0x2701 => "\x21", 0x2702 => "\x22", 0x2703 => "\x23",
0x2704 => "\x24", 0x260e => "\x25", 0x2706 => "\x26", 0x2707 => "\x27",
0x2708 => "\x28", 0x2709 => "\x29", 0x261b => "\x2a", 0x261e => "\x2b",
0x270c => "\x2c", 0x270d => "\x2d", 0x270e => "\x2e", 0x270f => "\x2f",
0x2710 => "\x30", 0x2711 => "\x31", 0x2712 => "\x32", 0x2713 => "\x33",
0x2714 => "\x34", 0x2715 => "\x35", 0x2716 => "\x36", 0x2717 => "\x37",
0x2718 => "\x38", 0x2719 => "\x39", 0x271a => "\x3a", 0x271b => "\x3b",
0x271c => "\x3c", 0x271d => "\x3d", 0x271e => "\x3e", 0x271f => "\x3f",
0x2720 => "\x40", 0x2721 => "\x41", 0x2722 => "\x42", 0x2723 => "\x43",
0x2724 => "\x44", 0x2725 => "\x45", 0x2726 => "\x46", 0x2727 => "\x47",
0x2605 => "\x48", 0x2729 => "\x49", 0x272a => "\x4a", 0x272b => "\x4b",
0x272c => "\x4c", 0x272d => "\x4d", 0x272e => "\x4e", 0x272f => "\x4f",
0x2730 => "\x50", 0x2731 => "\x51", 0x2732 => "\x52", 0x2733 => "\x53",
0x2734 => "\x54", 0x2735 => "\x55", 0x2736 => "\x56", 0x2737 => "\x57",
0x2738 => "\x58", 0x2739 => "\x59", 0x273a => "\x5a", 0x273b => "\x5b",
0x273c => "\x5c", 0x273d => "\x5d", 0x273e => "\x5e", 0x273f => "\x5f",
0x2740 => "\x60", 0x2741 => "\x61", 0x2742 => "\x62", 0x2743 => "\x63",
0x2744 => "\x64", 0x2745 => "\x65", 0x2746 => "\x66", 0x2747 => "\x67",
0x2748 => "\x68", 0x2749 => "\x69", 0x274a => "\x6a", 0x274b => "\x6b",
0x25cf => "\x6c", 0x274d => "\x6d", 0x25a0 => "\x6e", 0x274f => "\x6f",
0x2750 => "\x70", 0x2751 => "\x71", 0x2752 => "\x72", 0x25b2 => "\x73",
0x25bc => "\x74", 0x25c6 => "\x75", 0x2756 => "\x76", 0x25d7 => "\x77",
0x2758 => "\x78", 0x2759 => "\x79", 0x275a => "\x7a", 0x275b => "\x7b",
0x275c => "\x7c", 0x275d => "\x7d", 0x275e => "\x7e", 0x2768 => "\x80",
0x2769 => "\x81", 0x276a => "\x82", 0x276b => "\x83", 0x276c => "\x84",
0x276d => "\x85", 0x276e => "\x86", 0x276f => "\x87", 0x2770 => "\x88",
0x2771 => "\x89", 0x2772 => "\x8a", 0x2773 => "\x8b", 0x2774 => "\x8c",
0x2775 => "\x8d", 0x2761 => "\xa1", 0x2762 => "\xa2", 0x2763 => "\xa3",
0x2764 => "\xa4", 0x2765 => "\xa5", 0x2766 => "\xa6", 0x2767 => "\xa7",
0x2663 => "\xa8", 0x2666 => "\xa9", 0x2665 => "\xaa", 0x2660 => "\xab",
0x2460 => "\xac", 0x2461 => "\xad", 0x2462 => "\xae", 0x2463 => "\xaf",
0x2464 => "\xb0", 0x2465 => "\xb1", 0x2466 => "\xb2", 0x2467 => "\xb3",
0x2468 => "\xb4", 0x2469 => "\xb5", 0x2776 => "\xb6", 0x2777 => "\xb7",
0x2778 => "\xb8", 0x2779 => "\xb9", 0x277a => "\xba", 0x277b => "\xbb",
0x277c => "\xbc", 0x277d => "\xbd", 0x277e => "\xbe", 0x277f => "\xbf",
0x2780 => "\xc0", 0x2781 => "\xc1", 0x2782 => "\xc2", 0x2783 => "\xc3",
0x2784 => "\xc4", 0x2785 => "\xc5", 0x2786 => "\xc6", 0x2787 => "\xc7",
0x2788 => "\xc8", 0x2789 => "\xc9", 0x278a => "\xca", 0x278b => "\xcb",
0x278c => "\xcc", 0x278d => "\xcd", 0x278e => "\xce", 0x278f => "\xcf",
0x2790 => "\xd0", 0x2791 => "\xd1", 0x2792 => "\xd2", 0x2793 => "\xd3",
0x2794 => "\xd4", 0x2192 => "\xd5", 0x2194 => "\xd6", 0x2195 => "\xd7",
0x2798 => "\xd8", 0x2799 => "\xd9", 0x279a => "\xda", 0x279b => "\xdb",
0x279c => "\xdc", 0x279d => "\xdd", 0x279e => "\xde", 0x279f => "\xdf",
0x27a0 => "\xe0", 0x27a1 => "\xe1", 0x27a2 => "\xe2", 0x27a3 => "\xe3",
0x27a4 => "\xe4", 0x27a5 => "\xe5", 0x27a6 => "\xe6", 0x27a7 => "\xe7",
0x27a8 => "\xe8", 0x27a9 => "\xe9", 0x27aa => "\xea", 0x27ab => "\xeb",
0x27ac => "\xec", 0x27ad => "\xed", 0x27ae => "\xee", 0x27af => "\xef",
0x27b1 => "\xf1", 0x27b2 => "\xf2", 0x27b3 => "\xf3", 0x27b4 => "\xf4",
0x27b5 => "\xf5", 0x27b6 => "\xf6", 0x27b7 => "\xf7", 0x27b8 => "\xf8",
0x27b9 => "\xf9", 0x27ba => "\xfa", 0x27bb => "\xfb", 0x27bc => "\xfc",
0x27bd => "\xfd", 0x27be => "\xfe");
/**
* Array for conversion from special font encoding to local encoding.
* See {@link decodeString()}.
* @var array
*/
protected $_fromFontEncoding = array(
0x20 => "\x00\x20", 0x21 => "\x27\x01", 0x22 => "\x27\x02",
0x23 => "\x27\x03", 0x24 => "\x27\x04", 0x25 => "\x26\x0e",
0x26 => "\x27\x06", 0x27 => "\x27\x07", 0x28 => "\x27\x08",
0x29 => "\x27\x09", 0x2a => "\x26\x1b", 0x2b => "\x26\x1e",
0x2c => "\x27\x0c", 0x2d => "\x27\x0d", 0x2e => "\x27\x0e",
0x2f => "\x27\x0f", 0x30 => "\x27\x10", 0x31 => "\x27\x11",
0x32 => "\x27\x12", 0x33 => "\x27\x13", 0x34 => "\x27\x14",
0x35 => "\x27\x15", 0x36 => "\x27\x16", 0x37 => "\x27\x17",
0x38 => "\x27\x18", 0x39 => "\x27\x19", 0x3a => "\x27\x1a",
0x3b => "\x27\x1b", 0x3c => "\x27\x1c", 0x3d => "\x27\x1d",
0x3e => "\x27\x1e", 0x3f => "\x27\x1f", 0x40 => "\x27\x20",
0x41 => "\x27\x21", 0x42 => "\x27\x22", 0x43 => "\x27\x23",
0x44 => "\x27\x24", 0x45 => "\x27\x25", 0x46 => "\x27\x26",
0x47 => "\x27\x27", 0x48 => "\x26\x05", 0x49 => "\x27\x29",
0x4a => "\x27\x2a", 0x4b => "\x27\x2b", 0x4c => "\x27\x2c",
0x4d => "\x27\x2d", 0x4e => "\x27\x2e", 0x4f => "\x27\x2f",
0x50 => "\x27\x30", 0x51 => "\x27\x31", 0x52 => "\x27\x32",
0x53 => "\x27\x33", 0x54 => "\x27\x34", 0x55 => "\x27\x35",
0x56 => "\x27\x36", 0x57 => "\x27\x37", 0x58 => "\x27\x38",
0x59 => "\x27\x39", 0x5a => "\x27\x3a", 0x5b => "\x27\x3b",
0x5c => "\x27\x3c", 0x5d => "\x27\x3d", 0x5e => "\x27\x3e",
0x5f => "\x27\x3f", 0x60 => "\x27\x40", 0x61 => "\x27\x41",
0x62 => "\x27\x42", 0x63 => "\x27\x43", 0x64 => "\x27\x44",
0x65 => "\x27\x45", 0x66 => "\x27\x46", 0x67 => "\x27\x47",
0x68 => "\x27\x48", 0x69 => "\x27\x49", 0x6a => "\x27\x4a",
0x6b => "\x27\x4b", 0x6c => "\x25\xcf", 0x6d => "\x27\x4d",
0x6e => "\x25\xa0", 0x6f => "\x27\x4f", 0x70 => "\x27\x50",
0x71 => "\x27\x51", 0x72 => "\x27\x52", 0x73 => "\x25\xb2",
0x74 => "\x25\xbc", 0x75 => "\x25\xc6", 0x76 => "\x27\x56",
0x77 => "\x25\xd7", 0x78 => "\x27\x58", 0x79 => "\x27\x59",
0x7a => "\x27\x5a", 0x7b => "\x27\x5b", 0x7c => "\x27\x5c",
0x7d => "\x27\x5d", 0x7e => "\x27\x5e", 0x80 => "\x27\x68",
0x81 => "\x27\x69", 0x82 => "\x27\x6a", 0x83 => "\x27\x6b",
0x84 => "\x27\x6c", 0x85 => "\x27\x6d", 0x86 => "\x27\x6e",
0x87 => "\x27\x6f", 0x88 => "\x27\x70", 0x89 => "\x27\x71",
0x8a => "\x27\x72", 0x8b => "\x27\x73", 0x8c => "\x27\x74",
0x8d => "\x27\x75", 0xa1 => "\x27\x61", 0xa2 => "\x27\x62",
0xa3 => "\x27\x63", 0xa4 => "\x27\x64", 0xa5 => "\x27\x65",
0xa6 => "\x27\x66", 0xa7 => "\x27\x67", 0xa8 => "\x26\x63",
0xa9 => "\x26\x66", 0xaa => "\x26\x65", 0xab => "\x26\x60",
0xac => "\x24\x60", 0xad => "\x24\x61", 0xae => "\x24\x62",
0xaf => "\x24\x63", 0xb0 => "\x24\x64", 0xb1 => "\x24\x65",
0xb2 => "\x24\x66", 0xb3 => "\x24\x67", 0xb4 => "\x24\x68",
0xb5 => "\x24\x69", 0xb6 => "\x27\x76", 0xb7 => "\x27\x77",
0xb8 => "\x27\x78", 0xb9 => "\x27\x79", 0xba => "\x27\x7a",
0xbb => "\x27\x7b", 0xbc => "\x27\x7c", 0xbd => "\x27\x7d",
0xbe => "\x27\x7e", 0xbf => "\x27\x7f", 0xc0 => "\x27\x80",
0xc1 => "\x27\x81", 0xc2 => "\x27\x82", 0xc3 => "\x27\x83",
0xc4 => "\x27\x84", 0xc5 => "\x27\x85", 0xc6 => "\x27\x86",
0xc7 => "\x27\x87", 0xc8 => "\x27\x88", 0xc9 => "\x27\x89",
0xca => "\x27\x8a", 0xcb => "\x27\x8b", 0xcc => "\x27\x8c",
0xcd => "\x27\x8d", 0xce => "\x27\x8e", 0xcf => "\x27\x8f",
0xd0 => "\x27\x90", 0xd1 => "\x27\x91", 0xd2 => "\x27\x92",
0xd3 => "\x27\x93", 0xd4 => "\x27\x94", 0xd5 => "\x21\x92",
0xd6 => "\x21\x94", 0xd7 => "\x21\x95", 0xd8 => "\x27\x98",
0xd9 => "\x27\x99", 0xda => "\x27\x9a", 0xdb => "\x27\x9b",
0xdc => "\x27\x9c", 0xdd => "\x27\x9d", 0xde => "\x27\x9e",
0xdf => "\x27\x9f", 0xe0 => "\x27\xa0", 0xe1 => "\x27\xa1",
0xe2 => "\x27\xa2", 0xe3 => "\x27\xa3", 0xe4 => "\x27\xa4",
0xe5 => "\x27\xa5", 0xe6 => "\x27\xa6", 0xe7 => "\x27\xa7",
0xe8 => "\x27\xa8", 0xe9 => "\x27\xa9", 0xea => "\x27\xaa",
0xeb => "\x27\xab", 0xec => "\x27\xac", 0xed => "\x27\xad",
0xee => "\x27\xae", 0xef => "\x27\xaf", 0xf1 => "\x27\xb1",
0xf2 => "\x27\xb2", 0xf3 => "\x27\xb3", 0xf4 => "\x27\xb4",
0xf5 => "\x27\xb5", 0xf6 => "\x27\xb6", 0xf7 => "\x27\xb7",
0xf8 => "\x27\xb8", 0xf9 => "\x27\xb9", 0xfa => "\x27\xba",
0xfb => "\x27\xbb", 0xfc => "\x27\xbc", 0xfd => "\x27\xbd",
0xfe => "\x27\xbe");
/**** Public Interface ****/
/* Object Lifecycle */
/**
* Object constructor
*/
public function __construct()
{
parent::__construct();
/* Object properties */
/* The font names are stored internally as Unicode UTF-16BE-encoded
* strings. Since this information is static, save unnecessary trips
* through iconv() and just use pre-encoded hexidecimal strings.
*/
$this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
"\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
. "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
. "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
. "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x38\x00\x2c\x00\x20\x00"
. "\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
. "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
. "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
. "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
. "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x41\x00"
. "\x6c\x00\x6c\x00\x20\x00\x52\x00\x69\x00\x67\x00\x68\x00\x74\x00"
. "\x73\x00\x20\x00\x52\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00"
. "\x65\x00\x64\x00\x2e\x00\x49\x00\x54\x00\x43\x00\x20\x00\x5a\x00"
. "\x61\x00\x70\x00\x66\x00\x20\x00\x44\x00\x69\x00\x6e\x00\x67\x00"
. "\x62\x00\x61\x00\x74\x00\x73\x00\x20\x00\x69\x00\x73\x00\x20\x00"
. "\x61\x00\x20\x00\x72\x00\x65\x00\x67\x00\x69\x00\x73\x00\x74\x00"
. "\x65\x00\x72\x00\x65\x00\x64\x00\x20\x00\x74\x00\x72\x00\x61\x00"
. "\x64\x00\x65\x00\x6d\x00\x61\x00\x72\x00\x6b\x00\x20\x00\x6f\x00"
. "\x66\x00\x20\x00\x49\x00\x6e\x00\x74\x00\x65\x00\x72\x00\x6e\x00"
. "\x61\x00\x74\x00\x69\x00\x6f\x00\x6e\x00\x61\x00\x6c\x00\x20\x00"
. "\x54\x00\x79\x00\x70\x00\x65\x00\x66\x00\x61\x00\x63\x00\x65\x00"
. "\x20\x00\x43\x00\x6f\x00\x72\x00\x70\x00\x6f\x00\x72\x00\x61\x00"
. "\x74\x00\x69\x00\x6f\x00\x6e\x00\x2e";
$this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
"\x00\x5a\x00\x61\x00\x70\x00\x66\x00\x44\x00\x69\x00\x6e\x00\x67\x00"
. "\x62\x00\x61\x00\x74\x00\x73";
$this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
"\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
"\x00\x34\x00\x33\x00\x30\x00\x38\x00\x32";
$this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
"\x00\x5a\x00\x61\x00\x70\x00\x66\x00\x44\x00\x69\x00\x6e\x00\x67\x00"
. "\x62\x00\x61\x00\x74\x00\x73\x00\x20\x00\x4d\x00\x65\x00\x64\x00"
. "\x69\x00\x75\x00\x6d";
$this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
"\x00\x30\x00\x30\x00\x32\x00\x2e\x00\x30\x00\x30\x00\x30";
$this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
"\x00\x5a\x00\x61\x00\x70\x00\x66\x00\x44\x00\x69\x00\x6e\x00\x67\x00"
. "\x62\x00\x61\x00\x74\x00\x73";
$this->_isBold = false;
$this->_isItalic = false;
$this->_isMonospaced = false;
$this->_underlinePosition = -100;
$this->_underlineThickness = 50;
$this->_strikePosition = 225;
$this->_strikeThickness = 50;
$this->_unitsPerEm = 1000;
$this->_ascent = 1000;
$this->_descent = 0;
$this->_lineGap = 200;
/* The glyph numbers assigned here are synthetic; they do not match the
* actual glyph numbers used by the font. This is not a big deal though
* since this data never makes it to the PDF file. It is only used
* internally for layout calculations.
*/
$this->_glyphWidths = array(
0x00 => 0x01f4, 0x01 => 0x0116, 0x02 => 0x03ce, 0x03 => 0x03c1,
0x04 => 0x03ce, 0x05 => 0x03d4, 0x06 => 0x02cf, 0x07 => 0x0315,
0x08 => 0x0316, 0x09 => 0x0317, 0x0a => 0x02b2, 0x0b => 0x03c0,
0x0c => 0x03ab, 0x0d => 0x0225, 0x0e => 0x0357, 0x0f => 0x038f,
0x10 => 0x03a5, 0x11 => 0x038f, 0x12 => 0x03b1, 0x13 => 0x03ce,
0x14 => 0x02f3, 0x15 => 0x034e, 0x16 => 0x02fa, 0x17 => 0x02f9,
0x18 => 0x023b, 0x19 => 0x02a5, 0x1a => 0x02fb, 0x1b => 0x02f8,
0x1c => 0x02f7, 0x1d => 0x02f2, 0x1e => 0x01ee, 0x1f => 0x0228,
0x20 => 0x0219, 0x21 => 0x0241, 0x22 => 0x02b4, 0x23 => 0x0312,
0x24 => 0x0314, 0x25 => 0x0314, 0x26 => 0x0316, 0x27 => 0x0319,
0x28 => 0x031a, 0x29 => 0x0330, 0x2a => 0x0337, 0x2b => 0x0315,
0x2c => 0x0349, 0x2d => 0x0337, 0x2e => 0x0341, 0x2f => 0x0330,
0x30 => 0x033f, 0x31 => 0x039b, 0x32 => 0x02e8, 0x33 => 0x02d3,
0x34 => 0x02ed, 0x35 => 0x0316, 0x36 => 0x0318, 0x37 => 0x02b7,
0x38 => 0x0308, 0x39 => 0x0300, 0x3a => 0x0318, 0x3b => 0x02f7,
0x3c => 0x02c3, 0x3d => 0x02c4, 0x3e => 0x02aa, 0x3f => 0x02bd,
0x40 => 0x033a, 0x41 => 0x032f, 0x42 => 0x0315, 0x43 => 0x0315,
0x44 => 0x02c3, 0x45 => 0x02af, 0x46 => 0x02b8, 0x47 => 0x02b1,
0x48 => 0x0312, 0x49 => 0x0313, 0x4a => 0x02c9, 0x4b => 0x0317,
0x4c => 0x0311, 0x4d => 0x0317, 0x4e => 0x0369, 0x4f => 0x02f9,
0x50 => 0x02fa, 0x51 => 0x02fa, 0x52 => 0x02f7, 0x53 => 0x02f7,
0x54 => 0x037c, 0x55 => 0x037c, 0x56 => 0x0314, 0x57 => 0x0310,
0x58 => 0x01b6, 0x59 => 0x8a, 0x5a => 0x0115, 0x5b => 0x019f,
0x5c => 0x0188, 0x5d => 0x0188, 0x5e => 0x029c, 0x5f => 0x029c,
0x60 => 0x0186, 0x61 => 0x0186, 0x62 => 0x013d, 0x63 => 0x013d,
0x64 => 0x0114, 0x65 => 0x0114, 0x66 => 0x01fd, 0x67 => 0x01fd,
0x68 => 0x019a, 0x69 => 0x019a, 0x6a => 0xea, 0x6b => 0xea,
0x6c => 0x014e, 0x6d => 0x014e, 0x6e => 0x02dc, 0x6f => 0x0220,
0x70 => 0x0220, 0x71 => 0x038e, 0x72 => 0x029b, 0x73 => 0x02f8,
0x74 => 0x02f8, 0x75 => 0x0308, 0x76 => 0x0253, 0x77 => 0x02b6,
0x78 => 0x0272, 0x79 => 0x0314, 0x7a => 0x0314, 0x7b => 0x0314,
0x7c => 0x0314, 0x7d => 0x0314, 0x7e => 0x0314, 0x7f => 0x0314,
0x80 => 0x0314, 0x81 => 0x0314, 0x82 => 0x0314, 0x83 => 0x0314,
0x84 => 0x0314, 0x85 => 0x0314, 0x86 => 0x0314, 0x87 => 0x0314,
0x88 => 0x0314, 0x89 => 0x0314, 0x8a => 0x0314, 0x8b => 0x0314,
0x8c => 0x0314, 0x8d => 0x0314, 0x8e => 0x0314, 0x8f => 0x0314,
0x90 => 0x0314, 0x91 => 0x0314, 0x92 => 0x0314, 0x93 => 0x0314,
0x94 => 0x0314, 0x95 => 0x0314, 0x96 => 0x0314, 0x97 => 0x0314,
0x98 => 0x0314, 0x99 => 0x0314, 0x9a => 0x0314, 0x9b => 0x0314,
0x9c => 0x0314, 0x9d => 0x0314, 0x9e => 0x0314, 0x9f => 0x0314,
0xa0 => 0x0314, 0xa1 => 0x037e, 0xa2 => 0x0346, 0xa3 => 0x03f8,
0xa4 => 0x01ca, 0xa5 => 0x02ec, 0xa6 => 0x039c, 0xa7 => 0x02ec,
0xa8 => 0x0396, 0xa9 => 0x039f, 0xaa => 0x03a0, 0xab => 0x03a0,
0xac => 0x0342, 0xad => 0x0369, 0xae => 0x033c, 0xaf => 0x039c,
0xb0 => 0x039c, 0xb1 => 0x0395, 0xb2 => 0x03a2, 0xb3 => 0x03a3,
0xb4 => 0x01cf, 0xb5 => 0x0373, 0xb6 => 0x0344, 0xb7 => 0x0344,
0xb8 => 0x0363, 0xb9 => 0x0363, 0xba => 0x02b8, 0xbb => 0x02b8,
0xbc => 0x036a, 0xbd => 0x036a, 0xbe => 0x02f8, 0xbf => 0x03b2,
0xc0 => 0x0303, 0xc1 => 0x0361, 0xc2 => 0x0303, 0xc3 => 0x0378,
0xc4 => 0x03c7, 0xc5 => 0x0378, 0xc6 => 0x033f, 0xc7 => 0x0369,
0xc8 => 0x039f, 0xc9 => 0x03ca, 0xca => 0x0396);
/* The cmap table is similarly synthesized.
*/
$cmapData = array(
0x20 => 0x01, 0x2701 => 0x02, 0x2702 => 0x03, 0x2703 => 0x04,
0x2704 => 0x05, 0x260e => 0x06, 0x2706 => 0x07, 0x2707 => 0x08,
0x2708 => 0x09, 0x2709 => 0x0a, 0x261b => 0x0b, 0x261e => 0x0c,
0x270c => 0x0d, 0x270d => 0x0e, 0x270e => 0x0f, 0x270f => 0x10,
0x2710 => 0x11, 0x2711 => 0x12, 0x2712 => 0x13, 0x2713 => 0x14,
0x2714 => 0x15, 0x2715 => 0x16, 0x2716 => 0x17, 0x2717 => 0x18,
0x2718 => 0x19, 0x2719 => 0x1a, 0x271a => 0x1b, 0x271b => 0x1c,
0x271c => 0x1d, 0x271d => 0x1e, 0x271e => 0x1f, 0x271f => 0x20,
0x2720 => 0x21, 0x2721 => 0x22, 0x2722 => 0x23, 0x2723 => 0x24,
0x2724 => 0x25, 0x2725 => 0x26, 0x2726 => 0x27, 0x2727 => 0x28,
0x2605 => 0x29, 0x2729 => 0x2a, 0x272a => 0x2b, 0x272b => 0x2c,
0x272c => 0x2d, 0x272d => 0x2e, 0x272e => 0x2f, 0x272f => 0x30,
0x2730 => 0x31, 0x2731 => 0x32, 0x2732 => 0x33, 0x2733 => 0x34,
0x2734 => 0x35, 0x2735 => 0x36, 0x2736 => 0x37, 0x2737 => 0x38,
0x2738 => 0x39, 0x2739 => 0x3a, 0x273a => 0x3b, 0x273b => 0x3c,
0x273c => 0x3d, 0x273d => 0x3e, 0x273e => 0x3f, 0x273f => 0x40,
0x2740 => 0x41, 0x2741 => 0x42, 0x2742 => 0x43, 0x2743 => 0x44,
0x2744 => 0x45, 0x2745 => 0x46, 0x2746 => 0x47, 0x2747 => 0x48,
0x2748 => 0x49, 0x2749 => 0x4a, 0x274a => 0x4b, 0x274b => 0x4c,
0x25cf => 0x4d, 0x274d => 0x4e, 0x25a0 => 0x4f, 0x274f => 0x50,
0x2750 => 0x51, 0x2751 => 0x52, 0x2752 => 0x53, 0x25b2 => 0x54,
0x25bc => 0x55, 0x25c6 => 0x56, 0x2756 => 0x57, 0x25d7 => 0x58,
0x2758 => 0x59, 0x2759 => 0x5a, 0x275a => 0x5b, 0x275b => 0x5c,
0x275c => 0x5d, 0x275d => 0x5e, 0x275e => 0x5f, 0x2768 => 0x60,
0x2769 => 0x61, 0x276a => 0x62, 0x276b => 0x63, 0x276c => 0x64,
0x276d => 0x65, 0x276e => 0x66, 0x276f => 0x67, 0x2770 => 0x68,
0x2771 => 0x69, 0x2772 => 0x6a, 0x2773 => 0x6b, 0x2774 => 0x6c,
0x2775 => 0x6d, 0x2761 => 0x6e, 0x2762 => 0x6f, 0x2763 => 0x70,
0x2764 => 0x71, 0x2765 => 0x72, 0x2766 => 0x73, 0x2767 => 0x74,
0x2663 => 0x75, 0x2666 => 0x76, 0x2665 => 0x77, 0x2660 => 0x78,
0x2460 => 0x79, 0x2461 => 0x7a, 0x2462 => 0x7b, 0x2463 => 0x7c,
0x2464 => 0x7d, 0x2465 => 0x7e, 0x2466 => 0x7f, 0x2467 => 0x80,
0x2468 => 0x81, 0x2469 => 0x82, 0x2776 => 0x83, 0x2777 => 0x84,
0x2778 => 0x85, 0x2779 => 0x86, 0x277a => 0x87, 0x277b => 0x88,
0x277c => 0x89, 0x277d => 0x8a, 0x277e => 0x8b, 0x277f => 0x8c,
0x2780 => 0x8d, 0x2781 => 0x8e, 0x2782 => 0x8f, 0x2783 => 0x90,
0x2784 => 0x91, 0x2785 => 0x92, 0x2786 => 0x93, 0x2787 => 0x94,
0x2788 => 0x95, 0x2789 => 0x96, 0x278a => 0x97, 0x278b => 0x98,
0x278c => 0x99, 0x278d => 0x9a, 0x278e => 0x9b, 0x278f => 0x9c,
0x2790 => 0x9d, 0x2791 => 0x9e, 0x2792 => 0x9f, 0x2793 => 0xa0,
0x2794 => 0xa1, 0x2192 => 0xa2, 0x2194 => 0xa3, 0x2195 => 0xa4,
0x2798 => 0xa5, 0x2799 => 0xa6, 0x279a => 0xa7, 0x279b => 0xa8,
0x279c => 0xa9, 0x279d => 0xaa, 0x279e => 0xab, 0x279f => 0xac,
0x27a0 => 0xad, 0x27a1 => 0xae, 0x27a2 => 0xaf, 0x27a3 => 0xb0,
0x27a4 => 0xb1, 0x27a5 => 0xb2, 0x27a6 => 0xb3, 0x27a7 => 0xb4,
0x27a8 => 0xb5, 0x27a9 => 0xb6, 0x27aa => 0xb7, 0x27ab => 0xb8,
0x27ac => 0xb9, 0x27ad => 0xba, 0x27ae => 0xbb, 0x27af => 0xbc,
0x27b1 => 0xbd, 0x27b2 => 0xbe, 0x27b3 => 0xbf, 0x27b4 => 0xc0,
0x27b5 => 0xc1, 0x27b6 => 0xc2, 0x27b7 => 0xc3, 0x27b8 => 0xc4,
0x27b9 => 0xc5, 0x27ba => 0xc6, 0x27bb => 0xc7, 0x27bc => 0xc8,
0x27bd => 0xc9, 0x27be => 0xca);
$this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
/* Resource dictionary */
/* The resource dictionary for the standard fonts is sparse because PDF
* viewers already have all of the metrics data. We only need to provide
* the font name and encoding method.
*/
$this->_resource->BaseFont = new Zend_Pdf_Element_Name('ZapfDingbats');
/* This font has a built-in custom character encoding method. Don't
* override with WinAnsi like the other built-in fonts or else it will
* not work as expected.
*/
$this->_resource->Encoding = null;
}
/* Information and Conversion Methods */
/**
* Convert string encoding from local encoding to font encoding. Overridden
* to defeat the conversion behavior for this ornamental font.
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
*/
public function encodeString($string, $charEncoding)
{
/* This isn't the optimal time to perform this conversion, but it must
* live here until the remainder of the layout code is completed. This,
* and the $charEncoding parameter, will go away soon...
*/
if ($charEncoding != 'UTF-16BE') {
$string = iconv($charEncoding, 'UTF-16BE', $string);
}
/**
* @todo Properly handle characters encoded as surrogate pairs.
*/
$encodedString = '';
for ($i = 0; $i < strlen($string); $i++) {
$characterCode = (ord($string[$i++]) << 8) | ord($string[$i]);
if (isset($this->_toFontEncoding[$characterCode])) {
$encodedString .= $this->_toFontEncoding[$characterCode];
} else {
/* For now, mimic the behavior in Zend_Pdf_Font::encodeString()
* where unknown characters are removed completely. This is not
* perfect, but we should be consistent. In a future revision,
* we will use the well-known substitution character 0x1a
* (Control-Z).
*/
}
}
return $encodedString;
}
/**
* Convert string encoding from font encoding to local encoding. Overridden
* to defeat the conversion behavior for this ornamental font.
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
*/
public function decodeString($string, $charEncoding)
{
$decodedString = '';
for ($i = 0; $i < strlen($string); $i++) {
$characterCode = ord($string[$i]);
if (isset($this->_fromFontEncoding[$characterCode])) {
$decodedString .= $this->_fromFontEncoding[$characterCode];
} else {
/* For now, mimic the behavior in Zend_Pdf_Font::encodeString()
* where unknown characters are removed completely. This is not
* perfect, but we should be consistent. In a future revision,
* we will use the Unicode substitution character (U+FFFD).
*/
}
}
if ($charEncoding != 'UTF-16BE') {
$decodedString = iconv('UTF-16BE', $charEncoding, $decodedString);
}
return $decodedString;
}
/**
* Converts a Latin-encoded string that fakes the font's internal encoding
* to the proper Unicode characters, in UTF-16BE encoding.
*
* Used to maintain backwards compatibility with the 20 year-old legacy
* method of using this font, which is still employed by recent versions of
* some popular word processors.
*
* Note that using this method adds overhead due to the additional
* character conversion. Don't use this for new code; it is more efficient
* to use the appropriate Unicode characters directly.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source
* string. Defaults to current locale.
* @return string
*/
public function toUnicode($string, $charEncoding = '')
{
/* When using these faked strings, the closest match to the font's
* internal encoding is ISO-8859-1.
*/
if ($charEncoding != 'ISO-8859-1') {
$string = iconv($charEncoding, 'ISO-8859-1', $string);
}
return $this->decodeString($string, 'UTF-16BE');
}
}

View File

@ -0,0 +1,256 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Font */
require_once 'Zend/Pdf/Resource/Font.php';
/** Zend_Pdf_Resource_Font_CidFont */
require_once 'Zend/Pdf/Resource/Font/CidFont.php';
/** Zend_Pdf_Resource_Font_CidFont_TrueType */
require_once 'Zend/Pdf/Resource/Font/CidFont/TrueType.php';
/**
* Adobe PDF composite fonts implementation
*
* A composite font is one whose glyphs are obtained from other fonts or from fontlike
* objects called CIDFonts ({@link Zend_Pdf_Resource_Font_CidFont}), organized hierarchically.
* In PDF, a composite font is represented by a font dictionary whose Subtype value is Type0;
* this is also called a Type 0 font (the Type 0 font at the top level of the hierarchy is the
* root font).
*
* In PDF, a Type 0 font is a CID-keyed font.
*
* CID-keyed fonts provide effective method to operate with multi-byte character encodings.
*
* The CID-keyed font architecture specifies the external representation of certain font programs,
* called CMap and CIDFont files, along with some conventions for combining and using those files.
*
* A CID-keyed font is the combination of a CMap with one or more CIDFonts, simple fonts,
* or composite fonts containing glyph descriptions.
*
* The term 'CID-keyed font' reflects the fact that CID (character identifier) numbers
* are used to index and access the glyph descriptions in the font.
*
*
* Font objects should be normally be obtained from the factory methods
* {@link Zend_Pdf_Font::fontWithName} and {@link Zend_Pdf_Font::fontWithPath}.
*
* @package Zend_Pdf
* @subpackage Fonts
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Font_Type0 extends Zend_Pdf_Resource_Font
{
/**
* Descendant CIDFont
*
* @var Zend_Pdf_Resource_Font_CidFont
*/
private $_descendantFont;
/**
* Generate ToUnicode character map data
*
* @return string
*/
static private function getToUnicodeCMapData()
{
return '/CIDInit /ProcSet findresource begin ' . "\n"
. '12 dict begin ' . "\n"
. 'begincmap ' . "\n"
. '/CIDSystemInfo ' . "\n"
. '<</Registry (Adobe) ' . "\n"
. '/Ordering (UCS) ' . "\n"
. '/Supplement 0' . "\n"
. '>> def' . "\n"
. '/CMapName /Adobe-Identity-UCS def ' . "\n"
. '/CMapType 2 def ' . "\n"
. '1 begincodespacerange' . "\n"
. '<0000> <FFFF> ' . "\n"
. 'endcodespacerange ' . "\n"
. '1 beginbfrange ' . "\n"
. '<0000> <FFFF> <0000> ' . "\n"
. 'endbfrange ' . "\n"
. 'endcmap ' . "\n"
. 'CMapName currentdict /CMap defineresource pop ' . "\n"
. 'end '
. 'end ';
}
/**
* Object constructor
*
*/
public function __construct(Zend_Pdf_Resource_Font_CidFont $descendantFont)
{
parent::__construct();
$this->_objectFactory->attach($descendantFont->getFactory());
$this->_fontType = Zend_Pdf_Font::TYPE_TYPE_0;
$this->_descendantFont = $descendantFont;
$this->_fontNames = $descendantFont->getFontNames();
$this->_isBold = $descendantFont->isBold();
$this->_isItalic = $descendantFont->isItalic();
$this->_isMonospaced = $descendantFont->isMonospace();
$this->_underlinePosition = $descendantFont->getUnderlinePosition();
$this->_underlineThickness = $descendantFont->getUnderlineThickness();
$this->_strikePosition = $descendantFont->getStrikePosition();
$this->_strikeThickness = $descendantFont->getStrikeThickness();
$this->_unitsPerEm = $descendantFont->getUnitsPerEm();
$this->_ascent = $descendantFont->getAscent();
$this->_descent = $descendantFont->getDescent();
$this->_lineGap = $descendantFont->getLineGap();
$this->_resource->Subtype = new Zend_Pdf_Element_Name('Type0');
$this->_resource->BaseFont = new Zend_Pdf_Element_Name($descendantFont->getResource()->BaseFont->value);
$this->_resource->DescendantFonts = new Zend_Pdf_Element_Array(array( $descendantFont->getResource() ));
$this->_resource->Encoding = new Zend_Pdf_Element_Name('Identity-H');
$toUnicode = $this->_objectFactory->newStreamObject(self::getToUnicodeCMapData());
$this->_resource->ToUnicode = $toUnicode;
}
/**
* Returns an array of glyph numbers corresponding to the Unicode characters.
*
* Zend_Pdf uses 'Identity-H' encoding for Type 0 fonts.
* So we don't need to perform any conversion
*
* See also {@link glyphNumberForCharacter()}.
*
* @param array $characterCodes Array of Unicode character codes (code points).
* @return array Array of glyph numbers.
*/
public function glyphNumbersForCharacters($characterCodes)
{
return $characterCodes;
}
/**
* Returns the glyph number corresponding to the Unicode character.
*
* Zend_Pdf uses 'Identity-H' encoding for Type 0 fonts.
* So we don't need to perform any conversion
*
* @param integer $characterCode Unicode character code (code point).
* @return integer Glyph number.
*/
public function glyphNumberForCharacter($characterCode)
{
return $characterCode;
}
/**
* Returns a number between 0 and 1 inclusive that indicates the percentage
* of characters in the string which are covered by glyphs in this font.
*
* Since no one font will contain glyphs for the entire Unicode character
* range, this method can be used to help locate a suitable font when the
* actual contents of the string are not known.
*
* Note that some fonts lie about the characters they support. Additionally,
* fonts don't usually contain glyphs for control characters such as tabs
* and line breaks, so it is rare that you will get back a full 1.0 score.
* The resulting value should be considered informational only.
*
* @param string $string
* @param string $charEncoding (optional) Character encoding of source text.
* If omitted, uses 'current locale'.
* @return float
*/
public function getCoveredPercentage($string, $charEncoding = '')
{
return $this->_descendantFont->getCoveredPercentage($string, $charEncoding);
}
/**
* Returns the widths of the glyphs.
*
* The widths are expressed in the font's glyph space. You are responsible
* for converting to user space as necessary. See {@link unitsPerEm()}.
*
* Throws an exception if the glyph number is out of range.
*
* See also {@link widthForGlyph()}.
*
* @param array &$glyphNumbers Array of glyph numbers.
* @return array Array of glyph widths (integers).
* @throws Zend_Pdf_Exception
*/
public function widthsForGlyphs($glyphNumbers)
{
return $this->_descendantFont->widthsForChars($glyphNumbers);
}
/**
* Returns the width of the glyph.
*
* Like {@link widthsForGlyphs()} but used for one glyph at a time.
*
* @param integer $glyphNumber
* @return integer
* @throws Zend_Pdf_Exception
*/
public function widthForGlyph($glyphNumber)
{
return $this->_descendantFont->widthForChar($glyphNumber);
}
/**
* Convert string to the font encoding.
*
* The method is used to prepare string for text drawing operators
*
* @param string $string
* @param string $charEncoding Character encoding of source text.
* @return string
*/
public function encodeString($string, $charEncoding)
{
return iconv($charEncoding, 'UTF-16BE', $string);
}
/**
* Convert string from the font encoding.
*
* The method is used to convert strings retrieved from existing content streams
*
* @param string $string
* @param string $charEncoding Character encoding of resulting text.
* @return string
*/
public function decodeString($string, $charEncoding)
{
return iconv('UTF-16BE', $charEncoding, $string);
}
}

View File

@ -0,0 +1,78 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Dictionary */
require_once 'Zend/Pdf/Element/Dictionary.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/** Zend_Pdf_Resource */
require_once 'Zend/Pdf/Resource.php';
/**
* Image abstraction.
*
* Class is named not in accordance to the name convention.
* It's "end-user" class, but its ancestor is not.
* Thus part of the common class name is removed.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Resource_Image extends Zend_Pdf_Resource
{
/**
* Object constructor.
*/
public function __construct()
{
parent::__construct('');
$this->_resource->dictionary->Type = new Zend_Pdf_Element_Name('XObject');
$this->_resource->dictionary->Subtype = new Zend_Pdf_Element_Name('Image');
}
/**
* get the height in pixels of the image
*
* @return integer
*/
abstract public function getPixelHeight();
/**
* get the width in pixels of the image
*
* @return integer
*/
abstract public function getPixelWidth();
/**
* gets an associative array of information about an image
*
* @return array
*/
abstract public function getProperties();
}

View File

@ -0,0 +1,138 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Image */
require_once 'Zend/Pdf/Resource/Image.php';
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/**
* JPEG image
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Image_Jpeg extends Zend_Pdf_Resource_Image
{
protected $_width;
protected $_height;
protected $_imageProperties;
/**
* Object constructor
*
* @param string $imageFileName
* @throws Zend_Pdf_Exception
*/
public function __construct($imageFileName)
{
if (!function_exists('gd_info')) {
throw new Zend_Pdf_Exception('Image extension is not installed.');
}
$gd_options = gd_info();
if (!$gd_options['JPG Support'] ) {
throw new Zend_Pdf_Exception('JPG support is not configured properly.');
}
if (($imageInfo = getimagesize($imageFileName)) === false) {
throw new Zend_Pdf_Exception('Corrupted image or image doesn\'t exist.');
}
if ($imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_JPEG2000) {
throw new Zend_Pdf_Exception('ImageType is not JPG');
}
parent::__construct();
switch ($imageInfo['channels']) {
case 3:
$colorSpace = 'DeviceRGB';
break;
case 4:
$colorSpace = 'DeviceCMYK';
break;
default:
$colorSpace = 'DeviceGray';
break;
}
$imageDictionary = $this->_resource->dictionary;
$imageDictionary->Width = new Zend_Pdf_Element_Numeric($imageInfo[0]);
$imageDictionary->Height = new Zend_Pdf_Element_Numeric($imageInfo[1]);
$imageDictionary->ColorSpace = new Zend_Pdf_Element_Name($colorSpace);
$imageDictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric($imageInfo['bits']);
if ($imageInfo[2] == IMAGETYPE_JPEG) {
$imageDictionary->Filter = new Zend_Pdf_Element_Name('DCTDecode');
} else if ($imageInfo[2] == IMAGETYPE_JPEG2000){
$imageDictionary->Filter = new Zend_Pdf_Element_Name('JPXDecode');
}
if (($imageFile = @fopen($imageFileName, 'rb')) === false ) {
throw new Zend_Pdf_Exception( "Can not open '$imageFileName' file for reading." );
}
$byteCount = filesize($imageFileName);
$this->_resource->value = '';
while ( $byteCount > 0 && ($nextBlock = fread($imageFile, $byteCount)) != false ) {
$this->_resource->value .= $nextBlock;
$byteCount -= strlen($nextBlock);
}
fclose($imageFile);
$this->_resource->skipFilters();
$this->_width = $imageInfo[0];
$this->_height = $imageInfo[1];
$this->_imageProperties = array();
$this->_imageProperties['bitDepth'] = $imageInfo['bits'];
$this->_imageProperties['jpegImageType'] = $imageInfo[2];
$this->_imageProperties['jpegColorType'] = $imageInfo['channels'];
}
/**
* Image width
*/
public function getPixelWidth() {
return $this->_width;
}
/**
* Image height
*/
public function getPixelHeight() {
return $this->_height;
}
/**
* Image properties
*/
public function getProperties() {
return $this->_imageProperties;
}
}

View File

@ -0,0 +1,359 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Image */
require_once 'Zend/Pdf/Resource/Image.php';
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/** Zend_Pdf_ElementFactory */
require_once 'Zend/Pdf/ElementFactory.php';
/**
* PNG image
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
{
const PNG_COMPRESSION_DEFAULT_STRATEGY = 0;
const PNG_COMPRESSION_FILTERED = 1;
const PNG_COMPRESSION_HUFFMAN_ONLY = 2;
const PNG_COMPRESSION_RLE = 3;
const PNG_FILTER_NONE = 0;
const PNG_FILTER_SUB = 1;
const PNG_FILTER_UP = 2;
const PNG_FILTER_AVERAGE = 3;
const PNG_FILTER_PAETH = 4;
const PNG_INTERLACING_DISABLED = 0;
const PNG_INTERLACING_ENABLED = 1;
const PNG_CHANNEL_GRAY = 0;
const PNG_CHANNEL_RGB = 2;
const PNG_CHANNEL_INDEXED = 3;
const PNG_CHANNEL_GRAY_ALPHA = 4;
const PNG_CHANNEL_RGB_ALPHA = 6;
protected $_width;
protected $_height;
protected $_imageProperties;
/**
* Object constructor
*
* @param string $imageFileName
* @throws Zend_Pdf_Exception
* @todo Add compression conversions to support compression strategys other than PNG_COMPRESSION_DEFAULT_STRATEGY.
* @todo Add pre-compression filtering.
* @todo Add interlaced image handling.
* @todo Add support for 16-bit images. Requires PDF version bump to 1.5 at least.
* @todo Add processing for all PNG chunks defined in the spec. gAMA etc.
* @todo Fix tRNS chunk support for Indexed Images to a SMask.
*/
public function __construct($imageFileName)
{
if (($imageFile = @fopen($imageFileName, 'rb')) === false ) {
throw new Zend_Pdf_Exception( "Can not open '$imageFileName' file for reading." );
}
parent::__construct();
//Check if the file is a PNG
fseek($imageFile, 1, SEEK_CUR); //First signature byte (%)
if ('PNG' != fread($imageFile, 3)) {
throw new Zend_Pdf_Exception('Image is not a PNG');
}
fseek($imageFile, 12, SEEK_CUR); //Signature bytes (Includes the IHDR chunk) IHDR processed linerarly because it doesnt contain a variable chunk length
$wtmp = unpack('Ni',fread($imageFile, 4)); //Unpack a 4-Byte Long
$width = $wtmp['i'];
$htmp = unpack('Ni',fread($imageFile, 4));
$height = $htmp['i'];
$bits = ord(fread($imageFile, 1)); //Higher than 8 bit depths are only supported in later versions of PDF.
$color = ord(fread($imageFile, 1));
$compression = ord(fread($imageFile, 1));
$prefilter = ord(fread($imageFile,1));
if (($interlacing = ord(fread($imageFile,1))) != Zend_Pdf_Resource_Image_Png::PNG_INTERLACING_DISABLED) {
throw new Zend_Pdf_Exception( "Only non-interlaced images are currently supported." );
}
$this->_width = $width;
$this->_height = $height;
$this->_imageProperties = array();
$this->_imageProperties['bitDepth'] = $bits;
$this->_imageProperties['pngColorType'] = $color;
$this->_imageProperties['pngFilterType'] = $prefilter;
$this->_imageProperties['pngCompressionType'] = $compression;
$this->_imageProperties['pngInterlacingType'] = $interlacing;
fseek($imageFile, 4, SEEK_CUR); //4 Byte Ending Sequence
$imageData = '';
/*
* The following loop processes PNG chunks. 4 Byte Longs are packed first give the chunk length
* followed by the chunk signature, a four byte code. IDAT and IEND are manditory in any PNG.
*/
while(($chunkLengthBytes = fread($imageFile, 4)) !== false) {
$chunkLengthtmp = unpack('Ni', $chunkLengthBytes);
$chunkLength = $chunkLengthtmp['i'];
$chunkType = fread($imageFile, 4);
switch($chunkType) {
case 'IDAT': //Image Data
/*
* Reads the actual image data from the PNG file. Since we know at this point that the compression
* strategy is the default strategy, we also know that this data is Zip compressed. We will either copy
* the data directly to the PDF and provide the correct FlateDecode predictor, or decompress the data
* decode the filters and output the data as a raw pixel map.
*/
$imageData .= fread($imageFile, $chunkLength);
fseek($imageFile, 4, SEEK_CUR);
break;
case 'PLTE': //Palette
$paletteData = fread($imageFile, $chunkLength);
fseek($imageFile, 4, SEEK_CUR);
break;
case 'tRNS': //Basic (non-alpha channel) transparency.
$trnsData = fread($imageFile, $chunkLength);
switch ($color) {
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_GRAY:
$baseColor = ord(substr($trnsData, 1, 1));
$transparencyData = array(new Zend_Pdf_Element_Numeric($baseColor), new Zend_Pdf_Element_Numeric($baseColor));
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB:
$red = ord(substr($trnsData,1,1));
$green = ord(substr($trnsData,3,1));
$blue = ord(substr($trnsData,5,1));
$transparencyData = array(new Zend_Pdf_Element_Numeric($red), new Zend_Pdf_Element_Numeric($red), new Zend_Pdf_Element_Numeric($green), new Zend_Pdf_Element_Numeric($green), new Zend_Pdf_Element_Numeric($blue), new Zend_Pdf_Element_Numeric($blue));
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_INDEXED:
//Find the first transparent color in the index, we will mask that. (This is a bit of a hack. This should be a SMask and mask all entries values).
if(($trnsIdx = strpos($trnsData, chr(0))) !== false) {
$transparencyData = array(new Zend_Pdf_Element_Numeric($trnsIdx), new Zend_Pdf_Element_Numeric($trnsIdx));
}
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_GRAY_ALPHA:
// Fall through to the next case
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB_ALPHA:
throw new Zend_Pdf_Exception( "tRNS chunk illegal for Alpha Channel Images" );
break;
}
fseek($imageFile, 4, SEEK_CUR); //4 Byte Ending Sequence
break;
case 'IEND';
break 2; //End the loop too
default:
fseek($imageFile, $chunkLength + 4, SEEK_CUR); //Skip the section
break;
}
}
fclose($imageFile);
$compressed = true;
$imageDataTmp = '';
$smaskData = '';
switch ($color) {
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB:
$colorSpace = new Zend_Pdf_Element_Name('DeviceRGB');
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_GRAY:
$colorSpace = new Zend_Pdf_Element_Name('DeviceGray');
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_INDEXED:
if(empty($paletteData)) {
throw new Zend_Pdf_Exception( "PNG Corruption: No palette data read for indexed type PNG." );
}
$colorSpace = new Zend_Pdf_Element_Array();
$colorSpace->items[] = new Zend_Pdf_Element_Name('Indexed');
$colorSpace->items[] = new Zend_Pdf_Element_Name('DeviceRGB');
$colorSpace->items[] = new Zend_Pdf_Element_Numeric((strlen($paletteData)/3-1));
$paletteObject = $this->_objectFactory->newObject(new Zend_Pdf_Element_String_Binary($paletteData));
$colorSpace->items[] = $paletteObject;
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_GRAY_ALPHA:
/*
* To decode PNG's with alpha data we must create two images from one. One image will contain the Gray data
* the other will contain the Gray transparency overlay data. The former will become the object data and the latter
* will become the Shadow Mask (SMask).
*/
if($bits > 8) {
throw new Zend_Pdf_Exception("Alpha PNGs with bit depth > 8 are not yet supported");
}
$colorSpace = new Zend_Pdf_Element_Name('DeviceGray');
$decodingObjFactory = Zend_Pdf_ElementFactory::createFactory(1);
$decodingStream = $decodingObjFactory->newStreamObject($imageData);
$decodingStream->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
$decodingStream->dictionary->DecodeParms = new Zend_Pdf_Element_Dictionary();
$decodingStream->dictionary->DecodeParms->Predictor = new Zend_Pdf_Element_Numeric(15);
$decodingStream->dictionary->DecodeParms->Columns = new Zend_Pdf_Element_Numeric($width);
$decodingStream->dictionary->DecodeParms->Colors = new Zend_Pdf_Element_Numeric(2); //GreyAlpha
$decodingStream->dictionary->DecodeParms->BitsPerComponent = new Zend_Pdf_Element_Numeric($bits);
$decodingStream->skipFilters();
$pngDataRawDecoded = $decodingStream->value;
//Iterate every pixel and copy out gray data and alpha channel (this will be slow)
for($pixel = 0, $pixelcount = ($width * $height); $pixel < $pixelcount; $pixel++) {
$imageDataTmp .= $pngDataRawDecoded[($pixel*2)];
$smaskData .= $pngDataRawDecoded[($pixel*2)+1];
}
$compressed = false;
$imageData = $imageDataTmp; //Overwrite image data with the gray channel without alpha
break;
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB_ALPHA:
/*
* To decode PNG's with alpha data we must create two images from one. One image will contain the RGB data
* the other will contain the Gray transparency overlay data. The former will become the object data and the latter
* will become the Shadow Mask (SMask).
*/
if($bits > 8) {
throw new Zend_Pdf_Exception("Alpha PNGs with bit depth > 8 are not yet supported");
}
$colorSpace = new Zend_Pdf_Element_Name('DeviceRGB');
$decodingObjFactory = Zend_Pdf_ElementFactory::createFactory(1);
$decodingStream = $decodingObjFactory->newStreamObject($imageData);
$decodingStream->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
$decodingStream->dictionary->DecodeParms = new Zend_Pdf_Element_Dictionary();
$decodingStream->dictionary->DecodeParms->Predictor = new Zend_Pdf_Element_Numeric(15);
$decodingStream->dictionary->DecodeParms->Columns = new Zend_Pdf_Element_Numeric($width);
$decodingStream->dictionary->DecodeParms->Colors = new Zend_Pdf_Element_Numeric(4); //RGBA
$decodingStream->dictionary->DecodeParms->BitsPerComponent = new Zend_Pdf_Element_Numeric($bits);
$decodingStream->skipFilters();
$pngDataRawDecoded = $decodingStream->value;
//Iterate every pixel and copy out rgb data and alpha channel (this will be slow)
for($pixel = 0, $pixelcount = ($width * $height); $pixel < $pixelcount; $pixel++) {
$imageDataTmp .= $pngDataRawDecoded[($pixel*4)+0] . $pngDataRawDecoded[($pixel*4)+1] . $pngDataRawDecoded[($pixel*4)+2];
$smaskData .= $pngDataRawDecoded[($pixel*4)+3];
}
$compressed = false;
$imageData = $imageDataTmp; //Overwrite image data with the RGB channel without alpha
break;
default:
throw new Zend_Pdf_Exception( "PNG Corruption: Invalid color space." );
}
if(empty($imageData)) {
throw new Zend_Pdf_Exception( "Corrupt PNG Image. Mandatory IDAT chunk not found." );
}
$imageDictionary = $this->_resource->dictionary;
if(!empty($smaskData)) {
/*
* Includes the Alpha transparency data as a Gray Image, then assigns the image as the Shadow Mask for the main image data.
*/
$smaskStream = $this->_objectFactory->newStreamObject($smaskData);
$smaskStream->dictionary->Type = new Zend_Pdf_Element_Name('XObject');
$smaskStream->dictionary->Subtype = new Zend_Pdf_Element_Name('Image');
$smaskStream->dictionary->Width = new Zend_Pdf_Element_Numeric($width);
$smaskStream->dictionary->Height = new Zend_Pdf_Element_Numeric($height);
$smaskStream->dictionary->ColorSpace = new Zend_Pdf_Element_Name('DeviceGray');
$smaskStream->dictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric($bits);
$imageDictionary->SMask = $smaskStream;
// Encode stream with FlateDecode filter
$smaskStreamDecodeParms = array();
$smaskStreamDecodeParms['Predictor'] = new Zend_Pdf_Element_Numeric(15);
$smaskStreamDecodeParms['Columns'] = new Zend_Pdf_Element_Numeric($width);
$smaskStreamDecodeParms['Colors'] = new Zend_Pdf_Element_Numeric(1);
$smaskStreamDecodeParms['BitsPerComponent'] = new Zend_Pdf_Element_Numeric(8);
$smaskStream->dictionary->DecodeParms = new Zend_Pdf_Element_Dictionary($smaskStreamDecodeParms);
$smaskStream->dictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
}
if(!empty($transparencyData)) {
//This is experimental and not properly tested.
$imageDictionary->Mask = new Zend_Pdf_Element_Array($transparencyData);
}
$imageDictionary->Width = new Zend_Pdf_Element_Numeric($width);
$imageDictionary->Height = new Zend_Pdf_Element_Numeric($height);
$imageDictionary->ColorSpace = $colorSpace;
$imageDictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric($bits);
$imageDictionary->Filter = new Zend_Pdf_Element_Name('FlateDecode');
$decodeParms = array();
$decodeParms['Predictor'] = new Zend_Pdf_Element_Numeric(15); // Optimal prediction
$decodeParms['Columns'] = new Zend_Pdf_Element_Numeric($width);
$decodeParms['Colors'] = new Zend_Pdf_Element_Numeric((($color==Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB || $color==Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB_ALPHA)?(3):(1)));
$decodeParms['BitsPerComponent'] = new Zend_Pdf_Element_Numeric($bits);
$imageDictionary->DecodeParms = new Zend_Pdf_Element_Dictionary($decodeParms);
//Include only the image IDAT section data.
$this->_resource->value = $imageData;
//Skip double compression
if ($compressed) {
$this->_resource->skipFilters();
}
}
/**
* Image width
*/
public function getPixelWidth() {
return $this->_width;
}
/**
* Image height
*/
public function getPixelHeight() {
return $this->_height;
}
/**
* Image properties
*/
public function getProperties() {
return $this->_imageProperties;
}
}

View File

@ -0,0 +1,431 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Resource_Image */
require_once 'Zend/Pdf/Resource/Image.php';
/** Zend_Pdf_Exception */
require_once 'Zend/Pdf/Exception.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/**
* TIFF image
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
{
const TIFF_FIELD_TYPE_BYTE=1;
const TIFF_FIELD_TYPE_ASCII=2;
const TIFF_FIELD_TYPE_SHORT=3;
const TIFF_FIELD_TYPE_LONG=4;
const TIFF_FIELD_TYPE_RATIONAL=5;
const TIFF_TAG_IMAGE_WIDTH=256;
const TIFF_TAG_IMAGE_LENGTH=257; //Height
const TIFF_TAG_BITS_PER_SAMPLE=258;
const TIFF_TAG_COMPRESSION=259;
const TIFF_TAG_PHOTOMETRIC_INTERPRETATION=262;
const TIFF_TAG_STRIP_OFFSETS=273;
const TIFF_TAG_SAMPLES_PER_PIXEL=277;
const TIFF_TAG_STRIP_BYTE_COUNTS=279;
const TIFF_COMPRESSION_UNCOMPRESSED = 1;
const TIFF_COMPRESSION_CCITT1D = 2;
const TIFF_COMPRESSION_GROUP_3_FAX = 3;
const TIFF_COMPRESSION_GROUP_4_FAX = 4;
const TIFF_COMPRESSION_LZW = 5;
const TIFF_COMPRESSION_JPEG = 6;
const TIFF_COMPRESSION_FLATE = 8;
const TIFF_COMPRESSION_FLATE_OBSOLETE_CODE = 32946;
const TIFF_COMPRESSION_PACKBITS = 32773;
const TIFF_PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO=0;
const TIFF_PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO=1;
const TIFF_PHOTOMETRIC_INTERPRETATION_RGB=2;
const TIFF_PHOTOMETRIC_INTERPRETATION_RGB_INDEXED=3;
const TIFF_PHOTOMETRIC_INTERPRETATION_CMYK=5;
const TIFF_PHOTOMETRIC_INTERPRETATION_YCBCR=6;
const TIFF_PHOTOMETRIC_INTERPRETATION_CIELAB=8;
protected $_width;
protected $_height;
protected $_imageProperties;
protected $_endianType;
protected $_fileSize;
protected $_bitsPerSample;
protected $_compression;
protected $_filter;
protected $_colorCode;
protected $_whiteIsZero;
protected $_blackIsZero;
protected $_colorSpace;
protected $_imageDataOffset;
protected $_imageDataLength;
const TIFF_ENDIAN_BIG=0;
const TIFF_ENDIAN_LITTLE=1;
const UNPACK_TYPE_BYTE=0;
const UNPACK_TYPE_SHORT=1;
const UNPACK_TYPE_LONG=2;
const UNPACK_TYPE_RATIONAL=3;
/**
* Byte unpacking function
*
* Makes it possible to unpack bytes in one statement for enhanced logic readability.
*
* @param int $type
* @param string $bytes
* @throws Zend_Pdf_Exception
*/
protected function unpackBytes($type, $bytes) {
if(!isset($this->_endianType)) {
throw new Zend_Pdf_Exception("The unpackBytes function can only be used after the endianness of the file is known");
}
switch($type) {
case Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_BYTE:
$format = 'C';
$unpacked = unpack($format, $bytes);
return $unpacked[1];
break;
case Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT:
$format = ($this->_endianType == Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_LITTLE)?'v':'n';
$unpacked = unpack($format, $bytes);
return $unpacked[1];
break;
case Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_LONG:
$format = ($this->_endianType == Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_LITTLE)?'V':'N';
$unpacked = unpack($format, $bytes);
return $unpacked[1];
break;
case Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_RATIONAL:
$format = ($this->_endianType == Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_LITTLE)?'V2':'N2';
$unpacked = unpack($format, $bytes);
return ($unpacked[1]/$unpacked[2]);
break;
}
}
/**
* Object constructor
*
* @param string $imageFileName
* @throws Zend_Pdf_Exception
*/
public function __construct($imageFileName)
{
if (($imageFile = @fopen($imageFileName, 'rb')) === false ) {
throw new Zend_Pdf_Exception( "Can not open '$imageFileName' file for reading." );
}
$byteOrderIndicator = fread($imageFile, 2);
if($byteOrderIndicator == 'II') {
$this->_endianType = Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_LITTLE;
} else if($byteOrderIndicator == 'MM') {
$this->_endianType = Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_BIG;
} else {
throw new Zend_Pdf_Exception( "Not a tiff file or Tiff corrupt. No byte order indication found" );
}
$version = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT, fread($imageFile, 2));
if($version != 42) {
throw new Zend_Pdf_Exception( "Not a tiff file or Tiff corrupt. Incorrect version number." );
}
$ifdOffset = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_LONG, fread($imageFile, 4));
$fileStats = fstat($imageFile);
$this->_fileSize = $fileStats['size'];
/*
* Tiff files are stored as a series of Image File Directories (IFD) each direcctory
* has a specific number of entries each 12 bytes in length. At the end of the directories
* is four bytes pointing to the offset of the next IFD.
*/
while($ifdOffset > 0) {
if(fseek($imageFile, $ifdOffset, SEEK_SET) == -1 || $ifdOffset+2 >= $this->_fileSize) {
throw new Zend_Pdf_Exception("Could not seek to the image file directory as indexed by the file. Likely cause is TIFF corruption. Offset: ". $ifdOffset);
}
$numDirEntries = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT, fread($imageFile, 2));
/*
* Since we now know how many entries are in this (IFD) we can extract the data.
* The format of a TIFF directory entry is:
*
* 2 bytes (short) tag code; See TIFF_TAG constants at the top for supported values. (There are many more in the spec)
* 2 bytes (short) field type
* 4 bytes (long) number of values, or value count.
* 4 bytes (mixed) data if the data will fit into 4 bytes or an offset if the data is too large.
*/
for($dirEntryIdx = 1; $dirEntryIdx <= $numDirEntries; $dirEntryIdx++) {
$tag = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT, fread($imageFile, 2));
$fieldType = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT, fread($imageFile, 2));
$valueCount = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_LONG, fread($imageFile, 4));
switch($fieldType) {
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_BYTE:
$fieldLength = $valueCount;
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_ASCII:
$fieldLength = $valueCount;
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_SHORT:
$fieldLength = $valueCount * 2;
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_LONG:
$fieldLength = $valueCount * 4;
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_RATIONAL:
$fieldLength = $valueCount * 8;
break;
default:
$fieldLength = $valueCount;
}
$offsetBytes = fread($imageFile, 4);
if($fieldLength <= 4) {
switch($fieldType) {
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_BYTE:
$value = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_BYTE, $offsetBytes);
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_ASCII:
//Fall through to next case
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_LONG:
$value = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_LONG, $offsetBytes);
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_FIELD_TYPE_SHORT:
//Fall through to next case
default:
$value = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT, $offsetBytes);
}
} else {
$refOffset = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_LONG, $offsetBytes);
}
/*
* Linear tag processing is probably not the best way to do this. I've processed the tags according to the
* Tiff 6 specification and make some assumptions about when tags will be < 4 bytes and fit into $value and when
* they will be > 4 bytes and require seek/extraction of the offset. Same goes for extracting arrays of data, like
* the data offsets and length. This should be fixed in the future.
*/
switch($tag) {
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_IMAGE_WIDTH:
$this->_width = $value;
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_IMAGE_LENGTH:
$this->_height = $value;
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_BITS_PER_SAMPLE:
if($valueCount>1) {
$fp = ftell($imageFile);
fseek($imageFile, $refOffset, SEEK_SET);
$this->_bitsPerSample = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_SHORT, fread($imageFile, 2));
fseek($imageFile, $fp, SEEK_SET);
} else {
$this->_bitsPerSample = $value;
}
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_COMPRESSION:
$this->_compression = $value;
switch($value) {
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_UNCOMPRESSED:
$this->_filter = 'None';
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_CCITT1D:
//Fall through to next case
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_GROUP_3_FAX:
//Fall through to next case
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_GROUP_4_FAX:
$this->_filter = 'CCITTFaxDecode';
throw new Zend_Pdf_Exception("CCITTFaxDecode Compression Mode Not Currently Supported");
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_LZW:
$this->_filter = 'LZWDecode';
throw new Zend_Pdf_Exception("LZWDecode Compression Mode Not Currently Supported");
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_JPEG:
$this->_filter = 'DCTDecode'; //Should work, doesnt...
throw new Zend_Pdf_Exception("JPEG Compression Mode Not Currently Supported");
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_FLATE:
//fall through to next case
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_FLATE_OBSOLETE_CODE:
$this->_filter = 'FlateDecode';
throw new Zend_Pdf_Exception("ZIP/Flate Compression Mode Not Currently Supported");
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_PACKBITS:
$this->_filter = 'RunLengthDecode';
break;
}
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_PHOTOMETRIC_INTERPRETATION:
$this->_colorCode = $value;
$this->_whiteIsZero = false;
$this->_blackIsZero = false;
switch($value) {
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO:
$this->_whiteIsZero = true;
$this->_colorSpace = 'DeviceGray';
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO:
$this->_blackIsZero = true;
$this->_colorSpace = 'DeviceGray';
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_YCBCR:
//fall through to next case
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_RGB:
$this->_colorSpace = 'DeviceRGB';
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_RGB_INDEXED:
$this->_colorSpace = 'Indexed';
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_CMYK:
$this->_colorSpace = 'DeviceCMYK';
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_PHOTOMETRIC_INTERPRETATION_CIELAB:
$this->_colorSpace = 'Lab';
break;
default:
throw new Zend_Pdf_Exception('TIFF: Unknown or Unsupported Color Type: '. $value);
}
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_STRIP_OFFSETS:
if($valueCount>1) {
$format = ($this->_endianType == Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_LITTLE)?'V*':'N*';
$fp = ftell($imageFile);
fseek($imageFile, $refOffset, SEEK_SET);
$stripOffsetsBytes = fread($imageFile, $fieldLength);
$this->_imageDataOffset = unpack($format, $stripOffsetsBytes);
fseek($imageFile, $fp, SEEK_SET);
} else {
$this->_imageDataOffset = $value;
}
break;
case Zend_Pdf_Resource_Image_Tiff::TIFF_TAG_STRIP_BYTE_COUNTS:
if($valueCount>1) {
$format = ($this->_endianType == Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_LITTLE)?'V*':'N*';
$fp = ftell($imageFile);
fseek($imageFile, $refOffset, SEEK_SET);
$stripByteCountsBytes = fread($imageFile, $fieldLength);
$this->_imageDataLength = unpack($format, $stripByteCountsBytes);
fseek($imageFile, $fp, SEEK_SET);
} else {
$this->_imageDataLength = $value;
}
break;
default:
//For debugging. It should be harmless to ignore unknown tags, though there is some good info in them.
//echo "Unknown tag detected: ". $tag . " value: ". $value;
}
}
$ifdOffset = $this->unpackBytes(Zend_Pdf_Resource_Image_Tiff::UNPACK_TYPE_LONG, fread($imageFile, 4));
}
if(!isset($this->_imageDataOffset) || !isset($this->_imageDataLength)) {
throw new Zend_Pdf_Exception("TIFF: The image processed did not contain image data as expected.");
}
$imageDataBytes = '';
if(is_array($this->_imageDataOffset)) {
if(!is_array($this->_imageDataLength)) {
throw new Zend_Pdf_Exception("TIFF: The image contained multiple data offsets but not multiple data lengths. Tiff may be corrupt.");
}
foreach($this->_imageDataOffset as $idx => $offset) {
fseek($imageFile, $this->_imageDataOffset[$idx], SEEK_SET);
$imageDataBytes .= fread($imageFile, $this->_imageDataLength[$idx]);
}
} else {
fseek($imageFile, $this->_imageDataOffset, SEEK_SET);
$imageDataBytes = fread($imageFile, $this->_imageDataLength);
}
if($imageDataBytes === '') {
throw new Zend_Pdf_Exception("TIFF: No data. Image Corruption");
}
fclose($imageFile);
parent::__construct();
$imageDictionary = $this->_resource->dictionary;
if(!isset($this->_width) || !isset($this->_width)) {
throw new Zend_Pdf_Exception("Problem reading tiff file. Tiff is probably corrupt.");
}
$this->_imageProperties = array();
$this->_imageProperties['bitDepth'] = $this->_bitsPerSample;
$this->_imageProperties['fileSize'] = $this->_fileSize;
$this->_imageProperties['TIFFendianType'] = $this->_endianType;
$this->_imageProperties['TIFFcompressionType'] = $this->_compression;
$this->_imageProperties['TIFFwhiteIsZero'] = $this->_whiteIsZero;
$this->_imageProperties['TIFFblackIsZero'] = $this->_blackIsZero;
$this->_imageProperties['TIFFcolorCode'] = $this->_colorCode;
$this->_imageProperties['TIFFimageDataOffset'] = $this->_imageDataOffset;
$this->_imageProperties['TIFFimageDataLength'] = $this->_imageDataLength;
$this->_imageProperties['PDFfilter'] = $this->_filter;
$this->_imageProperties['PDFcolorSpace'] = $this->_colorSpace;
$imageDictionary->Width = new Zend_Pdf_Element_Numeric($this->_width);
if($this->_whiteIsZero === true) {
$imageDictionary->Decode = new Zend_Pdf_Element_Array(array(new Zend_Pdf_Element_Numeric(1), new Zend_Pdf_Element_Numeric(0)));
}
$imageDictionary->Height = new Zend_Pdf_Element_Numeric($this->_height);
$imageDictionary->ColorSpace = new Zend_Pdf_Element_Name($this->_colorSpace);
$imageDictionary->BitsPerComponent = new Zend_Pdf_Element_Numeric($this->_bitsPerSample);
if(isset($this->_filter) && $this->_filter != 'None') {
$imageDictionary->Filter = new Zend_Pdf_Element_Name($this->_filter);
}
$this->_resource->value = $imageDataBytes;
$this->_resource->skipFilters();
}
/**
* Image width (defined in Zend_Pdf_Resource_Image_Interface)
*/
public function getPixelWidth() {
return $this->_width;
}
/**
* Image height (defined in Zend_Pdf_Resource_Image_Interface)
*/
public function getPixelHeight() {
return $this->_height;
}
/**
* Image properties (defined in Zend_Pdf_Resource_Image_Interface)
*/
public function getProperties() {
return $this->_imageProperties;
}
}

View File

@ -0,0 +1,68 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf */
require_once 'Zend/Pdf.php';
/**
* Zend_Pdf_ImageFactory
*
* Helps manage the diverse set of supported image file types.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @todo Use Zend_Mime not file extension for type determination.
*/
class Zend_Pdf_Resource_ImageFactory
{
public static function factory($filename) {
if(!is_file($filename)) {
throw new Zend_Pdf_Exception("Cannot create image resource. File not found.");
}
$extension = pathinfo($filename, PATHINFO_EXTENSION);
/*
* There are plans to use Zend_Mime and not file extension. In the mean time, if you need to
* use an alternate file extension just spin up the right processor directly.
*/
switch (strtolower($extension)) {
case 'tif':
//Fall through to next case;
case 'tiff':
return new Zend_Pdf_Resource_Image_Tiff($filename);
break;
case 'png':
return new Zend_Pdf_Resource_Image_Png($filename);
break;
case 'jpg':
//Fall through to next case;
case 'jpe':
//Fall through to next case;
case 'jpeg':
return new Zend_Pdf_Resource_Image_Jpeg($filename);
break;
default:
throw new Zend_Pdf_Exception("Cannot create image resource. File extension not known or unsupported type.");
break;
}
}
}

View File

@ -0,0 +1,709 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_Element_Array */
require_once 'Zend/Pdf/Element/Array.php';
/** Zend_Pdf_Element_String_Binary */
require_once 'Zend/Pdf/Element/String/Binary.php';
/** Zend_Pdf_Element_Boolean */
require_once 'Zend/Pdf/Element/Boolean.php';
/** Zend_Pdf_Element_Dictionary */
require_once 'Zend/Pdf/Element/Dictionary.php';
/** Zend_Pdf_Element_Name */
require_once 'Zend/Pdf/Element/Name.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Reference */
require_once 'Zend/Pdf/Element/Reference.php';
/** Zend_Pdf_Element_Object_Stream */
require_once 'Zend/Pdf/Element/Object/Stream.php';
/** Zend_Pdf_Element_String */
require_once 'Zend/Pdf/Element/String.php';
/** Zend_Pdf_Element_Null */
require_once 'Zend/Pdf/Element/Null.php';
/** Zend_Pdf_Element_Reference_Context */
require_once 'Zend/Pdf/Element/Reference/Context.php';
/** Zend_Pdf_Element_Reference_Table */
require_once 'Zend/Pdf/Element/Reference/Table.php';
/** Zend_Pdf_ElementFactory_Interface */
require_once 'Zend/Pdf/ElementFactory/Interface.php';
/** Zend_Pdf_PhpArray */
require_once 'Zend/Pdf/PhpArray.php';
/**
* PDF string parser
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_StringParser
{
/**
* Source PDF
*
* @var string
*/
public $data = '';
/**
* Current position in a data
*
* @var integer
*/
public $offset = 0;
/**
* Current reference context
*
* @var Zend_Pdf_Element_Reference_Context
*/
private $_context = null;
/**
* Array of elements of the currently parsed object/trailer
*
* @var array
*/
private $_elements = array();
/**
* PDF objects factory.
*
* @var Zend_Pdf_ElementFactory_Interface
*/
private $_objFactory = null;
/**
* Clean up resources.
*
* Clear current state to remove cyclic object references
*/
public function cleanUp()
{
$this->_context = null;
$this->_elements = array();
$this->_objFactory = null;
}
/**
* Character with code $chCode is white space
*
* @param integer $chCode
* @return boolean
*/
public static function isWhiteSpace($chCode)
{
if ($chCode == 0x00 || // null character
$chCode == 0x09 || // Tab
$chCode == 0x0A || // Line feed
$chCode == 0x0C || // Form Feed
$chCode == 0x0D || // Carriage return
$chCode == 0x20 // Space
) {
return true;
} else {
return false;
}
}
/**
* Character with code $chCode is a delimiter character
*
* @param integer $chCode
* @return boolean
*/
public static function isDelimiter($chCode )
{
if ($chCode == 0x28 || // '('
$chCode == 0x29 || // ')'
$chCode == 0x3C || // '<'
$chCode == 0x3E || // '>'
$chCode == 0x5B || // '['
$chCode == 0x5D || // ']'
$chCode == 0x7B || // '{'
$chCode == 0x7D || // '}'
$chCode == 0x2F || // '/'
$chCode == 0x25 // '%'
) {
return true;
} else {
return false;
}
}
/**
* Skip white space
*
* @param boolean $skipComment
*/
public function skipWhiteSpace($skipComment = true)
{
while ($this->offset < strlen($this->data)) {
if (self::isWhiteSpace( ord($this->data[$this->offset]) )) {
$this->offset++;
} else if (ord($this->data[$this->offset]) == 0x25 && $skipComment) { // '%'
$this->skipComment();
} else {
return;
}
}
}
/**
* Skip comment
*/
public function skipComment()
{
while ($this->offset < strlen($this->data))
{
if (ord($this->data[$this->offset]) != 0x0A || // Line feed
ord($this->data[$this->offset]) != 0x0d // Carriage return
) {
$this->offset++;
} else {
return;
}
}
}
/**
* Read comment line
*
* @return string
*/
public function readComment()
{
$this->skipWhiteSpace(false);
/** Check if it's a comment line */
if ($this->data[$this->offset] != '%') {
return '';
}
for ($start = $this->offset;
$this->offset < strlen($this->data);
$this->offset++) {
if (ord($this->data[$this->offset]) == 0x0A || // Line feed
ord($this->data[$this->offset]) == 0x0d // Carriage return
) {
break;
}
}
return substr($this->data, $start, $this->offset-$start);
}
/**
* Returns next lexeme from a pdf stream
*
* @return string
*/
public function readLexeme()
{
$this->skipWhiteSpace();
if ($this->offset >= strlen($this->data)) {
return '';
}
$start = $this->offset;
if (self::isDelimiter( ord($this->data[$start]) )) {
if ($this->data[$start] == '<' && $this->offset + 1 < strlen($this->data) && $this->data[$start+1] == '<') {
$this->offset += 2;
return '<<';
} else if ($this->data[$start] == '>' && $this->offset + 1 < strlen($this->data) && $this->data[$start+1] == '>') {
$this->offset += 2;
return '>>';
} else {
$this->offset++;
return $this->data[$start];
}
} else {
while ( ($this->offset < strlen($this->data)) &&
(!self::isDelimiter( ord($this->data[$this->offset]) )) &&
(!self::isWhiteSpace( ord($this->data[$this->offset]) )) ) {
$this->offset++;
}
return substr($this->data, $start, $this->offset - $start);
}
}
/**
* Read elemental object from a PDF stream
*
* @return Zend_Pdf_Element
* @throws Zend_Pdf_Exception
*/
public function readElement($nextLexeme = null)
{
if ($nextLexeme === null) {
$nextLexeme = $this->readLexeme();
}
/**
* Note: readElement() method is a public method and could be invoked from other classes.
* If readElement() is used not by Zend_Pdf_StringParser::getObject() method, then we should not care
* about _elements member management.
*/
switch ($nextLexeme) {
case '(':
return ($this->_elements[] = $this->_readString());
case '<':
return ($this->_elements[] = $this->_readBinaryString());
case '/':
return ($this->_elements[] = new Zend_Pdf_Element_Name(
Zend_Pdf_Element_Name::unescape( $this->readLexeme() )
));
case '[':
return ($this->_elements[] = $this->_readArray());
case '<<':
return ($this->_elements[] = $this->_readDictionary());
case ')':
// fall through to next case
case '>':
// fall through to next case
case ']':
// fall through to next case
case '>>':
// fall through to next case
case '{':
// fall through to next case
case '}':
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X.',
$this->offset));
default:
if (strcasecmp($nextLexeme, 'true') == 0) {
return ($this->_elements[] = new Zend_Pdf_Element_Boolean(true));
} else if (strcasecmp($nextLexeme, 'false') == 0) {
return ($this->_elements[] = new Zend_Pdf_Element_Boolean(false));
} else if (strcasecmp($nextLexeme, 'null') == 0) {
return ($this->_elements[] = new Zend_Pdf_Element_Null());
}
$ref = $this->_readReference($nextLexeme);
if ($ref !== null) {
return ($this->_elements[] = $ref);
}
return ($this->_elements[] = $this->_readNumeric($nextLexeme));
}
}
/**
* Read string PDF object
* Also reads trailing ')' from a pdf stream
*
* @return Zend_Pdf_Element_String
* @throws Zend_Pdf_Exception
*/
private function _readString()
{
$start = $this->offset;
$openedBrackets = 1;
while ($this->offset < strlen($this->data)) {
switch (ord( $this->data[$this->offset] )) {
case 0x28: // '(' - opened bracket in the string, needs balanced pair.
$openedBrackets++;
break;
case 0x29: // ')' - pair to the opened bracket
$openedBrackets--;
break;
case 0x5C: // '\\' - escape sequence, skip next char from a check
$this->offset++;
}
$this->offset++;
if ($openedBrackets == 0) {
break; // end of string
}
}
if ($openedBrackets != 0) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected end of file while string reading. Offset - 0x%X. \')\' expected.', $start));
}
return new Zend_Pdf_Element_String(Zend_Pdf_Element_String::unescape( substr($this->data,
$start,
$this->offset - $start - 1) ));
}
/**
* Read binary string PDF object
* Also reads trailing '>' from a pdf stream
*
* @return Zend_Pdf_Element_String_Binary
* @throws Zend_Pdf_Exception
*/
private function _readBinaryString()
{
$start = $this->offset;
while ($this->offset < strlen($this->data)) {
if (self::isWhiteSpace( ord($this->data[$this->offset]) ) ||
ctype_xdigit( $this->data[$this->offset] ) ) {
$this->offset++;
} else if ($this->data[$this->offset] == '>') {
$this->offset++;
return new Zend_Pdf_Element_String_Binary(
Zend_Pdf_Element_String_Binary::unescape( substr($this->data,
$start,
$this->offset - $start - 1) ));
} else {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected character while binary string reading. Offset - 0x%X.', $this->offset));
}
}
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected end of file while binary string reading. Offset - 0x%X. \'>\' expected.', $start));
}
/**
* Read array PDF object
* Also reads trailing ']' from a pdf stream
*
* @return Zend_Pdf_Element_Array
* @throws Zend_Pdf_Exception
*/
private function _readArray()
{
$elements = array();
while ( strlen($nextLexeme = $this->readLexeme()) != 0 ) {
if ($nextLexeme != ']') {
$elements[] = $this->readElement($nextLexeme);
} else {
return new Zend_Pdf_Element_Array($elements);
}
}
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected end of file while array reading. Offset - 0x%X. \']\' expected.', $this->offset));
}
/**
* Read dictionary PDF object
* Also reads trailing '>>' from a pdf stream
*
* @return Zend_Pdf_Element_Dictionary
* @throws Zend_Pdf_Exception
*/
private function _readDictionary()
{
$dictionary = new Zend_Pdf_Element_Dictionary();
while ( strlen($nextLexeme = $this->readLexeme()) != 0 ) {
if ($nextLexeme != '>>') {
$nameStart = $this->offset - strlen($nextLexeme);
$name = $this->readElement($nextLexeme);
$value = $this->readElement();
if (!$name instanceof Zend_Pdf_Element_Name) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Name object expected while dictionary reading. Offset - 0x%X.', $nameStart));
}
$dictionary->add($name, $value);
} else {
return $dictionary;
}
}
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Unexpected end of file while dictionary reading. Offset - 0x%X. \'>>\' expected.', $this->offset));
}
/**
* Read reference PDF object
*
* @param string $nextLexeme
* @return Zend_Pdf_Element_Reference
*/
private function _readReference($nextLexeme = null)
{
$start = $this->offset;
if ($nextLexeme === null) {
$objNum = $this->readLexeme();
} else {
$objNum = $nextLexeme;
}
if (!ctype_digit($objNum)) { // it's not a reference
$this->offset = $start;
return null;
}
$genNum = $this->readLexeme();
if (!ctype_digit($genNum)) { // it's not a reference
$this->offset = $start;
return null;
}
$rMark = $this->readLexeme();
if ($rMark != 'R') { // it's not a reference
$this->offset = $start;
return null;
}
$ref = new Zend_Pdf_Element_Reference((int)$objNum, (int)$genNum, $this->_context, $this->_objFactory->resolve());
return $ref;
}
/**
* Read numeric PDF object
*
* @param string $nextLexeme
* @return Zend_Pdf_Element_Numeric
*/
private function _readNumeric($nextLexeme = null)
{
if ($nextLexeme === null) {
$nextLexeme = $this->readLexeme();
}
return new Zend_Pdf_Element_Numeric($nextLexeme);
}
/**
* Read inderect object from a PDF stream
*
* @param integer $offset
* @param Zend_Pdf_Element_Reference_Context $context
* @return Zend_Pdf_Element_Object
*/
public function getObject($offset, Zend_Pdf_Element_Reference_Context $context)
{
if ($offset === null ) {
return new Zend_Pdf_Element_Null();
}
// Save current offset to make getObject() reentrant
$offsetSave = $this->offset;
$this->offset = $offset;
$this->_context = $context;
$this->_elements = array();
$objNum = $this->readLexeme();
if (!ctype_digit($objNum)) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Object number expected.', $this->offset - strlen($objNum)));
}
$genNum = $this->readLexeme();
if (!ctype_digit($genNum)) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Object generation number expected.', $this->offset - strlen($genNum)));
}
$objKeyword = $this->readLexeme();
if ($objKeyword != 'obj') {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'obj\' keyword expected.', $this->offset - strlen($objKeyword)));
}
$objValue = $this->readElement();
$nextLexeme = $this->readLexeme();
if( $nextLexeme == 'endobj' ) {
/**
* Object is not generated by factory (thus it's not marked as modified object).
* But factory is assigned to the obect.
*/
$obj = new Zend_Pdf_Element_Object($objValue, (int)$objNum, (int)$genNum, $this->_objFactory->resolve());
foreach ($this->_elements as $element) {
$element->setParentObject($obj);
}
// Restore offset value
$this->offset = $offsetSave;
return $obj;
}
/**
* It's a stream object
*/
if ($nextLexeme != 'stream') {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'endobj\' or \'stream\' keywords expected.', $this->offset - strlen($nextLexeme)));
}
if (!$objValue instanceof Zend_Pdf_Element_Dictionary) {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. Stream extent must be preceded by stream dictionary.', $this->offset - strlen($nextLexeme)));
}
/**
* References are automatically dereferenced at this moment.
*/
$streamLength = $objValue->Length->value;
/**
* 'stream' keyword must be followed by either cr-lf sequence or lf character only.
* This restriction gives the possibility to recognize all cases exactly
*/
if ($this->data[$this->offset] == "\r" &&
$this->data[$this->offset + 1] == "\n" ) {
$this->offset += 2;
} else if ($this->data[$this->offset] == "\n" ) {
$this->offset++;
} else {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'stream\' must be followed by either cr-lf sequence or lf character only.', $this->offset - strlen($nextLexeme)));
}
$dataOffset = $this->offset;
$this->offset += $streamLength;
$nextLexeme = $this->readLexeme();
if ($nextLexeme != 'endstream') {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'endstream\' keyword expected.', $this->offset - strlen($nextLexeme)));
}
$nextLexeme = $this->readLexeme();
if ($nextLexeme != 'endobj') {
throw new Zend_Pdf_Exception(sprintf('PDF file syntax error. Offset - 0x%X. \'endobj\' keyword expected.', $this->offset - strlen($nextLexeme)));
}
$obj = new Zend_Pdf_Element_Object_Stream(substr($this->data,
$dataOffset,
$streamLength),
(int)$objNum,
(int)$genNum,
$this->_objFactory->resolve(),
$objValue);
foreach ($this->_elements as $element) {
$element->setParentObject($obj);
}
// Restore offset value
$this->offset = $offsetSave;
return $obj;
}
/**
* Get length of source string
*
* @return integer
*/
public function getLength()
{
return strlen($this->data);
}
/**
* Get source string
*
* @return string
*/
public function getString()
{
return $this->data;
}
/**
* Parse integer value from a binary stream
*
* @param string $stream
* @param integer $offset
* @param integer $size
* @return integer
*/
public static function parseIntFromStream($stream, $offset, $size)
{
$value = 0;
for ($count = 0; $count < $size; $count++) {
$value *= 256;
$value += ord($stream[$offset + $count]);
}
return $value;
}
/**
* Set current context
*
* @param Zend_Pdf_Element_Reference_Context $context
*/
public function setContext(Zend_Pdf_Element_Reference_Context $context)
{
$this->_context = $context;
}
/**
* Object constructor
*
* Note: PHP duplicates string, which is sent by value, only of it's updated.
* Thus we don't need to care about overhead
*
* @param string $pdfString
* @param Zend_Pdf_ElementFactory_Interface $factory
*/
public function __construct($source, Zend_Pdf_ElementFactory_Interface $factory)
{
$this->data = $source;
$this->_objFactory = $factory;
}
}

302
libs/Zend/Pdf/Style.php Normal file
View File

@ -0,0 +1,302 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** Zend_Pdf_Element_Array */
require_once 'Zend/Pdf/Element/Array.php';
/** Zend_Pdf_Resource_Font */
require_once 'Zend/Pdf/Resource/Font.php';
/**
* Style object.
* Style object doesn't directly correspond to any PDF file object.
* It's utility class, used as a container for style information.
* It's used by Zend_Pdf_Page class in draw operations.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Style
{
/**
* Fill color.
* Used to fill geometric shapes or text.
*
* @var Zend_Pdf_Color|null
*/
private $_fillColor = null;
/**
* Line color.
* Current color, used for lines and font outlines.
*
* @var Zend_Pdf_Color|null
*/
private $_color;
/**
* Line width.
*
* @var Zend_Pdf_Element_Numeric
*/
private $_lineWidth;
/**
* Array which describes line dashing pattern.
* It's array of numeric:
* array($on_length, $off_length, $on_length, $off_length, ...)
*
* @var array
*/
private $_lineDashingPattern;
/**
* Line dashing phase
*
* @var float
*/
private $_lineDashingPhase;
/**
* Current font
*
* @var Zend_Pdf_Resource_Font
*/
private $_font;
/**
* Font size
*
* @var float
*/
private $_fontSize;
/**
* Create style.
*
* @param Zend_Pdf_Style $anotherStyle
*/
public function __construct($anotherStyle = null)
{
if ($anotherStyle !== null) {
$this->_fillColor = $anotherStyle->_fillColor;
$this->_color = $anotherStyle->_color;
$this->_lineWidth = $anotherStyle->_lineWidth;
$this->_lineDashingPattern = $anotherStyle->_lineDashingPattern;
$this->_lineDashingPhase = $anotherStyle->_lineDashingPhase;
$this->_font = $anotherStyle->_font;
$this->_fontSize = $anotherStyle->_fontSize;
}
}
/**
* Set fill color.
*
* @param Zend_Pdf_Color $color
*/
public function setFillColor(Zend_Pdf_Color $color)
{
$this->_fillColor = $color;
}
/**
* Set line color.
*
* @param Zend_Pdf_Color $color
*/
public function setLineColor(Zend_Pdf_Color $color)
{
$this->_color = $color;
}
/**
* Set line width.
*
* @param float $width
*/
public function setLineWidth($width)
{
$this->_lineWidth = new Zend_Pdf_Element_Numeric($width);
}
/**
* Set line dashing pattern
*
* @param array $pattern
* @param float $phase
*/
public function setLineDashingPattern($pattern, $phase = 0)
{
if ($pattern === Zend_Pdf_Page::LINE_DASHING_SOLID) {
$pattern = array();
$phase = 0;
}
$this->_lineDashingPattern = $pattern;
$this->_lineDashingPhase = new Zend_Pdf_Element_Numeric($phase);
}
/**
* Set current font.
*
* @param Zend_Pdf_Resource_Font $font
* @param float $fontSize
*/
public function setFont(Zend_Pdf_Resource_Font $font, $fontSize)
{
$this->_font = $font;
$this->_fontSize = $fontSize;
}
/**
* Modify current font size
*
* @param float $fontSize
*/
public function setFontSize($fontSize)
{
$this->_fontSize = $fontSize;
}
/**
* Get fill color.
*
* @return Zend_Pdf_Color|null
*/
public function getFillColor()
{
return $this->_fillColor;
}
/**
* Get line color.
*
* @return Zend_Pdf_Color|null
*/
public function getLineColor()
{
return $this->_color;
}
/**
* Get line width.
*
* @return float
*/
public function getLineWidth()
{
$this->_lineWidth->value;
}
/**
* Get line dashing pattern
*
* @return array
*/
public function getLineDashingPattern()
{
return $this->_lineDashingPattern;
}
/**
* Get current font.
*
* @return Zend_Pdf_Resource_Font $font
*/
public function getFont()
{
return $this->_font;
}
/**
* Get current font size
*
* @return float $fontSize
*/
public function getFontSize()
{
return $this->_fontSize;
}
/**
* Get line dashing phase
*
* @return float
*/
public function getLineDashingPhase()
{
return $this->_lineDashingPhase->value;
}
/**
* Dump style to a string, which can be directly inserted into content stream
*
* @return string
*/
public function instructions()
{
$instructions = '';
if ($this->_fillColor !== null) {
$instructions .= $this->_fillColor->instructions(false);
}
if ($this->_color !== null) {
$instructions .= $this->_color->instructions(true);
}
if ($this->_lineWidth !== null) {
$instructions .= $this->_lineWidth->toString() . " w\n";
}
if ($this->_lineDashingPattern !== null) {
$dashPattern = new Zend_Pdf_Element_Array();
foreach ($this->_lineDashingPattern as $dashItem) {
$dashElement = new Zend_Pdf_Element_Numeric($dashItem);
$dashPattern->items[] = $dashElement;
}
$instructions .= $dashPattern->toString() . ' '
. $this->_lineDashingPhase->toString() . " d\n";
}
return $instructions;
}
}

127
libs/Zend/Pdf/Trailer.php Normal file
View File

@ -0,0 +1,127 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element_Dictionary */
require_once 'Zend/Pdf/Element/Dictionary.php';
/**
* PDF file trailer
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class Zend_Pdf_Trailer
{
private static $_allowedKeys = array('Size', 'Prev', 'Root', 'Encrypt', 'Info', 'ID', 'Index', 'W', 'XRefStm', 'DocChecksum');
/**
* Trailer dictionary.
*
* @var Zend_Pdf_Element_Dictionary
*/
private $_dict;
/**
* Check if key is correct
*
* @param string $key
* @throws Zend_Pdf_Exception
*/
private function _checkDictKey($key)
{
if ( !in_array($key, self::$_allowedKeys) ) {
/** @todo Make warning (log entry) instead of an exception */
throw new Zend_Pdf_Exception("Unknown trailer dictionary key: '$key'.");
}
}
/**
* Object constructor
*
* @param Zend_Pdf_Element_Dictionary $dict
*/
public function __construct(Zend_Pdf_Element_Dictionary $dict)
{
$this->_dict = $dict;
foreach ($this->_dict->getKeys() as $dictKey) {
$this->_checkDictKey($dictKey);
}
}
/**
* Get handler
*
* @param string $property
* @return mixed
*/
public function __get($property)
{
return $this->_dict->$property;
}
/**
* Set handler
*
* @param string $property
* @param mixed $value
*/
public function __set($property, $value)
{
$this->_checkDictKey($property);
$this->_dict->$property = $value;
}
/**
* Return string trailer representation
*
* @return string
*/
public function toString()
{
return "trailer\n" . $this->_dict->toString() . "\n";
}
/**
* Get length of source PDF
*
* @return string
*/
abstract public function getPDFLength();
/**
* Get PDF String
*
* @return string
*/
abstract public function getPDFString();
/**
* Get header of free objects list
* Returns object number of last free object
*
* @return integer
*/
abstract public function getLastFreeObject();
}

View File

@ -0,0 +1,74 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Trailer */
require_once 'Zend/Pdf/Trailer.php';
/**
* PDF file trailer generator (used for just created PDF)
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Trailer_Generator extends Zend_Pdf_Trailer
{
/**
* Object constructor
*
* @param Zend_Pdf_Element_Dictionary $dict
*/
public function __construct(Zend_Pdf_Element_Dictionary $dict)
{
parent::__construct($dict);
}
/**
* Get length of source PDF
*
* @return string
*/
public function getPDFLength()
{
return strlen(Zend_Pdf::PDF_HEADER);
}
/**
* Get PDF String
*
* @return string
*/
public function getPDFString()
{
return Zend_Pdf::PDF_HEADER;
}
/**
* Get header of free objects list
* Returns object number of last free object
*
* @return integer
*/
public function getLastFreeObject()
{
return 0;
}
}

View File

@ -0,0 +1,145 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Trailer */
require_once 'Zend/Pdf/Trailer.php';
/** Zend_Pdf_Element_Reference_Context */
require_once 'Zend/Pdf/Element/Reference/Context.php';
/**
* PDF file trailer.
* Stores and provides access to the trailer parced from a PDF file
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_Trailer_Keeper extends Zend_Pdf_Trailer
{
/**
* Reference context
*
* @var Zend_Pdf_Element_Reference_Context
*/
private $_context;
/**
* Previous trailer
*
* @var Zend_Pdf_Trailer
*/
private $_prev;
/**
* Object constructor
*
* @param Zend_Pdf_Element_Dictionary $dict
* @param Zend_Pdf_Element_Reference_Context $context
* @param Zend_Pdf_Trailer $prev
*/
public function __construct(Zend_Pdf_Element_Dictionary $dict,
Zend_Pdf_Element_Reference_Context $context,
$prev = null)
{
parent::__construct($dict);
$this->_context = $context;
$this->_prev = $prev;
}
/**
* Setter for $this->_prev
*
* @param Zend_Pdf_Trailer_Keeper $prev
*/
public function setPrev(Zend_Pdf_Trailer_Keeper $prev)
{
$this->_prev = $prev;
}
/**
* Getter for $this->_prev
*
* @return Zend_Pdf_Trailer
*/
public function getPrev()
{
return $this->_prev;
}
/**
* Get length of source PDF
*
* @return string
*/
public function getPDFLength()
{
return $this->_context->getParser()->getLength();
}
/**
* Get PDF String
*
* @return string
*/
public function getPDFString()
{
return $this->_context->getParser()->getString();
}
/**
* Get reference table, which corresponds to the trailer.
* Proxy to the $_context member methad call
*
* @return Zend_Pdf_Element_Reference_Context
*/
public function getRefTable()
{
return $this->_context->getRefTable();
}
/**
* Get header of free objects list
* Returns object number of last free object
*
* @throws Zend_Pdf_Exception
* @return integer
*/
public function getLastFreeObject()
{
try {
$this->_context->getRefTable()->getNextFree('0 65535 R');
} catch (Zend_Pdf_Exception $e) {
if ($e->getMessage() == 'Object not found.') {
/**
* Here is work around for some wrong generated PDFs.
* We have not found reference to the header of free object list,
* thus we treat it as there are no free objects.
*/
return 0;
}
throw $e;
}
}
}

View File

@ -0,0 +1,137 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/** Zend_Pdf_Element */
require_once 'Zend/Pdf/Element.php';
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Memory */
require_once 'Zend/Memory.php';
/**
* Container which collects updated object info.
*
* @package Zend_Pdf
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Pdf_UpdateInfoContainer
{
/**
* Object number
*
* @var integer
*/
private $_objNum;
/**
* Generation number
*
* @var integer
*/
private $_genNum;
/**
* Flag, which signals, that object is free
*
* @var boolean
*/
private $_isFree;
/**
* String representation of the object
*
* @var Zend_Memory_Container|null
*/
private $_dump = null;
/**
* Object constructor
*
* @param integer $objCount
*/
public function __construct($objNum, $genNum, $isFree, $dump = null)
{
$this->_objNum = $objNum;
$this->_genNum = $genNum;
$this->_isFree = $isFree;
if ($dump !== null) {
if (strlen($dump) > 1024) {
$this->_dump = Zend_Pdf::getMemoryManager()->create($dump);
} else {
$this->_dump = $dump;
}
}
}
/**
* Get object number
*
* @return integer
*/
public function getObjNum()
{
return $this->_objNum;
}
/**
* Get generation number
*
* @return integer
*/
public function getGenNum()
{
return $this->_genNum;
}
/**
* Check, that object is free
*
* @return boolean
*/
public function isFree()
{
return $this->_isFree;
}
/**
* Get string representation of the object
*
* @return string
*/
public function getObjectDump()
{
if ($this->_dump === null) {
return '';
}
if (is_string($this->_dump)) {
return $this->_dump;
}
return $this->_dump->getRef();
}
}