import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -18,9 +18,6 @@
|
||||
* @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';
|
||||
|
||||
@ -33,7 +30,6 @@ 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.
|
||||
@ -165,6 +161,7 @@ abstract class Zend_Pdf_Cmap
|
||||
return new Zend_Pdf_Cmap_ByteEncoding_Static($cmapData);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_HIGH_BYTE_MAPPING:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('High byte mapping cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
@ -175,18 +172,22 @@ abstract class Zend_Pdf_Cmap
|
||||
return new Zend_Pdf_Cmap_TrimmedTable($cmapData);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_MIXED_COVERAGE:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Mixed coverage cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_TRIMMED_ARRAY:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Trimmed array cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
case Zend_Pdf_Cmap::TYPE_SEGMENTED_COVERAGE:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Segmented coverage cmap currently unsupported',
|
||||
Zend_Pdf_Exception::CMAP_TYPE_UNSUPPORTED);
|
||||
|
||||
default:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Unknown cmap type: $cmapType",
|
||||
Zend_Pdf_Exception::CMAP_UNKNOWN_TYPE);
|
||||
}
|
||||
@ -244,9 +245,9 @@ abstract class Zend_Pdf_Cmap
|
||||
/**
|
||||
* 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
|
||||
* call, but this method do it in more effective way (prepare complete list instead of searching
|
||||
* glyph for each character code).
|
||||
*
|
||||
* @internal
|
||||
@ -274,6 +275,7 @@ abstract class Zend_Pdf_Cmap
|
||||
protected function _extractInt2(&$data, $index)
|
||||
{
|
||||
if (($index < 0) | (($index + 1) > strlen($data))) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Index out of range: $index",
|
||||
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
|
||||
}
|
||||
@ -300,6 +302,7 @@ abstract class Zend_Pdf_Cmap
|
||||
protected function _extractUInt2(&$data, $index)
|
||||
{
|
||||
if (($index < 0) | (($index + 1) > strlen($data))) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Index out of range: $index",
|
||||
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
|
||||
}
|
||||
@ -326,6 +329,7 @@ abstract class Zend_Pdf_Cmap
|
||||
protected function _extractUInt4(&$data, $index)
|
||||
{
|
||||
if (($index < 0) | (($index + 3) > strlen($data))) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Index out of range: $index",
|
||||
Zend_Pdf_Exception::INDEX_OUT_OF_RANGE);
|
||||
}
|
||||
|
@ -18,17 +18,12 @@
|
||||
* @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
|
||||
*
|
||||
|
@ -18,17 +18,12 @@
|
||||
* @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
|
||||
*
|
||||
|
@ -18,10 +18,6 @@
|
||||
* @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';
|
||||
|
||||
@ -31,7 +27,6 @@ require_once 'Zend/Pdf/Color/Rgb.php';
|
||||
/** Zend_Pdf_GrayScale */
|
||||
require_once 'Zend/Pdf/Color/GrayScale.php';
|
||||
|
||||
|
||||
/**
|
||||
* HTML color implementation
|
||||
*
|
||||
@ -395,6 +390,7 @@ class Zend_Pdf_Color_Html extends Zend_Pdf_Color
|
||||
$r = 0.604; $g = 0.804; $b = 0.196; break;
|
||||
|
||||
default:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Unknown color name: ' . $color);
|
||||
}
|
||||
if (($r == $g) && ($g == $b)) {
|
||||
|
@ -18,17 +18,12 @@
|
||||
* @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
|
||||
*
|
||||
|
@ -18,10 +18,6 @@
|
||||
* @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.
|
||||
*
|
||||
@ -115,6 +111,7 @@ abstract class Zend_Pdf_FileParser
|
||||
public function __construct(Zend_Pdf_FileParserDataSource $dataSource)
|
||||
{
|
||||
if ($dataSource->getSize() == 0) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('The data source has not been properly initialized',
|
||||
Zend_Pdf_Exception::BAD_DATA_SOURCE);
|
||||
}
|
||||
@ -229,6 +226,7 @@ abstract class Zend_Pdf_FileParser
|
||||
public function readInt($size, $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN)
|
||||
{
|
||||
if (($size < 1) || ($size > 4)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Invalid signed integer size: $size",
|
||||
Zend_Pdf_Exception::INVALID_INTEGER_SIZE);
|
||||
}
|
||||
@ -274,6 +272,7 @@ abstract class Zend_Pdf_FileParser
|
||||
}
|
||||
}
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Invalid byte order: $byteOrder",
|
||||
Zend_Pdf_Exception::INVALID_BYTE_ORDER);
|
||||
}
|
||||
@ -302,6 +301,7 @@ abstract class Zend_Pdf_FileParser
|
||||
public function readUInt($size, $byteOrder = Zend_Pdf_FileParser::BYTE_ORDER_BIG_ENDIAN)
|
||||
{
|
||||
if (($size < 1) || ($size > 4)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Invalid unsigned integer size: $size",
|
||||
Zend_Pdf_Exception::INVALID_INTEGER_SIZE);
|
||||
}
|
||||
@ -320,6 +320,7 @@ abstract class Zend_Pdf_FileParser
|
||||
$number |= ord($bytes[$i]) << ($i * 8);
|
||||
}
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Invalid byte order: $byteOrder",
|
||||
Zend_Pdf_Exception::INVALID_BYTE_ORDER);
|
||||
}
|
||||
@ -362,6 +363,7 @@ abstract class Zend_Pdf_FileParser
|
||||
{
|
||||
$bitsToRead = $mantissaBits + $fractionBits;
|
||||
if (($bitsToRead % 8) !== 0) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Fixed-point numbers are whole bytes',
|
||||
Zend_Pdf_Exception::BAD_FIXED_POINT_SIZE);
|
||||
}
|
||||
@ -413,6 +415,7 @@ abstract class Zend_Pdf_FileParser
|
||||
}
|
||||
return iconv('UTF-16LE', $characterSet, $bytes);
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Invalid byte order: $byteOrder",
|
||||
Zend_Pdf_Exception::INVALID_BYTE_ORDER);
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ abstract class Zend_Pdf_FileParser_Font extends Zend_Pdf_FileParser
|
||||
*/
|
||||
public function __set($property, $value)
|
||||
{
|
||||
if (is_null($value)) {
|
||||
if ($value === null) {
|
||||
unset($this->_fontProperties[$property]);
|
||||
} else {
|
||||
$this->_fontProperties[$property] = $value;
|
||||
@ -203,7 +203,9 @@ abstract class Zend_Pdf_FileParser_Font extends Zend_Pdf_FileParser
|
||||
$message = array_shift($args);
|
||||
$message = vsprintf($message, $args);
|
||||
}
|
||||
Zend_Log::log($message, Zend_Log::LEVEL_DEBUG, 'ZF');
|
||||
|
||||
$logger = new Zend_Log();
|
||||
$logger->log($message, Zend_Log::DEBUG);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ abstract class Zend_Pdf_FileParser_Font_OpenType extends Zend_Pdf_FileParser_Fon
|
||||
$nameOffset = $this->readUInt(2);
|
||||
|
||||
$languageCode = $this->_languageCodeForPlatform($platformID, $languageID);
|
||||
if (is_null($languageCode)) {
|
||||
if ($languageCode === null) {
|
||||
$this->_debugLog('Skipping languageID: 0x%x; platformID %d', $languageID, $platformID);
|
||||
continue; // Not a supported language. Move on.
|
||||
}
|
||||
@ -471,7 +471,7 @@ abstract class Zend_Pdf_FileParser_Font_OpenType extends Zend_Pdf_FileParser_Fon
|
||||
*/
|
||||
$this->numGlyphs = $this->readUInt(2);
|
||||
$this->_debugLog('number of glyphs: %d', $this->numGlyphs);
|
||||
|
||||
|
||||
// Skip other maxp table entries (if presented with table version 1.0)...
|
||||
}
|
||||
|
||||
@ -646,10 +646,10 @@ abstract class Zend_Pdf_FileParser_Font_OpenType extends Zend_Pdf_FileParser_Fon
|
||||
* even any of the extended latin characters, it is considered symbolic
|
||||
* to PDF and must be described differently in the Font Descriptor.
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* @todo Font is recognized as Adobe Latin subset font if it only contains
|
||||
* Basic Latin characters (only bit 0 of Unicode range bits is set).
|
||||
* Actually, other Unicode subranges like General Punctuation (bit 31) also
|
||||
* Actually, other Unicode subranges like General Punctuation (bit 31) also
|
||||
* fall into Adobe Latin characters. So this code has to be modified.
|
||||
*/
|
||||
$this->isAdobeLatinSubset = (($unicodeRange1 == 1) && ($unicodeRange2 == 0) &&
|
||||
|
@ -18,13 +18,11 @@
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_Pdf_FileParser */
|
||||
/**
|
||||
* @see Zend_Pdf_FileParser
|
||||
*/
|
||||
require_once 'Zend/Pdf/FileParser.php';
|
||||
|
||||
/** Zend_Log */
|
||||
require_once 'Zend/Log.php';
|
||||
|
||||
|
||||
/**
|
||||
* FileParser for Zend_Pdf_Image subclasses.
|
||||
*
|
||||
@ -35,6 +33,11 @@ require_once 'Zend/Log.php';
|
||||
*/
|
||||
abstract class Zend_Pdf_FileParser_Image extends Zend_Pdf_FileParser
|
||||
{
|
||||
/**
|
||||
* Image Type
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $imageType;
|
||||
|
||||
/**
|
||||
@ -48,9 +51,7 @@ abstract class Zend_Pdf_FileParser_Image extends Zend_Pdf_FileParser
|
||||
public function __construct(Zend_Pdf_FileParserDataSource $dataSource)
|
||||
{
|
||||
parent::__construct($dataSource);
|
||||
$this->imageType = Zend_Pdf_Image::TYPE_UNKNOWN;
|
||||
$this->imageType = Zend_Pdf_Image::TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -18,10 +18,6 @@
|
||||
* @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.
|
||||
@ -176,10 +172,12 @@ abstract class Zend_Pdf_FileParserDataSource
|
||||
return; // Not moving; do nothing.
|
||||
}
|
||||
if ($offset < 0) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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.
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Attempt to move beyond end of data source',
|
||||
Zend_Pdf_Exception::MOVE_BEYOND_END_OF_FILE);
|
||||
}
|
||||
@ -201,5 +199,4 @@ abstract class Zend_Pdf_FileParserDataSource
|
||||
{
|
||||
$this->moveToOffset($this->_offset + $byteCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,11 +17,6 @@
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Exception */
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
|
||||
|
||||
/**
|
||||
* PDF stream filter
|
||||
*
|
||||
|
@ -131,7 +131,7 @@ abstract class Zend_Pdf_Font
|
||||
* 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
|
||||
@ -143,7 +143,7 @@ abstract class Zend_Pdf_Font
|
||||
* 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 */
|
||||
|
||||
@ -672,7 +672,7 @@ abstract class Zend_Pdf_Font
|
||||
}
|
||||
|
||||
|
||||
if (is_null($font)) {
|
||||
if ($font === null) {
|
||||
/* 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
|
||||
@ -682,7 +682,7 @@ abstract class Zend_Pdf_Font
|
||||
// OpenType
|
||||
|
||||
// TrueType
|
||||
if ((is_null($font)) && ($fileExtension != 'ttf')) {
|
||||
if (($font === null) && ($fileExtension != 'ttf')) {
|
||||
$font = Zend_Pdf_Font::_extractTrueTypeFont($dataSource, $embeddingOptions);
|
||||
}
|
||||
|
||||
@ -698,7 +698,7 @@ abstract class Zend_Pdf_Font
|
||||
*/
|
||||
$dataSource = null;
|
||||
|
||||
if (! is_null($font)) {
|
||||
if ($font !== null) {
|
||||
/* Parsing was successful. Add this font instance to the cache arrays
|
||||
* and return it for use.
|
||||
*/
|
||||
@ -743,7 +743,7 @@ abstract class Zend_Pdf_Font
|
||||
{
|
||||
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);
|
||||
|
@ -169,7 +169,7 @@ abstract class Zend_Pdf_Image
|
||||
*/
|
||||
$dataSource = null;
|
||||
|
||||
if (! is_null($image)) {
|
||||
if ($image !== null) {
|
||||
return $image;
|
||||
|
||||
} else {
|
||||
|
@ -17,10 +17,6 @@
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
||||
/** Zend_Pdf_Exception */
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
|
||||
/** Zend_Pdf_Resource_Font */
|
||||
require_once 'Zend/Pdf/Resource/Font.php';
|
||||
|
||||
@ -308,6 +304,7 @@ class Zend_Pdf_Page
|
||||
* @todo support of user defined pagesize notations, like:
|
||||
* "210x297mm", "595x842", "8.5x11in", "612x792"
|
||||
*/
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Wrong pagesize notation.');
|
||||
}
|
||||
/**
|
||||
@ -323,6 +320,7 @@ class Zend_Pdf_Page
|
||||
$pageHeight = $param2;
|
||||
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Unrecognized method signature, wrong number of arguments or wrong argument types.');
|
||||
}
|
||||
|
||||
@ -346,6 +344,7 @@ class Zend_Pdf_Page
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Cloning Zend_Pdf_Page object using \'clone\' keyword is not supported. Use \'new Zend_Pdf_Page($srcPage)\' syntax');
|
||||
}
|
||||
|
||||
@ -430,6 +429,7 @@ class Zend_Pdf_Page
|
||||
public function flush()
|
||||
{
|
||||
if ($this->_saveCount != 0) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Saved graphics state is not restored');
|
||||
}
|
||||
|
||||
@ -496,6 +496,7 @@ class Zend_Pdf_Page
|
||||
}
|
||||
|
||||
if ($this->_attached) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Page is attached to one documen, but rendered in context of another.');
|
||||
/**
|
||||
* @todo Page cloning must be implemented here instead of exception.
|
||||
@ -508,7 +509,6 @@ class Zend_Pdf_Page
|
||||
} else {
|
||||
$objFactory->attach($this->_objFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -517,34 +517,43 @@ class Zend_Pdf_Page
|
||||
* Set fill color.
|
||||
*
|
||||
* @param Zend_Pdf_Color $color
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setFillColor(Zend_Pdf_Color $color)
|
||||
{
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= $color->instructions(false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line color.
|
||||
*
|
||||
* @param Zend_Pdf_Color $color
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setLineColor(Zend_Pdf_Color $color)
|
||||
{
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= $color->instructions(true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line width.
|
||||
*
|
||||
* @param float $width
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setLineWidth($width)
|
||||
{
|
||||
$this->_addProcSet('PDF');
|
||||
$widthObj = new Zend_Pdf_Element_Numeric($width);
|
||||
$this->_contents .= $widthObj->toString() . " w\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -555,6 +564,7 @@ class Zend_Pdf_Page
|
||||
*
|
||||
* @param array $pattern
|
||||
* @param array $phase
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setLineDashingPattern($pattern, $phase = 0)
|
||||
{
|
||||
@ -575,6 +585,8 @@ class Zend_Pdf_Page
|
||||
|
||||
$this->_contents .= $dashPattern->toString() . ' '
|
||||
. $phaseEleemnt->toString() . " d\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -582,6 +594,7 @@ class Zend_Pdf_Page
|
||||
*
|
||||
* @param Zend_Pdf_Resource_Font $font
|
||||
* @param float $fontSize
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setFont(Zend_Pdf_Resource_Font $font, $fontSize)
|
||||
{
|
||||
@ -594,12 +607,15 @@ class Zend_Pdf_Page
|
||||
$fontNameObj = new Zend_Pdf_Element_Name($fontName);
|
||||
$fontSizeObj = new Zend_Pdf_Element_Numeric($fontSize);
|
||||
$this->_contents .= $fontNameObj->toString() . ' ' . $fontSizeObj->toString() . " Tf\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style to use for future drawing operations on this page
|
||||
*
|
||||
* @param Zend_Pdf_Style $style
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setStyle(Zend_Pdf_Style $style)
|
||||
{
|
||||
@ -611,6 +627,8 @@ class Zend_Pdf_Page
|
||||
$this->setFont($style->getFont(), $style->getFontSize());
|
||||
}
|
||||
$this->_contents .= $style->instructions($this->_pageDictionary->Resources);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -626,14 +644,17 @@ class Zend_Pdf_Page
|
||||
* @param float $alpha
|
||||
* @param string $mode
|
||||
* @throws Zend_Pdf_Exception
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function setAlpha($alpha, $mode = 'Normal')
|
||||
{
|
||||
if (!in_array($mode, array('Normal', 'Multiply', 'Screen', 'Overlay', 'Darken', 'Lighten', 'ColorDodge',
|
||||
'ColorBurn', 'HardLight', 'SoftLight', 'Difference', 'Exclusion'))) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Unsupported transparency mode.');
|
||||
}
|
||||
if (!is_numeric($alpha) || $alpha < 0 || $alpha > 1) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Alpha value must be numeric between 0 (transparent) and 1 (opaque).');
|
||||
}
|
||||
|
||||
@ -666,6 +687,8 @@ class Zend_Pdf_Page
|
||||
|
||||
$gStateNameObj = new Zend_Pdf_Element_Name($gStateName);
|
||||
$this->_contents .= $gStateNameObj->toString() . " gs\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -725,6 +748,7 @@ class Zend_Pdf_Page
|
||||
}
|
||||
|
||||
$fonts = array();
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
foreach ($fontResourcesUnique as $resourceReference => $fontDictionary) {
|
||||
try {
|
||||
// Try to extract font
|
||||
@ -757,6 +781,7 @@ class Zend_Pdf_Page
|
||||
|
||||
$fontResources = $this->_pageDictionary->Resources->Font;
|
||||
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
foreach ($fontResources->getKeys() as $fontResourceName) {
|
||||
$fontDictionary = $fontResources->$fontResourceName;
|
||||
|
||||
@ -813,6 +838,7 @@ class Zend_Pdf_Page
|
||||
*
|
||||
* @todo check for the open paths
|
||||
* @throws Zend_Pdf_Exception - if a save is performed with an open path
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function saveGS()
|
||||
{
|
||||
@ -820,19 +846,25 @@ class Zend_Pdf_Page
|
||||
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= " q\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the graphics state that was saved with the last call to saveGS().
|
||||
*
|
||||
* @throws Zend_Pdf_Exception - if there is no previously saved state
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function restoreGS()
|
||||
{
|
||||
if ($this->_saveCount-- <= 0) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Restoring graphics state which is not saved');
|
||||
}
|
||||
$this->_contents .= " Q\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -844,12 +876,15 @@ class Zend_Pdf_Page
|
||||
* @param float $radius
|
||||
* @param float $startAngle
|
||||
* @param float $endAngle
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function clipCircle($x, $y, $radius, $startAngle = null, $endAngle = null)
|
||||
{
|
||||
$this->clipEllipse($x - $radius, $y - $radius,
|
||||
$x + $radius, $y + $radius,
|
||||
$startAngle, $endAngle);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -867,6 +902,7 @@ class Zend_Pdf_Page
|
||||
* @param float $y2
|
||||
* @param float $startAngle
|
||||
* @param float $endAngle
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function clipEllipse($x1, $y1, $x2, $y2, $startAngle = null, $endAngle = null)
|
||||
{
|
||||
@ -938,6 +974,8 @@ class Zend_Pdf_Page
|
||||
. $xl->toString() . ' ' . $yUp->toString() . ' '
|
||||
. $xC->toString() . ' ' . $yUp->toString() . " c\n"
|
||||
. "h\nW\nn\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -947,6 +985,7 @@ class Zend_Pdf_Page
|
||||
* @param array $x - array of float (the X co-ordinates of the vertices)
|
||||
* @param array $y - array of float (the Y co-ordinates of the vertices)
|
||||
* @param integer $fillMethod
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function clipPolygon($x, $y, $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)
|
||||
{
|
||||
@ -968,11 +1007,13 @@ class Zend_Pdf_Page
|
||||
$this->_contents .= $path;
|
||||
|
||||
if ($fillMethod == Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) {
|
||||
$this->_contents .= " h\n W\n";
|
||||
$this->_contents .= " h\n W\nn\n";
|
||||
} else {
|
||||
// Even-Odd fill method.
|
||||
$this->_contents .= " h\n W*\n";
|
||||
$this->_contents .= " h\n W*\nn\n";
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -982,6 +1023,7 @@ class Zend_Pdf_Page
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function clipRectangle($x1, $y1, $x2, $y2)
|
||||
{
|
||||
@ -994,7 +1036,9 @@ class Zend_Pdf_Page
|
||||
|
||||
$this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . ' '
|
||||
. $widthObj->toString() . ' ' . $height2Obj->toString() . " re\n"
|
||||
. " W\n";
|
||||
. " W\nn\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1005,9 +1049,12 @@ class Zend_Pdf_Page
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawContentStream($cs, $x1, $y1, $x2, $y2)
|
||||
{
|
||||
/** @todo implementation */
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1032,12 +1079,15 @@ class Zend_Pdf_Page
|
||||
* @param mixed $param4
|
||||
* @param mixed $param5
|
||||
* @param mixed $param6
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null)
|
||||
{
|
||||
$this->drawEllipse($x - $radius, $y - $radius,
|
||||
$x + $radius, $y + $radius,
|
||||
$param4, $param5, $param6);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1058,6 +1108,7 @@ class Zend_Pdf_Page
|
||||
* @param mixed $param5
|
||||
* @param mixed $param6
|
||||
* @param mixed $param7
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawEllipse($x1, $y1, $x2, $y2, $param5 = null, $param6 = null, $param7 = null)
|
||||
{
|
||||
@ -1165,6 +1216,8 @@ class Zend_Pdf_Page
|
||||
if ($startAngle !== null) {
|
||||
$this->_contents .= "Q\n";
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1175,6 +1228,7 @@ class Zend_Pdf_Page
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2)
|
||||
{
|
||||
@ -1193,6 +1247,8 @@ class Zend_Pdf_Page
|
||||
. $widthObj->toString() . ' 0 0 ' . $heightObj->toString() . " 0 0 cm\n"
|
||||
. $imageNameObj->toString() . " Do\n"
|
||||
. "Q\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1201,9 +1257,12 @@ class Zend_Pdf_Page
|
||||
* @param Zend_Pdf_Element_LayoutBox $box
|
||||
* @param float $x
|
||||
* @param float $y
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawLayoutBox($box, $x, $y)
|
||||
{
|
||||
/** @todo implementation */
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1213,6 +1272,7 @@ class Zend_Pdf_Page
|
||||
* @param float $y1
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawLine($x1, $y1, $x2, $y2)
|
||||
{
|
||||
@ -1225,6 +1285,8 @@ class Zend_Pdf_Page
|
||||
|
||||
$this->_contents .= $x1Obj->toString() . ' ' . $y1Obj->toString() . " m\n"
|
||||
. $x2Obj->toString() . ' ' . $y2Obj->toString() . " l\n S\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1239,6 +1301,7 @@ class Zend_Pdf_Page
|
||||
* @param array $y - array of float (the Y co-ordinates of the vertices)
|
||||
* @param integer $fillType
|
||||
* @param integer $fillMethod
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawPolygon($x, $y,
|
||||
$fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,
|
||||
@ -1282,6 +1345,8 @@ class Zend_Pdf_Page
|
||||
$this->_contents .= " S\n";
|
||||
break;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1297,6 +1362,7 @@ class Zend_Pdf_Page
|
||||
* @param float $x2
|
||||
* @param float $y2
|
||||
* @param integer $fillType
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawRectangle($x1, $y1, $x2, $y2, $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)
|
||||
{
|
||||
@ -1321,6 +1387,8 @@ class Zend_Pdf_Page
|
||||
$this->_contents .= " S\n";
|
||||
break;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1332,10 +1400,12 @@ class Zend_Pdf_Page
|
||||
* @param string $charEncoding (optional) Character encoding of source text.
|
||||
* Defaults to current locale.
|
||||
* @throws Zend_Pdf_Exception
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function drawText($text, $x, $y, $charEncoding = '')
|
||||
{
|
||||
if ($this->_font === null) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Font has not been set');
|
||||
}
|
||||
|
||||
@ -1349,6 +1419,8 @@ class Zend_Pdf_Page
|
||||
. $xObj->toString() . ' ' . $yObj->toString() . " Td\n"
|
||||
. $textObj->toString() . " Tj\n"
|
||||
. "ET\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1377,9 +1449,12 @@ class Zend_Pdf_Page
|
||||
* Close the path by drawing a straight line back to it's beginning.
|
||||
*
|
||||
* @throws Zend_Pdf_Exception - if a path hasn't been started with pathMove()
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function pathClose()
|
||||
{
|
||||
/** @todo implementation */
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1387,9 +1462,12 @@ class Zend_Pdf_Page
|
||||
*
|
||||
* @param float $x - the X co-ordinate to move to
|
||||
* @param float $y - the Y co-ordinate to move to
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function pathLine($x, $y)
|
||||
{
|
||||
/** @todo implementation */
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1398,9 +1476,12 @@ class Zend_Pdf_Page
|
||||
*
|
||||
* @param float $x - the X co-ordinate to move to
|
||||
* @param float $y - the Y co-ordinate to move to
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function pathMove($x, $y)
|
||||
{
|
||||
/** @todo implementation */
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1411,6 +1492,7 @@ class Zend_Pdf_Page
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $procSet (optional) Name of ProcSet to add.
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function rawWrite($data, $procSet = null)
|
||||
{
|
||||
@ -1418,12 +1500,17 @@ class Zend_Pdf_Page
|
||||
$this->_addProcSet($procSet);
|
||||
}
|
||||
$this->_contents .= $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate the page.
|
||||
*
|
||||
* @param float $angle
|
||||
* @param float $x - the X co-ordinate of rotation point
|
||||
* @param float $y - the Y co-ordinate of rotation point
|
||||
* @param float $angle - rotation angle
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function rotate($x, $y, $angle)
|
||||
{
|
||||
@ -1440,11 +1527,74 @@ class Zend_Pdf_Page
|
||||
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= '1 0 0 1 ' . $xObj->toString() . ' ' . $yObj->toString() . " cm\n"
|
||||
. $cos->toString() . ' ' . $sin->toString()
|
||||
. ' ' . $mSin->toString() . ' ' . $cos->toString() . " 0 0 cm\n"
|
||||
.'1 0 0 1 ' . $mXObj->toString() . ' ' . $mYObj->toString() . " cm\n";
|
||||
. $cos->toString() . ' ' . $sin->toString() . ' ' . $mSin->toString() . ' ' . $cos->toString() . " 0 0 cm\n"
|
||||
. '1 0 0 1 ' . $mXObj->toString() . ' ' . $mYObj->toString() . " cm\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale coordination system.
|
||||
*
|
||||
* @param float $xScale - X dimention scale factor
|
||||
* @param float $yScale - Y dimention scale factor
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function scale($xScale, $yScale)
|
||||
{
|
||||
$xScaleObj = new Zend_Pdf_Element_Numeric($xScale);
|
||||
$yScaleObj = new Zend_Pdf_Element_Numeric($yScale);
|
||||
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= $xScaleObj->toString() . ' 0 0 ' . $yScaleObj->toString() . " 0 0 cm\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate coordination system.
|
||||
*
|
||||
* @param float $xShift - X coordinate shift
|
||||
* @param float $yShift - Y coordinate shift
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function translate($xShift, $yShift)
|
||||
{
|
||||
$xShiftObj = new Zend_Pdf_Element_Numeric($xShift);
|
||||
$yShiftObj = new Zend_Pdf_Element_Numeric($yShift);
|
||||
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= '1 0 0 1 ' . $xShiftObj->toString() . ' ' . $yShiftObj->toString() . " cm\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate coordination system.
|
||||
*
|
||||
* @param float $x - the X co-ordinate of axis skew point
|
||||
* @param float $y - the Y co-ordinate of axis skew point
|
||||
* @param float $xAngle - X axis skew angle
|
||||
* @param float $yAngle - Y axis skew angle
|
||||
* @return Zend_Pdf_Page
|
||||
*/
|
||||
public function skew($x, $y, $xAngle, $yAngle)
|
||||
{
|
||||
$tanXObj = new Zend_Pdf_Element_Numeric(tan($xAngle));
|
||||
$tanYObj = new Zend_Pdf_Element_Numeric(-tan($yAngle));
|
||||
|
||||
$xObj = new Zend_Pdf_Element_Numeric($x);
|
||||
$yObj = new Zend_Pdf_Element_Numeric($y);
|
||||
|
||||
$mXObj = new Zend_Pdf_Element_Numeric(-$x);
|
||||
$mYObj = new Zend_Pdf_Element_Numeric(-$y);
|
||||
|
||||
$this->_addProcSet('PDF');
|
||||
$this->_contents .= '1 0 0 1 ' . $xObj->toString() . ' ' . $yObj->toString() . " cm\n"
|
||||
. '1 ' . $tanXObj->toString() . ' ' . $tanYObj->toString() . " 1 0 0 cm\n"
|
||||
. '1 0 0 1 ' . $mXObj->toString() . ' ' . $mYObj->toString() . " cm\n";
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,6 @@
|
||||
/** Zend_Pdf_Resource */
|
||||
require_once 'Zend/Pdf/Resource.php';
|
||||
|
||||
/** Zend_Pdf_Exception */
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
|
||||
|
||||
/**
|
||||
* Abstract class which manages PDF fonts.
|
||||
*
|
||||
@ -235,13 +231,13 @@ abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource
|
||||
}
|
||||
/* If the preferred language could not be found, use whatever is first.
|
||||
*/
|
||||
if (is_null($name)) {
|
||||
if ($name === null) {
|
||||
$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
|
||||
if (($characterSet !== null) && ($characterSet != 'UTF-16BE') && PHP_OS != 'AIX') { // AIX knows not this charset
|
||||
$name = iconv('UTF-16BE', $characterSet, $name);
|
||||
}
|
||||
return $name;
|
||||
@ -249,14 +245,14 @@ abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource
|
||||
|
||||
/**
|
||||
* Returns whole set of font names.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFontNames()
|
||||
{
|
||||
return $this->_fontNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if font is bold.
|
||||
*
|
||||
@ -276,7 +272,7 @@ abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource
|
||||
{
|
||||
return $this->_isItalic;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if font is monospace.
|
||||
*
|
||||
@ -481,8 +477,8 @@ abstract class Zend_Pdf_Resource_Font extends Zend_Pdf_Resource
|
||||
|
||||
/**
|
||||
* Convert string to the font encoding.
|
||||
*
|
||||
* The method is used to prepare string for text drawing operators
|
||||
*
|
||||
* The method is used to prepare string for text drawing operators
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $charEncoding Character encoding of source text.
|
||||
|
@ -21,9 +21,6 @@
|
||||
/** 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';
|
||||
|
||||
@ -54,18 +51,22 @@ class Zend_Pdf_Resource_Image_Jpeg extends Zend_Pdf_Resource_Image
|
||||
public function __construct($imageFileName)
|
||||
{
|
||||
if (!function_exists('gd_info')) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Image extension is not installed.');
|
||||
}
|
||||
|
||||
$gd_options = gd_info();
|
||||
if (!$gd_options['JPG Support'] ) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('JPG support is not configured properly.');
|
||||
}
|
||||
|
||||
if (($imageInfo = getimagesize($imageFileName)) === false) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('Corrupted image or image doesn\'t exist.');
|
||||
}
|
||||
if ($imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_JPEG2000) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('ImageType is not JPG');
|
||||
}
|
||||
|
||||
@ -95,6 +96,7 @@ class Zend_Pdf_Resource_Image_Jpeg extends Zend_Pdf_Resource_Image
|
||||
}
|
||||
|
||||
if (($imageFile = @fopen($imageFileName, 'rb')) === false ) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "Can not open '$imageFileName' file for reading." );
|
||||
}
|
||||
$byteCount = filesize($imageFileName);
|
||||
|
@ -17,13 +17,9 @@
|
||||
* @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';
|
||||
|
||||
@ -33,7 +29,6 @@ require_once 'Zend/Pdf/Element/Name.php';
|
||||
/** Zend_Pdf_ElementFactory */
|
||||
require_once 'Zend/Pdf/ElementFactory.php';
|
||||
|
||||
|
||||
/**
|
||||
* PNG image
|
||||
*
|
||||
@ -82,6 +77,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
public function __construct($imageFileName)
|
||||
{
|
||||
if (($imageFile = @fopen($imageFileName, 'rb')) === false ) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "Can not open '$imageFileName' file for reading." );
|
||||
}
|
||||
|
||||
@ -90,6 +86,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
//Check if the file is a PNG
|
||||
fseek($imageFile, 1, SEEK_CUR); //First signature byte (%)
|
||||
if ('PNG' != fread($imageFile, 3)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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
|
||||
@ -104,6 +101,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
$prefilter = ord(fread($imageFile,1));
|
||||
|
||||
if (($interlacing = ord(fread($imageFile,1))) != Zend_Pdf_Resource_Image_Png::PNG_INTERLACING_DISABLED) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "Only non-interlaced images are currently supported." );
|
||||
}
|
||||
|
||||
@ -170,6 +168,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
// Fall through to the next case
|
||||
|
||||
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_RGB_ALPHA:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "tRNS chunk illegal for Alpha Channel Images" );
|
||||
break;
|
||||
}
|
||||
@ -200,6 +199,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
|
||||
case Zend_Pdf_Resource_Image_Png::PNG_CHANNEL_INDEXED:
|
||||
if(empty($paletteData)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "PNG Corruption: No palette data read for indexed type PNG." );
|
||||
}
|
||||
$colorSpace = new Zend_Pdf_Element_Array();
|
||||
@ -217,6 +217,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
* will become the Shadow Mask (SMask).
|
||||
*/
|
||||
if($bits > 8) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Alpha PNGs with bit depth > 8 are not yet supported");
|
||||
}
|
||||
|
||||
@ -250,6 +251,7 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
* will become the Shadow Mask (SMask).
|
||||
*/
|
||||
if($bits > 8) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Alpha PNGs with bit depth > 8 are not yet supported");
|
||||
}
|
||||
|
||||
@ -278,10 +280,12 @@ class Zend_Pdf_Resource_Image_Png extends Zend_Pdf_Resource_Image
|
||||
break;
|
||||
|
||||
default:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "PNG Corruption: Invalid color space." );
|
||||
}
|
||||
|
||||
if(empty($imageData)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "Corrupt PNG Image. Mandatory IDAT chunk not found." );
|
||||
}
|
||||
|
||||
|
@ -17,20 +17,15 @@
|
||||
* @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
|
||||
*
|
||||
@ -107,6 +102,7 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
*/
|
||||
protected function unpackBytes($type, $bytes) {
|
||||
if(!isset($this->_endianType)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("The unpackBytes function can only be used after the endianness of the file is known");
|
||||
}
|
||||
switch($type) {
|
||||
@ -142,6 +138,7 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
public function __construct($imageFileName)
|
||||
{
|
||||
if (($imageFile = @fopen($imageFileName, 'rb')) === false ) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception( "Can not open '$imageFileName' file for reading." );
|
||||
}
|
||||
|
||||
@ -151,12 +148,14 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
} else if($byteOrderIndicator == 'MM') {
|
||||
$this->_endianType = Zend_Pdf_Resource_Image_Tiff::TIFF_ENDIAN_BIG;
|
||||
} else {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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));
|
||||
@ -172,6 +171,7 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
|
||||
while($ifdOffset > 0) {
|
||||
if(fseek($imageFile, $ifdOffset, SEEK_SET) == -1 || $ifdOffset+2 >= $this->_fileSize) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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);
|
||||
}
|
||||
|
||||
@ -266,21 +266,25 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
//Fall through to next case
|
||||
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_GROUP_4_FAX:
|
||||
$this->_filter = 'CCITTFaxDecode';
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("CCITTFaxDecode Compression Mode Not Currently Supported");
|
||||
break;
|
||||
case Zend_Pdf_Resource_Image_Tiff::TIFF_COMPRESSION_LZW:
|
||||
$this->_filter = 'LZWDecode';
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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");
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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");
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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';
|
||||
@ -315,6 +319,7 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
$this->_colorSpace = 'Lab';
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception('TIFF: Unknown or Unsupported Color Type: '. $value);
|
||||
}
|
||||
break;
|
||||
@ -351,12 +356,14 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
}
|
||||
|
||||
if(!isset($this->_imageDataOffset) || !isset($this->_imageDataLength)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
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) {
|
||||
@ -368,6 +375,7 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
$imageDataBytes = fread($imageFile, $this->_imageDataLength);
|
||||
}
|
||||
if($imageDataBytes === '') {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("TIFF: No data. Image Corruption");
|
||||
}
|
||||
|
||||
@ -377,6 +385,7 @@ class Zend_Pdf_Resource_Image_Tiff extends Zend_Pdf_Resource_Image
|
||||
|
||||
$imageDictionary = $this->_resource->dictionary;
|
||||
if(!isset($this->_width) || !isset($this->_width)) {
|
||||
require_once 'Zend/Pdf/Exception.php';
|
||||
throw new Zend_Pdf_Exception("Problem reading tiff file. Tiff is probably corrupt.");
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ class Zend_Pdf_Style
|
||||
*/
|
||||
public function getLineWidth()
|
||||
{
|
||||
$this->_lineWidth->value;
|
||||
return $this->_lineWidth->value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user