Pdf/Page.php

Show: PublicProtectedPrivateinherited
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 license@zend.com 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: Page.php 24593 2012-01-05 20:35:02Z matthew $  

\Zend_Pdf_Page

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

Constants

>VConstant  SIZE_A4 = '595:842:'
Size representing an A4 page in portrait (tall) orientation.
>VConstant  SIZE_A4_LANDSCAPE = '842:595:'
Size representing an A4 page in landscape (wide) orientation.
>VConstant  SIZE_LETTER = '612:792:'
Size representing a US Letter page in portrait (tall) orientation.
>VConstant  SIZE_LETTER_LANDSCAPE = '792:612:'
Size representing a US Letter page in landscape (wide) orientation.
>VConstant  SHAPE_DRAW_STROKE = 0
Stroke the path only.

Do not fill.

>VConstant  SHAPE_DRAW_FILL = 1
Fill the path only.

Do not stroke.

>VConstant  SHAPE_DRAW_FILL_AND_STROKE = 2
Fill and stroke the path.
>VConstant  FILL_METHOD_NON_ZERO_WINDING = 0
Fill the path using the non-zero winding rule.
>VConstant  FILL_METHOD_EVEN_ODD = 1
Fill the path using the even-odd rule.
>VConstant  LINE_DASHING_SOLID = 0
Solid line dash.

Properties

>VPropertyprotectedboolean $_attached
Flag which signals, that page is created separately from any PDF document or attached to anyone.
Details
Type
boolean
>VPropertyprotectedstring $_contents = ''
inherited
Drawing instructions
Inherited from: \Zend_Pdf_Canvas_Abstract::$$_contents
Default value''Details
Type
string
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_contents  
>VPropertyprotected\Zend_Pdf_Element_Reference|\Zend_Pdf_Element_Object $_dictionary
Page dictionary (refers to an inderect Zend_Pdf_Element_Dictionary object).
>VPropertyprotected\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  
>VPropertyprotectedfloat $_fontSize
inherited
Current font size
Inherited from: \Zend_Pdf_Canvas_Abstract::$$_fontSize
Details
Type
float
Inherited_from
\Zend_Pdf_Canvas_Abstract::$$_fontSize  
>VPropertyprotected\Zend_Pdf_ElementFactory_Interface $_objFactory = null
PDF objects factory.
Default valuenullDetails
Type
\Zend_Pdf_ElementFactory_Interface
>VPropertyprotectedboolean $_safeGS
Safe Graphics State semafore

If it's false, than we can't be sure Graphics State is restored withing context of previous contents stream (ex. drawing coordinate system may be rotated). We should encompass existing content with save/restore GS operators

Details
Type
boolean
>VPropertyprotectedinteger $_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  
>VPropertyprotected\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  

Methods

methodpublic__clone() : void

Clone page, extract it and dependent objects from the current document, so it can be used within other docs.

methodpublic__construct(mixed $param1, mixed $param2 = null, mixed $param3 = null) : void

Object constructor.

Constructor signatures:

  1. Load PDF page from a parsed PDF file.

Object factory is created by PDF parser.

new Zend_Pdf_Page(Zend_Pdf_Element_Dictionary $pageDict,

Zend_Pdf_ElementFactory_Interface $factory);

  1. Make a copy of the PDF page. New page is created in the same context as source page. Object factory is shared. Thus it will be attached to the document, but need to be placed into Zend_Pdf::$pages array

to be included into output.

new Zend_Pdf_Page(Zend_Pdf_Page $page);

  1. Create new page with a specified pagesize. If $factory is null then it will be created and page must be attached to the document to be

included into output.

new Zend_Pdf_Page(string $pagesize, Zend_Pdf_ElementFactory_Interface $factory = null);

  1. Create new page with a specified pagesize (in default user space units). If $factory is null then it will be created and page must be attached to the document to be

included into output.

new Zend_Pdf_Page(numeric $width, numeric $height, Zend_Pdf_ElementFactory_Interface $factory = null);

Parameters
NameTypeDescription
$param1mixed
$param2mixed
$param3mixed
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodprotected_addProcSet(string $procSetName) : void

Add procedureSet to the Page description

Parameters
NameTypeDescription
$procSetNamestring
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
NameTypeDescription
$typestring
$resource\Zend_Pdf_Resource
Returns
TypeDescription
string
methodpublicattachAnnotation(\Zend_Pdf_Annotation $annotation) : \Zend_Pdf_Page

Parameters
NameTypeDescription
$annotation\Zend_Pdf_Annotation
Returns
TypeDescription
\Zend_Pdf_Page
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
NameTypeDescription
$xfloat
$yfloat
$radiusfloat
$startAnglefloat
$endAnglefloat
Returns
TypeDescription
\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
NameTypeDescription
$x1float
$y1float
$x2float
$y2float
$startAnglefloat
$endAnglefloat
Returns
TypeDescription
\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
NameTypeDescription
$xarray
  • array of float (the X co-ordinates of the vertices)
$yarray
  • array of float (the Y co-ordinates of the vertices)
