API Documentation

Pdf/Page.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Pdf
version
$Id: Page.php 20470 2010-01-21 16:10:42Z alexander $
Classes
Zend_Pdf_Page

Description

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.

Zend_Pdf_Page

copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Pdf
Constants
SIZE_A4
SIZE_A4_LANDSCAPE
SIZE_LETTER
SIZE_LETTER_LANDSCAPE
SHAPE_DRAW_STROKE
SHAPE_DRAW_FILL
SHAPE_DRAW_FILL_AND_STROKE
FILL_METHOD_NON_ZERO_WINDING
FILL_METHOD_EVEN_ODD
LINE_DASHING_SOLID
Properties
$_pageDictionary
$_objFactory
$_attached
$_contents
$_style
$_saveCount
$_safeGS
$_font
$_fontSize
Methods
__construct
__clone
_attachResource
_addProcSet
getPageDictionary
flush
render
setFillColor
setLineColor
setLineWidth
setLineDashingPattern
setFont
setStyle
setAlpha
getFont
extractResources
extractFonts
extractFont
getFontSize
getStyle
saveGS
restoreGS
clipCircle
clipEllipse
clipPolygon
clipRectangle
drawContentStream
drawCircle
drawEllipse
drawImage
drawLayoutBox
drawLine
drawPolygon
drawRectangle
drawRoundedRectangle
drawText
attachAnnotation
getHeight
getWidth
pathClose
pathLine
pathMove
rawWrite
rotate
scale
translate
skew

Description

PDF Page

Constants

SIZE_A4

 SIZE_A4 = '595:842:'

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

Details

value
595:842:

SIZE_A4_LANDSCAPE

 SIZE_A4_LANDSCAPE = '842:595:'

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

Details

value
842:595:

SIZE_LETTER

 SIZE_LETTER = '612:792:'

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

Details

value
612:792:

SIZE_LETTER_LANDSCAPE

 SIZE_LETTER_LANDSCAPE = '792:612:'

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

Details

value
792:612:

SHAPE_DRAW_STROKE

 SHAPE_DRAW_STROKE = '0'

Stroke the path only. Do not fill.

Details

value
0

SHAPE_DRAW_FILL

 SHAPE_DRAW_FILL = '1'

Fill the path only. Do not stroke.

Details

value
1

SHAPE_DRAW_FILL_AND_STROKE

 SHAPE_DRAW_FILL_AND_STROKE = '2'

Fill and stroke the path.

Details

value
2

FILL_METHOD_NON_ZERO_WINDING

 FILL_METHOD_NON_ZERO_WINDING = '0'

Fill the path using the non-zero winding rule.

Details

value
0

FILL_METHOD_EVEN_ODD

 FILL_METHOD_EVEN_ODD = '1'

Fill the path using the even-odd rule.

Details

value
1

LINE_DASHING_SOLID

 LINE_DASHING_SOLID = '0'

Solid line dash.

Details

value
0

Properties

$_attached

boolean $_attached = ''

Flag which signals, that page is created separately from any PDF document or attached to anyone.

Details

$_attached
boolean
visibility
protected
default
final
false
static
false

$_contents

string $_contents = ''

Stream of the drawing instructions.

Details

$_contents
string
visibility
protected
default
final
false
static
false

$_font

Zend_Pdf_Resource_Font $_font = 'null'

Current font

Details

$_font
Zend_Pdf_Resource_Font
visibility
protected
default
null
final
false
static
false

$_fontSize

float $_fontSize = ''

Current font size

Details

$_fontSize
float
visibility
protected
default
final
false
static
false

$_objFactory

Zend_Pdf_ElementFactory_Interface $_objFactory = 'null'

PDF objects factory.

Details

$_objFactory
Zend_Pdf_ElementFactory_Interface
visibility
protected
default
null
final
false
static
false

$_pageDictionary

Zend_Pdf_Element_Reference|Zend_Pdf_Element_Object $_pageDictionary = ''

Page dictionary (refers to an inderect Zend_Pdf_Element_Dictionary object).

Details

$_pageDictionary
Zend_Pdf_Element_Reference|Zend_Pdf_Element_Object
visibility
protected
default
final
false
static
false

$_safeGS

boolean $_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

$_safeGS
boolean
visibility
protected
default
final
false
static
false

$_saveCount

integer $_saveCount = '0'

Counter for the "Save" operations

Details

$_saveCount
integer
visibility
protected
default
0
final
false
static
false

$_style

Zend_Pdf_Style $_style = 'null'

Current style

Details

$_style
Zend_Pdf_Style
visibility
protected
default
null
final
false
static
false

Methods

__clone

__clone( ) :

Clone operator

Details
visibility
public
final
false
static
false
throws

