Pdf/Canvas.php

Show: inherited
Table of Contents

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 [email protected] so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Pdf  
Version
$Id: Style.php 20096 2010-01-06 02:05:09Z bkarwin $  

\Zend_Pdf_Canvas

Package: Zend\Pdf

Canvas is an abstract rectangle drawing area which can be dropped into page object at specified place.

Parent(s)
\Zend_Pdf_Canvas_Abstract
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Properties

Propertyprotectedstring $_contents = ''
inherited

Drawing instructions

Inherited from: \Zend_Pdf_Canvas_Abstract::$$_contents
Default value''Details
Type
string
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_contents  
Propertyprotected\Zend_Pdf_Resource_Font $_font = null
inherited

Current font

Inherited from: \Zend_Pdf_Canvas_Abstract::$$_font
Default valuenullDetails
Type
\Zend_Pdf_Resource_Font
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_font  
Propertyprotectedfloat $_fontSize =
inherited

Current font size

Inherited from: \Zend_Pdf_Canvas_Abstract::$$_fontSize
Details
Type
float
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_fontSize  
Propertyprotectedfloat $_height =

Canvas height expressed in default user space units (1/72 inch)

Details
Type
float
Propertyprotectedarray $_procSet = array()

Canvas procedure sets.

Allowed values: 'PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'.

Default valuearray()Details
Type
array
Propertyprotected$_resources = array('Font' => array(), 'XObject' => array(), 'ExtGState' => array())
Default valuearray('Font' => array(), 'XObject' => array(), 'ExtGState' => array())Details
Type
n/a
Propertyprotectedinteger $_saveCount = 0
inherited

Counter for the "Save" operations

Inherited from: \Zend_Pdf_Canvas_Abstract::$$_saveCount
Default value0Details
Type
integer
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_saveCount  
Propertyprotected\Zend_Pdf_Style $_style = null
inherited

Current style

Inherited from: \Zend_Pdf_Canvas_Abstract::$$_style
Default valuenullDetails
Type
\Zend_Pdf_Style
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_style  
Propertyprotectedfloat $_width =

Canvas width expressed in default user space units (1/72 inch)

Details
Type
float

Methods

methodpublic__construct(float $width, float $height) : void

Object constructor

Parameters
Name Type Description
$width float
$height float
methodprotected_addProcSet(string $procSetName) : void

Add procedure set to the canvas description

Parameters
Name Type Description
$procSetName string
methodprotected_attachResource(string $type, \Zend_Pdf_Resource $resource) : string

Attach resource to the canvas

Method returns a name of the resource which can be used as a resource reference within drawing instructions stream Allowed types: 'ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font', 'Properties'

Parameters
Name Type Description
$type string
$resource \Zend_Pdf_Resource
Returns
Type Description
string
methodpublicclipCircle(float $x, float $y, float $radius, float $startAngle = null, float $endAngle = null) : \Zend_Pdf_Canvas_Interface
inherited

Intersect current clipping area with a circle.

Inherited from: \Zend_Pdf_Canvas_Abstract::clipCircle()
Parameters
Name Type Description
$x float
$y float
$radius float
$startAngle float
$endAngle float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicclipEllipse(float $x1, float $y1, float $x2, float $y2, float $startAngle = null, float $endAngle = null) : \Zend_Pdf_Canvas_Interface
inherited

Intersect current clipping area with a polygon.

Inherited from: \Zend_Pdf_Canvas_Abstract::clipEllipse()

Method signatures: drawEllipse($x1, $y1, $x2, $y2); drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);

Parameters
Name Type Description
$x1 float
$y1 float
$x2 float
$y2 float
$startAngle float
$endAngle float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicclipPolygon(array $x, array $y, integer $fillMethod = \Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) : \Zend_Pdf_Canvas_Interface
inherited

Intersect current clipping area with a polygon.

Inherited from: \Zend_Pdf_Canvas_Abstract::clipPolygon()
Parameters
Name Type Description
$x array
  • array of float (the X co-ordinates of the vertices)