$fillMethodinteger
Returns
TypeDescription
\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
NameTypeDescription
$x1float
$y1float
$x2float
$y2float
Returns
TypeDescription
\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
NameTypeDescription
$canvas\Zend_Pdf_Canvas_Interface
$x1float
$y1float
$x2float
$y2float
Returns
TypeDescription
\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
NameTypeDescription
$xfloat
$yfloat
$radiusfloat
$param4mixed
$param5mixed
$param6mixed
Returns
TypeDescription
\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
NameTypeDescription
$x1float
$y1float
$x2float
$y2float
$param5mixed
$param6mixed
$param7mixed
Returns
TypeDescription
\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
NameTypeDescription
$image\Zend_Pdf_Image
$x1float
$y1float
$x2float
$y2float
Returns
TypeDescription
\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
NameTypeDescription
$x1float
$y1float
$x2float
$y2float
Returns
TypeDescription
\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
NameTypeDescription
$xarray
  • array of float (the X co-ordinates of the vertices)
$yarray
  • array of float (the Y co-ordinates of the vertices)
$fillTypeinteger
$fillMethodinteger
Returns
TypeDescription
\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
NameTypeDescription
$x1float
$y1float
$x2float
$y2float
$fillTypeinteger
Returns
TypeDescription
\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
NameTypeDescription
$x1float
$y1float
$x2float
$y2float
$radiusinteger | array
$fillTypeinteger
Returns
TypeDescription
\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
NameTypeDescription
$textstring
$xfloat
$yfloat
$charEncodingstring

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

Returns
TypeDescription
\Zend_Pdf_Canvas_Interface
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicextractFont( $fontName) : \Zend_Pdf_Resource_Font_Extracted | null

Extract font attached to the page by specific font name

$fontName should be specified in UTF-8 encoding

Parameters
NameTypeDescription
$fontName
Returns
TypeDescription
\Zend_Pdf_Resource_Font_Extracted | null
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicextractFonts() : array

Extract fonts attached to the page

returns array of Zend_Pdf_Resource_Font_Extracted objects

Returns
TypeDescription
array
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicflush() : void

Dump current drawing instructions into the content stream.

Throws
ExceptionDescription
\Zend_Pdf_Exception
Details
Todo
Don't forget to close all current graphics operations (like path drawing)  
methodpublicgetFont() : \Zend_Pdf_Resource_Font
inherited

Get current font.

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

Get current font size

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

Return the height of this page in points.

Returns
TypeDescription
float
methodpublicgetStyle() : \Zend_Pdf_Style
inherited

Return the style, applied to the page.

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

Return the width of this page in points.

Returns
TypeDescription
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
NameTypeDescription
$datastring
$procSetstring

(optional) Name of ProcSet to add.

Returns
TypeDescription
\Zend_Pdf_Canvas_Interface
methodpublicrender(\Zend_Pdf_ElementFactory_Interface $objFactory) : void

Prepare page to be rendered into PDF.

Parameters
NameTypeDescription
$objFactory\Zend_Pdf_ElementFactory_Interface
Throws
ExceptionDescription
\Zend_Pdf_Exception
Details
Todo
Don't forget to close all current graphics operations (like path drawing)  
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
TypeDescription
\Zend_Pdf_Canvas_Interface
Throws
ExceptionDescription
\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
NameTypeDescription
$xfloat
  • the X co-ordinate of rotation point
$yfloat
  • the Y co-ordinate of rotation point
$anglefloat
  • rotation angle
Returns
TypeDescription
\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
TypeDescription
\Zend_Pdf_Canvas_Interface
Throws
ExceptionDescription
\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
NameTypeDescription
$xScalefloat
  • X dimention scale factor
$yScalefloat
  • Y dimention scale factor
Returns
TypeDescription
\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
NameTypeDescription
$alphafloat
$modestring
Returns
TypeDescription
\Zend_Pdf_Canvas_Interface
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicsetFillColor(\Zend_Pdf_Color $color) : \Zend_Pdf_Canvas_Interface
inherited

Set fill color.

Inherited from: \Zend_Pdf_Canvas_Abstract::setFillColor()
Parameters
NameTypeDescription
$color\Zend_Pdf_Color
Returns
TypeDescription
\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
NameTypeDescription
$font\Zend_Pdf_Resource_Font
$fontSizefloat
Returns
TypeDescription
\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
NameTypeDescription
$color\Zend_Pdf_Color
Returns
TypeDescription
\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
NameTypeDescription
$patternmixed
$phasearray
Returns
TypeDescription
\Zend_Pdf_Canvas_Interface
methodpublicsetLineWidth(float $width) : \Zend_Pdf_Canvas_Interface
inherited

Set line width.

Inherited from: \Zend_Pdf_Canvas_Abstract::setLineWidth()
Parameters
NameTypeDescription
$widthfloat
Returns
TypeDescription
\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
NameTypeDescription
$style\Zend_Pdf_Style
Returns
TypeDescription
\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
NameTypeDescription
$xfloat
  • the X co-ordinate of axis skew point
$yfloat
  • the Y co-ordinate of axis skew point
$xAnglefloat
  • X axis skew angle
$yAnglefloat
  • Y axis skew angle
Returns
TypeDescription
\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
NameTypeDescription
$xShiftfloat
  • X coordinate shift
$yShiftfloat
  • Y coordinate shift
Returns
TypeDescription
\Zend_Pdf_Canvas_Interface
Documentation was generated by phpDocumentor 2.0.0a12.