__construct

__construct( mixed $param1, mixed $param2 = null, mixed $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);

  1. Clone 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);

Arguments
$param1
mixed
$param2
mixed
$param3
mixed
Details
visibility
public
final
false
static
false
throws

_addProcSet

_addProcSet( string $procSetName ) :

Add procedureSet to the Page description

Arguments
$procSetName
string
Details
visibility
protected
final
false
static
false

_attachResource

_attachResource( string $type, Zend_Pdf_Resource $resource ) : string

Attach resource to the page

Arguments
$type
string
$resource
Zend_Pdf_Resource
Output
string
Details
visibility
protected
final
false
static
false

attachAnnotation

attachAnnotation( Zend_Pdf_Annotation $annotation ) : Zend_Pdf_Page

Arguments
$annotation
Zend_Pdf_Annotation
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

clipCircle

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

Intersect current clipping area with a circle.

Arguments
$x
float
$y
float
$radius
float
$startAngle
float
$endAngle
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

clipEllipse

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

Intersect current clipping area with a polygon.

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

Arguments
$x1
float
$y1
float
$x2
float
$y2
float
$startAngle
float
$endAngle
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
todo
process special cases with $x2-$x1 == 0 or $y2-$y1 == 0

clipPolygon

clipPolygon( array $x, array $y, integer $fillMethod = Zend_Pdf_Page ) : Zend_Pdf_Page

Intersect current clipping area with a polygon.

Arguments
$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
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

clipRectangle

clipRectangle( float $x1, float $y1, float $x2, float $y2 ) : Zend_Pdf_Page

Intersect current clipping area with a rectangle.

Arguments
$x1
float
$y1
float
$x2
float
$y2
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawCircle

drawCircle( float $x, float $y, float $radius, mixed $param4 = null, mixed $param5 = null, mixed $param6 = null ) : Zend_Pdf_Page

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, 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.

Arguments
$x
float
$y
float
$radius
float
$param4
mixed
$param5
mixed
$param6
mixed
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawContentStream

drawContentStream( ZPdfContentStream $cs, float $x1, float $y1, float $x2, float $y2 ) : Zend_Pdf_Page

Draw a Zend_Pdf_ContentStream at the specified position on the page

Arguments
$cs
ZPdfContentStream
$x1
float
$y1
float
$x2
float
$y2
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawEllipse

drawEllipse( float $x1, float $y1, float $x2, float $y2, mixed $param5 = null, mixed $param6 = null, mixed $param7 = null ) : Zend_Pdf_Page

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

Arguments
$x1
float
$y1
float
$x2
float
$y2
float
$param5
mixed
$param6
mixed
$param7
mixed
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
todo
process special cases with $x2-$x1 == 0 or $y2-$y1 == 0

drawImage

drawImage( Zend_Pdf_Image $image, float $x1, float $y1, float $x2, float $y2 ) : Zend_Pdf_Page

Draw an image at the specified position on the page.

Arguments
$image
Zend_Pdf_Image
$x1
float
$y1
float
$x2
float
$y2
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawLayoutBox

drawLayoutBox( Zend_Pdf_Element_LayoutBox $box, float $x, float $y ) : Zend_Pdf_Page

Draw a LayoutBox at the specified position on the page.

Arguments
$box
Zend_Pdf_Element_LayoutBox
$x
float
$y
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawLine

drawLine( float $x1, float $y1, float $x2, float $y2 ) : Zend_Pdf_Page

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

Arguments
$x1
float
$y1
float
$x2
float
$y2
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawPolygon

drawPolygon( array $x, array $y, integer $fillType = Zend_Pdf_Page, integer $fillMethod = Zend_Pdf_Page ) : Zend_Pdf_Page

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)

Arguments
$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
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawRectangle

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

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

Arguments
$x1
float
$y1
float
$x2
float
$y2
float
$fillType
integer
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawRoundedRectangle

drawRoundedRectangle( float $x1, float $y1, float $x2, float $y2, integer|array $radius, integer $fillType = Zend_Pdf_Page ) : Zend_Pdf_Page

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

Arguments
$x1
float
$y1
float
$x2
float
$y2
float
$radius
integerarray
$fillType
integer
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

drawText

drawText( string $text, float $x, float $y, string $charEncoding ) : Zend_Pdf_Page

Draw a line of text at the specified position.

Arguments
$text
string
$x
float
$y
float
$charEncoding
string
(optional) Character encoding of source text. Defaults to current locale.
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
throws

extractFont

