Zend Framework  1.12
Public Member Functions | List of all members
Zend_Pdf_Canvas_Interface Interface Reference

Public Member Functions

 getResources ()
 Returns dictionaries of used resources.
 
 getContents ()
 Get drawing instructions stream.
 
 getHeight ()
 Return canvas height.
 
 getWidth ()
 Return canvas width.
 
 drawCanvas (Zend_Pdf_Canvas_Interface $canvas, $x1, $y1, $x2=null, $y2=null)
 Draw a canvas at the specified location.
 
 setFillColor (Zend_Pdf_Color $color)
 Set fill color.
 
 setLineColor (Zend_Pdf_Color $color)
 Set line color.
 
 setLineWidth ($width)
 Set line width.
 
 setLineDashingPattern ($pattern, $phase=0)
 Set line dashing pattern.
 
 setFont (Zend_Pdf_Resource_Font $font, $fontSize)
 Set current font.
 
 setStyle (Zend_Pdf_Style $style)
 Set the style to use for future drawing operations on this page.
 
 getFont ()
 Get current font.
 
 getFontSize ()
 Get current font size.
 
 getStyle ()
 Return the style, applied to the page.
 
 saveGS ()
 Save the graphics state of this page.
 
 setAlpha ($alpha, $mode= 'Normal')
 Set the transparancy.
 
 clipCircle ($x, $y, $radius, $startAngle=null, $endAngle=null)
 Intersect current clipping area with a circle.
 
 clipEllipse ($x1, $y1, $x2, $y2, $startAngle=null, $endAngle=null)
 Intersect current clipping area with a polygon.
 
 clipPolygon ($x, $y, $fillMethod=Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)
 Intersect current clipping area with a polygon.
 
 clipRectangle ($x1, $y1, $x2, $y2)
 Intersect current clipping area with a rectangle.
 
 drawCircle ($x, $y, $radius, $param4=null, $param5=null, $param6=null)
 Draw a circle centered on x, y with a radius of radius.
 
 drawEllipse ($x1, $y1, $x2, $y2, $param5=null, $param6=null, $param7=null)
 Draw an ellipse inside the specified rectangle.
 
 drawImage (Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2)
 Draw an image at the specified position on the page.
 
 drawLayoutBox ($box, $x, $y)
 Draw a LayoutBox at the specified position on the page.
 
 drawLine ($x1, $y1, $x2, $y2)
 Draw a line from x1,y1 to x2,y2.
 
 drawPolygon ($x, $y, $fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE, $fillMethod=Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING)
 Draw a polygon.
 
 drawRectangle ($x1, $y1, $x2, $y2, $fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)
 Draw a rectangle.
 
 drawRoundedRectangle ($x1, $y1, $x2, $y2, $radius, $fillType=Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE)
 Draw a rounded rectangle.
 
 drawText ($text, $x, $y, $charEncoding= '')
 Draw a line of text at the specified position.
 
 pathClose ()
 Close the path by drawing a straight line back to it's beginning.
 
 pathLine ($x, $y)
 Continue the open path in a straight line to the specified position.
 
 pathMove ($x, $y)
 Start a new path at the specified position.
 
 rotate ($x, $y, $angle)
 Rotate the page.
 
 scale ($xScale, $yScale)
 Scale coordination system.
 
 translate ($xShift, $yShift)
 Translate coordination system.
 
 skew ($x, $y, $xAngle, $yAngle)
 Translate coordination system.
 
 rawWrite ($data, $procSet=null)
 Writes the raw data to the page's content stream.
 

Member Function Documentation

clipCircle (   $x,
  $y,
  $radius,
  $startAngle = null,
  $endAngle = null 
)

Intersect current clipping area with a circle.

Parameters
float$x
float$y
float$radius
float$startAngle
float$endAngle
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

clipEllipse (   $x1,
  $y1,
  $x2,
  $y2,
  $startAngle = null,
  $endAngle = null 
)

