File indexing completed on 2024-06-16 05:30:16

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Pdf
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id: Style.php 20096 2010-01-06 02:05:09Z bkarwin $
0020  */
0021 
0022 
0023 /**
0024  * Canvas is an abstract rectangle drawing area which can be dropped into
0025  * page object at specified place.
0026  *
0027  * @package    Zend_Pdf
0028  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0029  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0030  */
0031 interface Zend_Pdf_Canvas_Interface
0032 {
0033     /**
0034      * Returns dictionaries of used resources.
0035      *
0036      * Used for canvas implementations interoperability
0037      *
0038      * Structure of the returned array:
0039      * array(
0040      *   <resTypeName> => array(
0041      *                      <resName> => <Zend_Pdf_Resource object>,
0042      *                      <resName> => <Zend_Pdf_Resource object>,
0043      *                      <resName> => <Zend_Pdf_Resource object>,
0044      *                      ...
0045      *                    ),
0046      *   <resTypeName> => array(
0047      *                      <resName> => <Zend_Pdf_Resource object>,
0048      *                      <resName> => <Zend_Pdf_Resource object>,
0049      *                      <resName> => <Zend_Pdf_Resource object>,
0050      *                      ...
0051      *                    ),
0052      *   ...
0053      *   'ProcSet' => array()
0054      * )
0055      *
0056      * where ProcSet array is a list of used procedure sets names (strings).
0057      * Allowed procedure set names: 'PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'
0058      *
0059      * @internal
0060      * @return array
0061      */
0062     public function getResources();
0063 
0064     /**
0065      * Get drawing instructions stream
0066      *
0067      * It has to be returned as a PDF stream object to make it reusable.
0068      *
0069      * @internal
0070      * @returns Zend_Pdf_Resource_ContentStream
0071      */
0072     public function getContents();
0073 
0074     /**
0075      * Return canvas height.
0076      *
0077      * @return float
0078      */
0079     public function getHeight();
0080 
0081     /**
0082      * Return canvas width.
0083      *
0084      * @return float
0085      */
0086     public function getWidth();
0087 
0088     /**
0089      * Draw a canvas at the specified location
0090      *
0091      * If upper right corner is not specified then canvas heght and width
0092      * are used.
0093      *
0094      * @param Zend_Pdf_Canvas_Interface $canvas
0095      * @param float $x1
0096      * @param float $y1
0097      * @param float $x2
0098      * @param float $y2
0099      * @return Zend_Pdf_Canvas_Interface
0100      */
0101     public function drawCanvas(Zend_Pdf_Canvas_Interface $canvas, $x1, $y1, $x2 = null, $y2 = null);
0102 
0103     /**
0104      * Set fill color.
0105      *
0106      * @param Zend_Pdf_Color $color
0107      * @return Zend_Pdf_Canvas_Interface
0108      */
0109     public function setFillColor(Zend_Pdf_Color $color);
0110 
0111     /**
0112      * Set line color.
0113      *
0114      * @param Zend_Pdf_Color $color
0115      * @return Zend_Pdf_Canvas_Interface
0116      */
0117     public function setLineColor(Zend_Pdf_Color $color);
0118 
0119     /**
0120      * Set line width.
0121      *
0122      * @param float $width
0123      * @return Zend_Pdf_Canvas_Interface
0124      */
0125     public function setLineWidth($width);
0126 
0127     /**
0128      * Set line dashing pattern
0129      *
0130      * Pattern is an array of floats: array(on_length, off_length, on_length, off_length, ...)
0131      * or Zend_Pdf_Page::LINE_DASHING_SOLID constant
0132      * Phase is shift from the beginning of line.
0133      *
0134      * @param mixed $pattern
0135      * @param array $phase
0136      * @return Zend_Pdf_Canvas_Interface
0137      */
0138     public function setLineDashingPattern($pattern, $phase = 0);
0139 
0140     /**
0141      * Set current font.
0142      *
0143      * @param Zend_Pdf_Resource_Font $font
0144      * @param float $fontSize
0145      * @return Zend_Pdf_Canvas_Interface
0146      */
0147     public function setFont(Zend_Pdf_Resource_Font $font, $fontSize);
0148 
0149     /**
0150      * Set the style to use for future drawing operations on this page
0151      *
0152      * @param Zend_Pdf_Style $style
0153      * @return Zend_Pdf_Canvas_Interface
0154      */
0155     public function setStyle(Zend_Pdf_Style $style);
0156 
0157     /**
0158      * Get current font.
0159      *
0160      * @return Zend_Pdf_Resource_Font $font
0161      */
0162     public function getFont();
0163 
0164     /**
0165      * Get current font size
0166      *
0167      * @return float $fontSize
0168      */
0169     public function getFontSize();
0170 
0171     /**
0172      * Return the style, applied to the page.
0173      *
0174      * @return Zend_Pdf_Style|null
0175      */
0176     public function getStyle();
0177 
0178     /**
0179      * Save the graphics state of this page.
0180      * This takes a snapshot of the currently applied style, position, clipping area and
0181      * any rotation/translation/scaling that has been applied.
0182      *
0183      * @throws Zend_Pdf_Exception    - if a save is performed with an open path
0184      * @return Zend_Pdf_Page
0185      */
0186     public function saveGS();
0187 
0188     /**
0189      * Set the transparancy
0190      *
0191      * $alpha == 0  - transparent
0192      * $alpha == 1  - opaque
0193      *
0194      * Transparency modes, supported by PDF:
0195      * Normal (default), Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight,
0196      * SoftLight, Difference, Exclusion
0197      *
0198      * @param float $alpha
0199      * @param string $mode
0200      * @throws Zend_Pdf_Exception
0201      * @return Zend_Pdf_Canvas_Interface
0202      */
0203     public function setAlpha($alpha, $mode = 'Normal');
0204 
0205     /**
0206      * Intersect current clipping area with a circle.
0207      *
0208      * @param float $x
0209      * @param float $y
0210      * @param float $radius
0211      * @param float $startAngle
0212      * @param float $endAngle
0213      * @return Zend_Pdf_Canvas_Interface
0214      */
0215     public function clipCircle($x, $y, $radius, $startAngle = null, $endAngle = null);
0216 
0217     /**
0218      * Intersect current clipping area with a polygon.
0219      *
0220      * Method signatures:
0221      * drawEllipse($x1, $y1, $x2, $y2);
0222      * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
0223      *
0224      * @todo process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
0225      *
0226      * @param float $x1
0227      * @param float $y1
0228      * @param float $x2
0229      * @param float $y2
0230      * @param float $startAngle
0231      * @param float $endAngle
0232      * @return Zend_Pdf_Canvas_Interface
0233      */
0234     public function clipEllipse($x1, $y1, $x2, $y2, $startAngle = null, $endAngle = null);
0235 
0236     /**
0237      * Intersect current clipping area with a polygon.
0238      *
0239      * @param array $x  - array of float (the X co-ordinates of the vertices)
0240      * @param array $y  - array of float (the Y co-ordinates of the vertices)
0241      * @param integer $fillMethod
0242      * @return Zend_Pdf_Canvas_Interface
0243      */
0244     public function clipPolygon($x, $y, $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
0245 
0246     /**
0247      * Intersect current clipping area with a rectangle.
0248      *
0249      * @param float $x1
0250      * @param float $y1
0251      * @param float $x2
0252      * @param float $y2
0253      * @return Zend_Pdf_Canvas_Interface
0254      */
0255     public function clipRectangle($x1, $y1, $x2, $y2);
0256 
0257     /**
0258      * Draw a circle centered on x, y with a radius of radius.
0259      *
0260      * Method signatures:
0261      * drawCircle($x, $y, $radius);
0262      * drawCircle($x, $y, $radius, $fillType);
0263      * drawCircle($x, $y, $radius, $startAngle, $endAngle);
0264      * drawCircle($x, $y, $radius, $startAngle, $endAngle, $fillType);
0265      *
0266      *
0267      * It's not a really circle, because PDF supports only cubic Bezier curves.
0268      * But _very_ good approximation.
0269      * It differs from a real circle on a maximum 0.00026 radiuses
0270      * (at PI/8, 3*PI/8, 5*PI/8, 7*PI/8, 9*PI/8, 11*PI/8, 13*PI/8 and 15*PI/8 angles).
0271      * At 0, PI/4, PI/2, 3*PI/4, PI, 5*PI/4, 3*PI/2 and 7*PI/4 it's exactly a tangent to a circle.
0272      *
0273      * @param float $x
0274      * @param float $y
0275      * @param float $radius
0276      * @param mixed $param4
0277      * @param mixed $param5
0278      * @param mixed $param6
0279      * @return Zend_Pdf_Canvas_Interface
0280      */
0281     public function  drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null);
0282 
0283     /**
0284      * Draw an ellipse inside the specified rectangle.
0285      *
0286      * Method signatures:
0287      * drawEllipse($x1, $y1, $x2, $y2);
0288      * drawEllipse($x1, $y1, $x2, $y2, $fillType);
0289      * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
0290      * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle, $fillType);
0291      *
0292      * @todo process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
0293      *
0294      * @param float $x1
0295      * @param float $y1
0296      * @param float $x2
0297      * @param float $y2
0298      * @param mixed $param5
0299      * @param mixed $param6
0300      * @param mixed $param7
0301      * @return Zend_Pdf_Canvas_Interface
0302      */
0303     public function drawEllipse($x1, $y1, $x2, $y2, $param5 = null, $param6 = null, $param7 = null);
0304 
0305     /**
0306      * Draw an image at the specified position on the page.
0307      *
0308      * @param Zend_Pdf_Image $image
0309      * @param float $x1
0310      * @param float $y1
0311      * @param float $x2
0312      * @param float $y2
0313      * @return Zend_Pdf_Canvas_Interface
0314      */
0315     public function drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2);
0316 
0317     /**
0318      * Draw a LayoutBox at the specified position on the page.
0319      *
0320      * @internal (not implemented now)
0321      *
0322      * @param Zend_Pdf_Element_LayoutBox $box
0323      * @param float $x
0324      * @param float $y
0325      * @return Zend_Pdf_Canvas_Interface
0326      */
0327     public function drawLayoutBox($box, $x, $y);
0328 
0329     /**
0330      * Draw a line from x1,y1 to x2,y2.
0331      *
0332      * @param float $x1
0333      * @param float $y1
0334      * @param float $x2
0335      * @param float $y2
0336      * @return Zend_Pdf_Canvas_Interface
0337      */
0338     public function drawLine($x1, $y1, $x2, $y2);
0339 
0340     /**
0341      * Draw a polygon.
0342      *
0343      * If $fillType is Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE or
0344      * Zend_Pdf_Page::SHAPE_DRAW_FILL, then polygon is automatically closed.
0345      * See detailed description of these methods in a PDF documentation
0346      * (section 4.4.2 Path painting Operators, Filling)
0347      *
0348      * @param array $x  - array of float (the X co-ordinates of the vertices)
0349      * @param array $y  - array of float (the Y co-ordinates of the vertices)
0350      * @param integer $fillType
0351      * @param integer $fillMethod
0352      * @return Zend_Pdf_Canvas_Interface
0353      */
0354     public function drawPolygon($x, $y,
0355                                 $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,
0356                                 $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
0357     /**
0358      * Draw a rectangle.
0359      *
0360      * Fill types:
0361      * Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)
0362      * Zend_Pdf_Page::SHAPE_DRAW_STROKE      - stroke rectangle
0363      * Zend_Pdf_Page::SHAPE_DRAW_FILL        - fill rectangle
0364      *
0365      * @param float $x1
0366      * @param float $y1
0367      * @param float $x2
0368      * @param float $y2
0369      * @param integer $fillType
0370      * @return Zend_Pdf_Canvas_Interface
0371      */
0372     public function drawRectangle($x1, $y1, $x2, $y2, $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
0373 
0374     /**
0375      * Draw a rounded rectangle.
0376      *
0377      * Fill types:
0378      * Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)
0379      * Zend_Pdf_Page::SHAPE_DRAW_STROKE      - stroke rectangle
0380      * Zend_Pdf_Page::SHAPE_DRAW_FILL        - fill rectangle
0381      *
0382      * radius is an integer representing radius of the four corners, or an array
0383      * of four integers representing the radius starting at top left, going
0384      * clockwise
0385      *
0386      * @param float $x1
0387      * @param float $y1
0388      * @param float $x2
0389      * @param float $y2
0390      * @param integer|array $radius
0391      * @param integer $fillType
0392      * @return Zend_Pdf_Canvas_Interface
0393      */
0394     public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius,
0395                                          $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
0396 
0397     /**
0398      * Draw a line of text at the specified position.
0399      *
0400      * @param string $text
0401      * @param float $x
0402      * @param float $y
0403      * @param string $charEncoding (optional) Character encoding of source text.
0404      *   Defaults to current locale.
0405      * @throws Zend_Pdf_Exception
0406      * @return Zend_Pdf_Canvas_Interface
0407      */
0408     public function drawText($text, $x, $y, $charEncoding = '');
0409 
0410      /**
0411      * Close the path by drawing a straight line back to it's beginning.
0412      *
0413      * @internal (needs implementation)
0414      *
0415      * @throws Zend_Pdf_Exception    - if a path hasn't been started with pathMove()
0416      * @return Zend_Pdf_Canvas_Interface
0417      */
0418     public function pathClose();
0419 
0420     /**
0421      * Continue the open path in a straight line to the specified position.
0422      *
0423      * @internal (needs implementation)
0424      *
0425      * @param float $x  - the X co-ordinate to move to
0426      * @param float $y  - the Y co-ordinate to move to
0427      * @return Zend_Pdf_Canvas_Interface
0428      */
0429     public function pathLine($x, $y);
0430 
0431     /**
0432      * Start a new path at the specified position. If a path has already been started,
0433      * move the cursor without drawing a line.
0434      *
0435      * @internal (needs implementation)
0436      *
0437      * @param float $x  - the X co-ordinate to move to
0438      * @param float $y  - the Y co-ordinate to move to
0439      * @return Zend_Pdf_Canvas_Interface
0440      */
0441     public function pathMove($x, $y);
0442 
0443     /**
0444      * Rotate the page.
0445      *
0446      * @param float $x  - the X co-ordinate of rotation point
0447      * @param float $y  - the Y co-ordinate of rotation point
0448      * @param float $angle - rotation angle
0449      * @return Zend_Pdf_Canvas_Interface
0450      */
0451     public function rotate($x, $y, $angle);
0452 
0453     /**
0454      * Scale coordination system.
0455      *
0456      * @param float $xScale - X dimention scale factor
0457      * @param float $yScale - Y dimention scale factor
0458      * @return Zend_Pdf_Canvas_Interface
0459      */
0460     public function scale($xScale, $yScale);
0461 
0462     /**
0463      * Translate coordination system.
0464      *
0465      * @param float $xShift - X coordinate shift
0466      * @param float $yShift - Y coordinate shift
0467      * @return Zend_Pdf_Canvas_Interface
0468      */
0469     public function translate($xShift, $yShift);
0470 
0471     /**
0472      * Translate coordination system.
0473      *
0474      * @param float $x  - the X co-ordinate of axis skew point
0475      * @param float $y  - the Y co-ordinate of axis skew point
0476      * @param float $xAngle - X axis skew angle
0477      * @param float $yAngle - Y axis skew angle
0478      * @return Zend_Pdf_Canvas_Interface
0479      */
0480     public function skew($x, $y, $xAngle, $yAngle);
0481 
0482     /**
0483      * Writes the raw data to the page's content stream.
0484      *
0485      * Be sure to consult the PDF reference to ensure your syntax is correct. No
0486      * attempt is made to ensure the validity of the stream data.
0487      *
0488      * @param string $data
0489      * @param string $procSet (optional) Name of ProcSet to add.
0490      * @return Zend_Pdf_Canvas_Interface
0491      */
0492     public function rawWrite($data, $procSet = null);
0493 }