extractFont(  $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

Arguments
$fontName
Details
visibility
public
final
false
static
false
throws

extractFonts

extractFonts( ) : array

Extract fonts attached to the page

returns array of Zend_Pdf_Resource_Font_Extracted objects

Output
array
Details
visibility
public
final
false
static
false
throws

extractResources

extractResources( ) : array

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

Output
array
Details
visibility
public
final
false
static
false
internal

flush

flush( ) :

Dump current drawing instructions into the content stream.

Details
visibility
public
final
false
static
false
throws
todo
Don't forget to close all current graphics operations (like path drawing)

getFont

getFont( ) : Zend_Pdf_Resource_Font

Get current font.

Output
Zend_Pdf_Resource_Font
$font
Details
visibility
public
final
false
static
false

getFontSize

getFontSize( ) : float

Get current font size

Output
float
$fontSize
Details
visibility
public
final
false
static
false

getHeight

getHeight( ) : float

Return the height of this page in points.

Output
float
Details
visibility
public
final
false
static
false

getPageDictionary

getPageDictionary( ) : Zend_Pdf_Element_Dictionary

Retrive PDF file reference to the page

Details
visibility
public
final
false
static
false
internal

getStyle

getStyle( ) : Zend_Pdf_Style|null

Return the style, applied to the page.

Output
Zend_Pdf_Style|null
Details
visibility
public
final
false
static
false

getWidth

getWidth( ) : float

Return the width of this page in points.

Output
float
Details
visibility
public
final
false
static
false

pathClose

pathClose( ) : Zend_Pdf_Page

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

Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
throws
- if a path hasn't been started with pathMove()

pathLine

pathLine( float $x, float $y ) : Zend_Pdf_Page

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

Arguments
$x
float
- the X co-ordinate to move to
$y
float
- the Y co-ordinate to move to
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

pathMove

pathMove( float $x, float $y ) : Zend_Pdf_Page

Start a new path at the specified position. If a path has already been started, move the cursor without drawing a line.

Arguments
$x
float
- the X co-ordinate to move to
$y
float
- the Y co-ordinate to move to
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

rawWrite

rawWrite( string $data, string $procSet = null ) : Zend_Pdf_Page

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.

Arguments
$data
string
$procSet
string
(optional) Name of ProcSet to add.
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

render

render( Zend_Pdf_ElementFactory_Interface $objFactory ) :

Prepare page to be rendered into PDF.

Arguments
$objFactory
Zend_Pdf_ElementFactory_Interface
Details
visibility
public
final
false
static
false
throws
todo
Don't forget to close all current graphics operations (like path drawing)

restoreGS

restoreGS( ) : Zend_Pdf_Page

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

Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
throws
- if there is no previously saved state

rotate

rotate( float $x, float $y, float $angle ) : Zend_Pdf_Page

Rotate the page.

Arguments
$x
float
- the X co-ordinate of rotation point
$y
float
- the Y co-ordinate of rotation point
$angle
float
- rotation angle
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

saveGS

saveGS( ) : Zend_Pdf_Page

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.

Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
throws
- if a save is performed with an open path
todo
check for the open paths

scale

scale( float $xScale, float $yScale ) : Zend_Pdf_Page

Scale coordination system.

Arguments
$xScale
float
- X dimention scale factor
$yScale
float
- Y dimention scale factor
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

setAlpha

setAlpha( float $alpha, string $mode = Normal ) : Zend_Pdf_Page

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

Arguments
$alpha
float
$mode
string
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
throws

setFillColor

setFillColor( Zend_Pdf_Color $color ) : Zend_Pdf_Page

Set fill color.

Arguments
$color
Zend_Pdf_Color
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

setFont

setFont( Zend_Pdf_Resource_Font $font, float $fontSize ) : Zend_Pdf_Page

Set current font.

Arguments
$font
Zend_Pdf_Resource_Font
$fontSize
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

setLineColor

setLineColor( Zend_Pdf_Color $color ) : Zend_Pdf_Page

Set line color.

Arguments
$color
Zend_Pdf_Color
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

setLineDashingPattern

setLineDashingPattern( array $pattern, array $phase = 0 ) : Zend_Pdf_Page

Set line dashing pattern

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

Arguments
$pattern
array
$phase
array
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

setLineWidth

setLineWidth( float $width ) : Zend_Pdf_Page

Set line width.

Arguments
$width
float
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

setStyle

setStyle( Zend_Pdf_Style $style ) : Zend_Pdf_Page

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

Arguments
$style
Zend_Pdf_Style
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

skew

skew( float $x, float $y, float $xAngle, float $yAngle ) : Zend_Pdf_Page

Translate coordination system.

Arguments
$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
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

translate

translate( float $xShift, float $yShift ) : Zend_Pdf_Page

Translate coordination system.

Arguments
$xShift
float
- X coordinate shift
$yShift
float
- Y coordinate shift
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.