import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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." );
}

View File

@ -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.");
}