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

Public Member Functions

 save ($filename, $updateOnly=false)
 Render PDF document and save it.
 
 __construct ($source=null, $revision=null, $load=false)
 Creates or loads PDF document.
 
 revisions ()
 Retrive number of revisions.
 
 rollback ($steps)
 Rollback document $steps number of revisions.
 
 newPage ($param1, $param2=null)
 Create page object, attached to the PDF document.
 
 getMetadata ()
 Return the document-level Metadata or null Metadata stream is not presented.
 
 setMetadata ($metadata)
 Sets the document-level Metadata (mast be valid XMP document)
 
 getJavaScript ()
 Return the document-level JavaScript or null if there is no JavaScript for this document.
 
 getOpenAction ()
 Get open Action Returns Zend_Pdf_Target (Zend_Pdf_Destination or Zend_Pdf_Action object)
 
 setOpenAction (Zend_Pdf_Target $openAction=null)
 Set open Action which is actually Zend_Pdf_Destination or Zend_Pdf_Action object.
 
 getNamedDestinations ()
 Return an associative array containing all the named destinations (or GoTo actions) in the PDF.
 
 getNamedDestination ($name)
 Return specified named destination.
 
 setNamedDestination ($name, $destination=null)
 Set specified named destination.
 
 resolveDestination (Zend_Pdf_Destination $destination, $refreshPageCollectionHashes=true)
 Resolve destination.
 
 extractFonts ()
 Extract fonts attached to the document.
 
 extractFont ($fontName)
 Extract font attached to the page by specific font name.
 
 render ($newSegmentOnly=false, $outputStream=null)
 Render the completed PDF to a string.
 
 setJavaScript ($javascript)
 Set the document-level JavaScript.
 

Static Public Member Functions

static getMemoryManager ()
 Request used memory manager.
 
static setMemoryManager (Zend_Memory_Manager $memoryManager)
 Set user defined memory manager.
 
static parse (&$source=null, $revision=null)
 Create new PDF document from a $source string.
 
static load ($source=null, $revision=null)
 Load PDF document from a file.
 