Intersect current clipping area with a polygon.

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

Todo:
process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
Parameters
float$x1
float$y1
float$x2
float$y2
float$startAngle
float$endAngle
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

clipPolygon (   $x,
  $y,
  $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING 
)

Intersect current clipping area with a polygon.

Parameters
array$x- array of float (the X co-ordinates of the vertices)
array$y- array of float (the Y co-ordinates of the vertices)
integer$fillMethod
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

clipRectangle (   $x1,
  $y1,
  $x2,
  $y2 
)

Intersect current clipping area with a rectangle.

Parameters
float$x1
float$y1
float$x2
float$y2
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawCanvas ( Zend_Pdf_Canvas_Interface  $canvas,
  $x1,
  $y1,
  $x2 = null,
  $y2 = null 
)

Draw a canvas at the specified location.

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

Parameters
Zend_Pdf_Canvas_Interface$canvas
float$x1
float$y1
float$x2
float$y2
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawCircle (   $x,
  $y,
  $radius,
  $param4 = null,
  $param5 = null,
  $param6 = null 
)

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

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, 3*PI/8, 5*PI/8, 7*PI/8, 9*PI/8, 11*PI/8, 13*PI/8 and 15*PI/8 angles). 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.

Parameters
float$x
float$y
float$radius
mixed$param4
mixed$param5
mixed$param6
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawEllipse (   $x1,
  $y1,
  $x2,
  $y2,
  $param5 = null,
  $param6 = null,
  $param7 = null 
)

Draw an ellipse inside the specified rectangle.

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

Todo:
process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
Parameters
float$x1
float$y1
float$x2
float$y2
mixed$param5
mixed$param6
mixed$param7
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawImage ( Zend_Pdf_Resource_Image  $image,
  $x1,
  $y1,
  $x2,
  $y2 
)

Draw an image at the specified position on the page.

Parameters
Zend_Pdf_Image$image
float$x1
float$y1
float$x2
float$y2
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawLayoutBox (   $box,
  $x,
  $y 
)

Draw a LayoutBox at the specified position on the page.

Implemented in Zend_Pdf_Canvas_Abstract.

drawLine (   $x1,
  $y1,
  $x2,
  $y2 
)

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

Parameters
float$x1
float$y1
float$x2
float$y2
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawPolygon (   $x,
  $y,
  $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,
  $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING 
)

Draw a polygon.

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
array$x- array of float (the X co-ordinates of the vertices)
array$y- array of float (the Y co-ordinates of the vertices)
integer$fillType
integer$fillMethod
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawRectangle (   $x1,
  $y1,
  $x2,
  $y2,
  $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE 
)

Draw a rectangle.

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
float$x1
float$y1
float$x2
float$y2
integer$fillType
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawRoundedRectangle (   $x1,
  $y1,
  $x2,
  $y2,
  $radius,
  $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE 
)

Draw a rounded rectangle.

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
float$x1
float$y1
float$x2
float$y2
integer | array$radius
integer$fillType
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

drawText (   $text,
  $x,
  $y,
  $charEncoding = '' 
)

Draw a line of text at the specified position.

Parameters
string$text
float$x
float$y
string$charEncoding(optional) Character encoding of source text. Defaults to current locale.
Exceptions
Zend_Pdf_Exception
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

getContents ( )

Get drawing instructions stream.

It has to be returned as a PDF stream object to make it reusable.

Implemented in Zend_Pdf_Page, and Zend_Pdf_Canvas.

getFont ( )

Get current font.

Returns
Zend_Pdf_Resource_Font $font

Implemented in Zend_Pdf_Canvas_Abstract.

getFontSize ( )

Get current font size.

Returns
float $fontSize

Implemented in Zend_Pdf_Canvas_Abstract.

getHeight ( )

Return canvas height.

Returns
float

Implemented in Zend_Pdf_Page, and Zend_Pdf_Canvas.

