Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Pdf_Page Class Reference

Public Member Functions

 __construct ($param1, $param2=null, $param3=null)
 Object constructor.
 
 getResources ()
 Returns dictionaries of used resources.
 
 getContents ()
 Get drawing instructions stream.
 
 getHeight ()
 Return the height of this page in points.
 
 getWidth ()
 Return the width of this page in points.
 
 __clone ()
 Clone page, extract it and dependent objects from the current document, so it can be used within other docs.
 
 clonePage ($factory, &$processed)
 Clone page, extract it and dependent objects from the current document, so it can be used within other docs.
 
 getPageDictionary ()
 Retrive PDF file reference to the page.
 
 flush ()
 Dump current drawing instructions into the content stream.
 
 render (Zend_Pdf_ElementFactory_Interface $objFactory)
 Prepare page to be rendered into PDF.
 
 extractResources ()
 Extract resources attached to the page.
 
 extractFonts ()
 Extract fonts attached to the page.
 
 extractFont ($fontName)
 Extract font attached to the page by specific font name.
 
 attachAnnotation (Zend_Pdf_Annotation $annotation)
 
- Public Member Functions inherited from Zend_Pdf_Canvas_Abstract
 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.
 
 restoreGS ()
 Restore the graphics state that was saved with the last call to saveGS().
 
 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.
 

Public Attributes

const SIZE_A4 = '595:842:'
 Size representing an A4 page in portrait (tall) orientation.
 
const SIZE_A4_LANDSCAPE = '842:595:'
 Size representing an A4 page in landscape (wide) orientation.
 
const SIZE_LETTER = '612:792:'
 Size representing a US Letter page in portrait (tall) orientation.
 
const SIZE_LETTER_LANDSCAPE = '792:612:'
 Size representing a US Letter page in landscape (wide) orientation.
 
const SHAPE_DRAW_STROKE = 0
 Stroke the path only.
 
const SHAPE_DRAW_FILL = 1
 Fill the path only.
 
const SHAPE_DRAW_FILL_AND_STROKE = 2
 Fill and stroke the path.
 
const FILL_METHOD_NON_ZERO_WINDING = 0
 Fill the path using the non-zero winding rule.
 
const FILL_METHOD_EVEN_ODD = 1
 Fill the path using the even-odd rule.
 
const LINE_DASHING_SOLID = 0
 Solid line dash.
 

Protected Member Functions

 _attachResource ($type, Zend_Pdf_Resource $resource)
 Attach resource to the canvas.
 
 _addProcSet ($procSetName)
 Add procedureSet to the Page description.
 
- Protected Member Functions inherited from Zend_Pdf_Canvas_Abstract
 _addProcSet ($procSetName)
 Add procedureSet to the Page description.
 
 _attachResource ($type, Zend_Pdf_Resource $resource)
 Attach resource to the canvas.
 

Protected Attributes

 $_dictionary
 
 $_objFactory = null
 
 $_attached
 
 $_safeGS
 
- Protected Attributes inherited from Zend_Pdf_Canvas_Abstract
 $_contents = ''
 
 $_font = null
 
 $_fontSize
 
 $_style = null
 
 $_saveCount = 0
 

Constructor & Destructor Documentation

__construct (   $param1,
  $param2 = null,
  $param3 = null 
)

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

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

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

4. 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
mixed$param1
mixed$param2
mixed$param3
Exceptions
Zend_Pdf_Exception

New page created. That's users App responsibility to track GS changes

Todo:
support of user defined pagesize notations, like: "210x297mm", "595x842", "8.5x11in", "612x792"
Todo:
support of pagesize recalculation to "default user space units"

New page created. That's users App responsibility to track GS changes

Member Function Documentation

__clone ( )

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

_addProcSet (   $procSetName)
protected

Add procedureSet to the Page description.

Parameters
string$procSetName
_attachResource (   $type,
Zend_Pdf_Resource  $resource 
)
protected

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
string$type
Zend_Pdf_Resource$resource
Returns
string
attachAnnotation ( Zend_Pdf_Annotation  $annotation)
Parameters
Zend_Pdf_Annotation$annotation
Returns
Zend_Pdf_Page
clonePage (   $factory,
$processed 
)

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

extractFont (   $fontName)

Extract font attached to the page by specific font name.

$fontName should be specified in UTF-8 encoding

Returns
Zend_Pdf_Resource_Font_Extracted|null
Exceptions
Zend_Pdf_Exception
extractFonts ( )

Extract fonts attached to the page.

returns array of Zend_Pdf_Resource_Font_Extracted objects

Returns
array
Exceptions
Zend_Pdf_Exception
extractResources ( )

Extract resources attached to the page.

This method is not intended to be used in userland, but helps to optimize some document wide operations

returns array of Zend_Pdf_Element_Dictionary objects

flush ( )

Dump current drawing instructions into the content stream.

Todo:
Don't forget to close all current graphics operations (like path drawing)
Exceptions
Zend_Pdf_Exception

It's a stream object. Prepare Contents page attribute for update.

Page already has some content which is not treated as safe.

Add save/restore GS operators

getContents ( )

Get drawing instructions stream.

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

Todo:
implementation

Implements Zend_Pdf_Canvas_Interface.

getHeight ( )

Return the height of this page in points.

Returns
float

Implements Zend_Pdf_Canvas_Interface.

getPageDictionary ( )

Retrive PDF file reference to the page.

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'

Implements Zend_Pdf_Canvas_Interface.

getWidth ( )

Return the width of this page in points.

Returns
float

Implements Zend_Pdf_Canvas_Interface.

render ( Zend_Pdf_ElementFactory_Interface  $objFactory)

Prepare page to be rendered into PDF.

Todo:
Don't forget to close all current graphics operations (like path drawing)
Parameters
Zend_Pdf_ElementFactory_Interface$objFactory
Exceptions
Zend_Pdf_Exception

Member Data Documentation

$_attached
protected
$_dictionary
protected
$_objFactory = null
protected
$_safeGS
protected
const FILL_METHOD_EVEN_ODD = 1

Fill the path using the even-odd rule.

const FILL_METHOD_NON_ZERO_WINDING = 0

Fill the path using the non-zero winding rule.

const LINE_DASHING_SOLID = 0

Solid line dash.

const SHAPE_DRAW_FILL = 1

Fill the path only.

Do not stroke.

const SHAPE_DRAW_FILL_AND_STROKE = 2

Fill and stroke the path.

const SHAPE_DRAW_STROKE = 0

Stroke the path only.

Do not fill.

const SIZE_A4 = '595:842:'

Size representing an A4 page in portrait (tall) orientation.

const SIZE_A4_LANDSCAPE = '842:595:'

Size representing an A4 page in landscape (wide) orientation.

const SIZE_LETTER = '612:792:'

Size representing a US Letter page in portrait (tall) orientation.

const SIZE_LETTER_LANDSCAPE = '792:612:'

Size representing a US Letter page in landscape (wide) orientation.