static pdfDate ($timestamp=null)
 Convert date to PDF format (it's close to ASN.1 (Abstract Syntax Notation One) defined in ISO/IEC 8824).
 

Public Attributes

const PDF_VERSION = '1.4'
 Version number of generated PDF documents.
 
const PDF_HEADER = "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n"
 PDF file header.
 
 $pages = array()
 
 $properties = array()
 
 $outlines = array()
 

Protected Member Functions

 _loadPages (Zend_Pdf_Element_Reference $pages, $attributes=array())
 Load pages recursively.
 
 _loadNamedDestinations (Zend_Pdf_Element_Reference $root, $pdfHeaderVersion)
 Load named destinations recursively.
 
 _loadOutlines (Zend_Pdf_Element_Reference $root)
 Load outlines recursively.
 
 _dumpPages ()
 Orginize pages to tha pages tree structure.
 
 _dumpNamedDestinations ()
 Dump named destinations.
 
 _dumpOutlines ()
 Dump outlines recursively.
 
 _refreshPagesHash ()
 Refresh page collection hashes.
 
 _cleanUpAction (Zend_Pdf_Action $action, $refreshPageCollectionHashes=true)
 Walk through action and its chained actions tree and remove nodes if they are GoTo actions with an unresolved target.
 

Protected Attributes

 $_originalProperties = array()
 
 $_javaScript = null
 
 $_namedTargets = array()
 
 $_originalOutlines = array()
 
 $_originalOpenOutlinesCount = 0
 
 $_trailer = null
 
 $_objFactory = null
 
 $_parser
 
 $_isNewDocument = true
 
 $_pageReferences = null
 
 $_pageNumbers = null
 

Static Protected Attributes

static $_memoryManager = null
 
static $_inheritableAttributes = array('Resources', 'MediaBox', 'CropBox', 'Rotate')
 

Constructor & Destructor Documentation

__construct (   $source = null,
  $revision = null,
  $load = false 
)

Creates or loads PDF document.

If $source is null, then it creates a new document.

If $source is a string and $load is false, then it loads document from a binary string.

If $source is a string and $load is true, then it loads document from a file.

$revision used to roll back document to specified version (0 - current version, 1 - previous version, 2 - ...)

Parameters
string$source- PDF file to load
integer$revision
Exceptions
Zend_Pdf_Exception
Returns
Zend_Pdf

Document id

Document catalog indirect object.

Pages container

Member Function Documentation

_cleanUpAction ( Zend_Pdf_Action  $action,
  $refreshPageCollectionHashes = true 
)
protected

Walk through action and its chained actions tree and remove nodes if they are GoTo actions with an unresolved target.

Returns null if root node is deleted or updated action overwise.

Todo:
Give appropriate name and make method public
Parameters
Zend_Pdf_Action$action
boolean$refreshPagesHashRefresh page collection hashes before processing
Returns
Zend_Pdf_Action|null
_dumpNamedDestinations ( )
protected

Dump named destinations.

Todo:
Create a balanced tree instead of plain structure.
_dumpOutlines ( )
protected

Dump outlines recursively.

_dumpPages ( )
protected

Orginize pages to tha pages tree structure.

Todo:

atomatically attach page to the document, if it's not done yet.

check, that page is attached to the current document

Todo:
Dump pages as a balanced tree instead of a plain set.
_loadNamedDestinations ( Zend_Pdf_Element_Reference  $root,
  $pdfHeaderVersion 
)
protected

Load named destinations recursively.

Parameters
Zend_Pdf_Element_Reference$rootDocument catalog entry
string$pdfHeaderVersion
Exceptions
Zend_Pdf_Exception
_loadOutlines ( Zend_Pdf_Element_Reference  $root)
protected

Load outlines recursively.

Parameters
Zend_Pdf_Element_Reference$rootDocument catalog entry
_loadPages ( Zend_Pdf_Element_Reference  $pages,
  $attributes = array() 
)
protected

Load pages recursively.

Parameters
Zend_Pdf_Element_Reference$pages
array | null$attributes

Important note. If any attribute or dependant object is an indirect object, then it's still shared between pages.

_refreshPagesHash ( )
protected

Refresh page collection hashes.

Returns
Zend_Pdf
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 document.

returns array of Zend_Pdf_Resource_Font_Extracted objects

Returns
array
Exceptions
Zend_Pdf_Exception
getJavaScript ( )

Return the document-level JavaScript or null if there is no JavaScript for this document.

Returns
string
static getMemoryManager ( )
static

Request used memory manager.

Returns
Zend_Memory_Manager
getMetadata ( )

Return the document-level Metadata or null Metadata stream is not presented.

Returns
string
getNamedDestination (   $name)

Return specified named destination.

Parameters
string$name
Returns
Zend_Pdf_Destination_Explicit|Zend_Pdf_Action_GoTo
getNamedDestinations ( )

Return an associative array containing all the named destinations (or GoTo actions) in the PDF.

Named targets can be used to reference from outside the PDF, ex: 'http://www.something.com/mydocument.pdf#MyAction'

Returns
array
getOpenAction ( )

Get open Action Returns Zend_Pdf_Target (Zend_Pdf_Destination or Zend_Pdf_Action object)

Returns
Zend_Pdf_Target
static load (   $source = null,
  $revision = null 
)
static

Load PDF document from a file.

Parameters
string$source
integer$revision
Returns
Zend_Pdf
newPage (   $param1,
  $param2 = null 
)

Create page object, attached to the PDF document.

Method signatures:

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

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

Parameters
mixed$param1
mixed$param2
Returns
Zend_Pdf_Page
static parse ( $source = null,
  $revision = null 
)
static

Create new PDF document from a $source string.

Parameters
string$source
integer$revision
Returns
Zend_Pdf
static pdfDate (   $timestamp = null)
static

Convert date to PDF format (it's close to ASN.1 (Abstract Syntax Notation One) defined in ISO/IEC 8824).

Todo:
This really isn't the best location for this method. It should probably actually exist as Zend_Pdf_Element_Date or something like that.
Todo:
Address the following E_STRICT issue: PHP Strict Standards: date(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
Parameters
integer$timestamp(optional) If omitted, uses the current time.
Returns
string
render (   $newSegmentOnly = false,
  $outputStream = null 
)

Render the completed PDF to a string.

If $newSegmentOnly is true and it's not a new document, then only appended part of PDF is returned.

Parameters
boolean$newSegmentOnly
resource$outputStream
Returns
string
Exceptions
Zend_Pdf_Exception
resolveDestination ( Zend_Pdf_Destination  $destination,
  $refreshPageCollectionHashes = true 
)

Resolve destination.

Returns Zend_Pdf_Page page object or null if destination is not found within PDF document.

Parameters
Zend_Pdf_Destination$destinationDestination to resolve
boolean$refreshPagesHashRefresh page collection hashes before processing
Returns
Zend_Pdf_Page|null
Exceptions
Zend_Pdf_Exception
revisions ( )

Retrive number of revisions.

Returns
integer
rollback (   $steps)

Rollback document $steps number of revisions.

This method must be invoked before any changes, applied to the document. Otherwise behavior is undefined.

Parameters
integer$steps
save (   $filename,
  $updateOnly = false 
)

Render PDF document and save it.

If $updateOnly is true and it's not a new document, then it only appends new section to the end of file.

Parameters
string$filename
boolean$updateOnly
Exceptions
Zend_Pdf_Exception
setJavaScript (   $javascript)

Set the document-level JavaScript.

Parameters
string$javascript
static setMemoryManager ( Zend_Memory_Manager  $memoryManager)
static

Set user defined memory manager.

Parameters
Zend_Memory_Manager$memoryManager
setMetadata (   $metadata)

Sets the document-level Metadata (mast be valid XMP document)

Parameters
string$metadata
setNamedDestination (   $name,
  $destination = null 
)

Set specified named destination.

Parameters
string$name
Zend_Pdf_Destination_Explicit | Zend_Pdf_Action_GoTo$target
setOpenAction ( Zend_Pdf_Target  $openAction = null)

Set open Action which is actually Zend_Pdf_Destination or Zend_Pdf_Action object.

Parameters
Zend_Pdf_Target$openAction
Returns
Zend_Pdf

Member Data Documentation

$_inheritableAttributes = array('Resources', 'MediaBox', 'CropBox', 'Rotate')
staticprotected
$_isNewDocument = true
protected
$_javaScript = null
protected
$_memoryManager = null
staticprotected
$_namedTargets = array()
protected
$_objFactory = null
protected
$_originalOpenOutlinesCount = 0
protected
$_originalOutlines = array()
protected
$_originalProperties = array()
protected
$_pageNumbers = null
protected
$_pageReferences = null
protected
$_parser
protected
$_trailer = null
protected
$outlines = array()
$pages = array()
$properties = array()
const PDF_HEADER = "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n"

PDF file header.

const PDF_VERSION = '1.4'

Version number of generated PDF documents.