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

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