$y array
  • array of float (the Y co-ordinates of the vertices)
$fillMethod integer
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicclipRectangle(float $x1, float $y1, float $x2, float $y2) : \Zend_Pdf_Canvas_Interface
inherited

Intersect current clipping area with a rectangle.

Inherited from: \Zend_Pdf_Canvas_Abstract::clipRectangle()
Parameters
Name Type Description
$x1 float
$y1 float
$x2 float
$y2 float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawCanvas(\Zend_Pdf_Canvas_Interface $canvas, float $x1, float $y1, float $x2 = null, float $y2 = null) : \Zend_Pdf_Canvas_Interface
inherited

Draw a canvas at the specified location

Inherited from: \Zend_Pdf_Canvas_Abstract::drawCanvas()

If upper right corner is not specified then canvas heght and width are used.

Parameters
Name Type Description
$canvas \Zend_Pdf_Canvas_Interface
$x1 float
$y1 float
$x2 float
$y2 float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawCircle(float $x, float $y, float $radius, mixed $param4 = null, mixed $param5 = null, mixed $param6 = null) : \Zend_Pdf_Canvas_Interface
inherited

Draw a circle centered on x, y with a radius of radius.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawCircle()

Method signatures: drawCircle($x, $y, $radius); drawCircle($x, $y, $radius, $fillType); drawCircle($x, $y, $radius, $startAngle, $endAngle); drawCircle($x, $y, $radius, $startAngle, $endAngle, $fillType);

It's not a really circle, because PDF supports only cubic Bezier curves. But very good approximation. It differs from a real circle on a maximum 0.00026 radiuses (at PI/8, 3PI/8, 5PI/8, 7PI/8, 9PI/8, 11PI/8, 13PI/8 and 15PI/8 angles). At 0, PI/4, PI/2, 3PI/4, PI, 5PI/4, 3PI/2 and 7*PI/4 it's exactly a tangent to a circle.

Parameters
Name Type Description
$x float
$y float
$radius float
$param4 mixed
$param5 mixed
$param6 mixed
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawEllipse(float $x1, float $y1, float $x2, float $y2, mixed $param5 = null, mixed $param6 = null, mixed $param7 = null) : \Zend_Pdf_Canvas_Interface
inherited

Draw an ellipse inside the specified rectangle.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawEllipse()

Method signatures: drawEllipse($x1, $y1, $x2, $y2); drawEllipse($x1, $y1, $x2, $y2, $fillType); drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle); drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle, $fillType);

Parameters
Name Type Description
$x1 float
$y1 float
$x2 float
$y2 float
$param5 mixed
$param6 mixed
$param7 mixed
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawImage(\Zend_Pdf_Image $image, float $x1, float $y1, float $x2, float $y2) : \Zend_Pdf_Canvas_Interface
inherited

Draw an image at the specified position on the page.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawImage()
Parameters
Name Type Description
$image \Zend_Pdf_Image
$x1 float
$y1 float
$x2 float
$y2 float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawLine(float $x1, float $y1, float $x2, float $y2) : \Zend_Pdf_Canvas_Interface
inherited

Draw a line from x1,y1 to x2,y2.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawLine()
Parameters
Name Type Description
$x1 float
$y1 float
$x2 float
$y2 float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawPolygon(array $x, array $y, integer $fillType = \Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, integer $fillMethod = \Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING) : \Zend_Pdf_Canvas_Interface
inherited

Draw a polygon.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawPolygon()

If $fillType is Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE or Zend_Pdf_Page::SHAPE_DRAW_FILL, then polygon is automatically closed. See detailed description of these methods in a PDF documentation (section 4.4.2 Path painting Operators, Filling)

Parameters
Name Type Description
$x array
  • array of float (the X co-ordinates of the vertices)
$y array
  • array of float (the Y co-ordinates of the vertices)
$fillType integer
$fillMethod integer
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawRectangle(float $x1, float $y1, float $x2, float $y2, integer $fillType = \Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE) : \Zend_Pdf_Canvas_Interface
inherited