getResources ( )

Returns dictionaries of used resources.

Used for canvas implementations interoperability

Structure of the returned array: array( <resTypeName> => array( <resName> => <Zend_Pdf_Resource object>="">, <resName> => <Zend_Pdf_Resource object>="">, <resName> => <Zend_Pdf_Resource object>="">, ... ), <resTypeName> => array( <resName> => <Zend_Pdf_Resource object>="">, <resName> => <Zend_Pdf_Resource object>="">, <resName> => <Zend_Pdf_Resource object>="">, ... ), ... 'ProcSet' => array() )

where ProcSet array is a list of used procedure sets names (strings). Allowed procedure set names: 'PDF', 'Text', 'ImageB', 'ImageC', 'ImageI'

Implemented in Zend_Pdf_Page, and Zend_Pdf_Canvas.

getStyle ( )

Return the style, applied to the page.

Returns
Zend_Pdf_Style|null

Implemented in Zend_Pdf_Canvas_Abstract.

getWidth ( )

Return canvas width.

Returns
float

Implemented in Zend_Pdf_Page, and Zend_Pdf_Canvas.

pathClose ( )

Close the path by drawing a straight line back to it's beginning.

Implemented in Zend_Pdf_Canvas_Abstract.

pathLine (   $x,
  $y 
)

Continue the open path in a straight line to the specified position.

Implemented in Zend_Pdf_Canvas_Abstract.

pathMove (   $x,
  $y 
)

Start a new path at the specified position.

If a path has already been started, move the cursor without drawing a line.

Implemented in Zend_Pdf_Canvas_Abstract.

rawWrite (   $data,
  $procSet = null 
)

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

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
string$data
string$procSet(optional) Name of ProcSet to add.
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

rotate (   $x,
  $y,
  $angle 
)

Rotate the page.

Parameters
float$x- the X co-ordinate of rotation point
float$y- the Y co-ordinate of rotation point
float$angle- rotation angle
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

saveGS ( )

Save the graphics state of this page.

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

Exceptions
Zend_Pdf_Exception- if a save is performed with an open path
Returns
Zend_Pdf_Page

Implemented in Zend_Pdf_Canvas_Abstract.

scale (   $xScale,
  $yScale 
)

Scale coordination system.

Parameters
float$xScale- X dimention scale factor
float$yScale- Y dimention scale factor
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setAlpha (   $alpha,
  $mode = 'Normal' 
)

Set the transparancy.

$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
float$alpha
string$mode
Exceptions
Zend_Pdf_Exception
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setFillColor ( Zend_Pdf_Color  $color)

Set fill color.

Parameters
Zend_Pdf_Color$color
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setFont ( Zend_Pdf_Resource_Font  $font,
  $fontSize 
)

Set current font.

Parameters
Zend_Pdf_Resource_Font$font
float$fontSize
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setLineColor ( Zend_Pdf_Color  $color)

Set line color.

Parameters
Zend_Pdf_Color$color
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setLineDashingPattern (   $pattern,
  $phase = 0 
)

Set line dashing pattern.

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
mixed$pattern
array$phase
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setLineWidth (   $width)

Set line width.

Parameters
float$width
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

setStyle ( Zend_Pdf_Style  $style)

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

Parameters
Zend_Pdf_Style$style
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

skew (   $x,
  $y,
  $xAngle,
  $yAngle 
)

Translate coordination system.

Parameters
float$x- the X co-ordinate of axis skew point
float$y- the Y co-ordinate of axis skew point
float$xAngle- X axis skew angle
float$yAngle- Y axis skew angle
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.

translate (   $xShift,
  $yShift 
)

Translate coordination system.

Parameters
float$xShift- X coordinate shift
float$yShift- Y coordinate shift
Returns
Zend_Pdf_Canvas_Interface

Implemented in Zend_Pdf_Canvas_Abstract.