Draw a rectangle.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawRectangle()

Fill types: Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default) Zend_Pdf_Page::SHAPE_DRAW_STROKE - stroke rectangle Zend_Pdf_Page::SHAPE_DRAW_FILL - fill rectangle

Parameters
Name Type Description
$x1 float
$y1 float
$x2 float
$y2 float
$fillType integer
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawRoundedRectangle(float $x1, float $y1, float $x2, float $y2, integer | array $radius, integer $fillType = \Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE) : \Zend_Pdf_Canvas_Interface
inherited

Draw a rounded rectangle.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawRoundedRectangle()

Fill types: Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default) Zend_Pdf_Page::SHAPE_DRAW_STROKE - stroke rectangle Zend_Pdf_Page::SHAPE_DRAW_FILL - fill rectangle

radius is an integer representing radius of the four corners, or an array of four integers representing the radius starting at top left, going clockwise

Parameters
Name Type Description
$x1 float
$y1 float
$x2 float
$y2 float
$radius integer | array
$fillType integer
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicdrawText(string $text, float $x, float $y, string $charEncoding = '') : \Zend_Pdf_Canvas_Interface
inherited

Draw a line of text at the specified position.

Inherited from: \Zend_Pdf_Canvas_Abstract::drawText()
Parameters
Name Type Description
$text string
$x float
$y float
$charEncoding string

(optional) Character encoding of source text. Defaults to current locale.

Returns
Type Description
\Zend_Pdf_Canvas_Interface
Throws
Exception Description
\Zend_Pdf_Exception
methodpublicgetFont() : \Zend_Pdf_Resource_Font
inherited

Get current font.

Inherited from: \Zend_Pdf_Canvas_Abstract::getFont()
Returns
Type Description
\Zend_Pdf_Resource_Font $font
methodpublicgetFontSize() : float
inherited

Get current font size

Inherited from: \Zend_Pdf_Canvas_Abstract::getFontSize()
Returns
Type Description
float $fontSize
methodpublicgetHeight() : float

Return the height of this page in points.

Returns
Type Description
float
methodpublicgetStyle() : \Zend_Pdf_Style
inherited

Return the style, applied to the page.

Inherited from: \Zend_Pdf_Canvas_Abstract::getStyle()
Returns
Type Description
\Zend_Pdf_Style
methodpublicgetWidth() : float

Return the width of this page in points.

Returns
Type Description
float
methodpublicrawWrite(string $data, string $procSet = null) : \Zend_Pdf_Canvas_Interface
inherited

Writes the raw data to the page's content stream.

Inherited from: \Zend_Pdf_Canvas_Abstract::rawWrite()

Be sure to consult the PDF reference to ensure your syntax is correct. No attempt is made to ensure the validity of the stream data.

Parameters
Name Type Description
$data string
$procSet string

(optional) Name of ProcSet to add.

Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicrestoreGS() : \Zend_Pdf_Canvas_Interface
inherited

Restore the graphics state that was saved with the last call to saveGS().

Inherited from: \Zend_Pdf_Canvas_Abstract::restoreGS()
Returns
Type Description
\Zend_Pdf_Canvas_Interface
Throws
Exception Description
\Zend_Pdf_Exception - if there is no previously saved state
methodpublicrotate(float $x, float $y, float $angle) : \Zend_Pdf_Canvas_Interface
inherited

Rotate the page.

Inherited from: \Zend_Pdf_Canvas_Abstract::rotate()
Parameters
Name Type Description
$x float
  • the X co-ordinate of rotation point
$y float
  • the Y co-ordinate of rotation point
$angle float
  • rotation angle
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsaveGS() : \Zend_Pdf_Canvas_Interface
inherited

Save the graphics state of this page.

Inherited from: \Zend_Pdf_Canvas_Abstract::saveGS()

This takes a snapshot of the currently applied style, position, clipping area and any rotation/translation/scaling that has been applied.

Returns
Type Description
\Zend_Pdf_Canvas_Interface
Throws
Exception Description
\Zend_Pdf_Exception - if a save is performed with an open path
methodpublicscale(float $xScale, float $yScale) : \Zend_Pdf_Canvas_Interface
inherited

Scale coordination system.

Inherited from: \Zend_Pdf_Canvas_Abstract::scale()
Parameters
Name Type Description
$xScale float
  • X dimention scale factor
$yScale float
  • Y dimention scale factor
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsetAlpha(float $alpha, string $mode = 'Normal') : \Zend_Pdf_Canvas_Interface
inherited

Set the transparancy

Inherited from: \Zend_Pdf_Canvas_Abstract::setAlpha()

$alpha == 0 - transparent $alpha == 1 - opaque

Transparency modes, supported by PDF: Normal (default), Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion

Parameters
Name Type Description
$alpha float
$mode string
Returns
Type Description
\Zend_Pdf_Canvas_Interface
Throws
Exception Description
\Zend_Pdf_Exception
methodpublicsetFillColor(\Zend_Pdf_Color $color) : \Zend_Pdf_Canvas_Interface
inherited

Set fill color.

Inherited from: \Zend_Pdf_Canvas_Abstract::setFillColor()
Parameters
Name Type Description
$color \Zend_Pdf_Color
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsetFont(\Zend_Pdf_Resource_Font $font, float $fontSize) : \Zend_Pdf_Canvas_Interface
inherited

Set current font.

Inherited from: \Zend_Pdf_Canvas_Abstract::setFont()
Parameters
Name Type Description
$font \Zend_Pdf_Resource_Font
$fontSize float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsetLineColor(\Zend_Pdf_Color $color) : \Zend_Pdf_Canvas_Interface
inherited

Set line color.

Inherited from: \Zend_Pdf_Canvas_Abstract::setLineColor()
Parameters
Name Type Description
$color \Zend_Pdf_Color
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsetLineDashingPattern(mixed $pattern, array $phase = 0) : \Zend_Pdf_Canvas_Interface
inherited

Set line dashing pattern

Inherited from: \Zend_Pdf_Canvas_Abstract::setLineDashingPattern()

Pattern is an array of floats: array(on_length, off_length, on_length, off_length, ...) or Zend_Pdf_Page::LINE_DASHING_SOLID constant Phase is shift from the beginning of line.

Parameters
Name Type Description
$pattern mixed
$phase array
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsetLineWidth(float $width) : \Zend_Pdf_Canvas_Interface
inherited

Set line width.

Inherited from: \Zend_Pdf_Canvas_Abstract::setLineWidth()
Parameters
Name Type Description
$width float
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicsetStyle(\Zend_Pdf_Style $style) : \Zend_Pdf_Canvas_Interface
inherited

Set the style to use for future drawing operations on this page

Inherited from: \Zend_Pdf_Canvas_Abstract::setStyle()
Parameters
Name Type Description
$style \Zend_Pdf_Style
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublicskew(float $x, float $y, float $xAngle, float $yAngle) : \Zend_Pdf_Canvas_Interface
inherited

Translate coordination system.

Inherited from: \Zend_Pdf_Canvas_Abstract::skew()
Parameters
Name Type Description
$x float
  • the X co-ordinate of axis skew point
$y float
  • the Y co-ordinate of axis skew point
$xAngle float
  • X axis skew angle
$yAngle float
  • Y axis skew angle
Returns
Type Description
\Zend_Pdf_Canvas_Interface
methodpublictranslate(float $xShift, float $yShift) : \Zend_Pdf_Canvas_Interface
inherited

Translate coordination system.

Inherited from: \Zend_Pdf_Canvas_Abstract::translate()
Parameters
Name Type Description
$xShift float
  • X coordinate shift
$yShift float
  • Y coordinate shift
Returns
Type Description
\Zend_Pdf_Canvas_Interface
Documentation was generated by phpDocumentor 2.0.0a8.