Pdf.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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Pdf  
Version
$Id$  

\Zend_Pdf

Package: Zend_Pdf
General entity which describes PDF document.
It implements document abstraction with a document level operations. Class is used to create new PDF document or load existing document. See details in a class constructor description Class agregates document level properties and entities (pages, bookmarks, document level actions, attachments, form object, etc)
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  PDF_VERSION = '1.4'
Version number of generated PDF documents.
>VConstant  PDF_HEADER = "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n"
PDF file header.

Properties

>VPropertyprotectedarray $_inheritableAttributes = array('Resources', 'MediaBox', 'CropBox', 'Rotate')
static
List of inheritable attributesfor pages tree
Default valuearray('Resources', 'MediaBox', 'CropBox', 'Rotate')Details
Type
array
>VPropertyprotectedboolean $_isNewDocument = true
True if the object is a newly created PDF document (affects save() method behavior) False otherwise
Default valuetrueDetails
Type
boolean
>VPropertyprotectedstring $_javaScript = null
Document level javascript
Default valuenullDetails
Type
string
>VPropertyprotected\Zend_Memory_Manager|null $_memoryManager = null
static
Memory manager for stream objects
Default valuenullDetails
Type
\Zend_Memory_Manager | null
>VPropertyprotectedarray $_namedTargets = array()
Document named destinations or "GoTo.
.." actions, used to refer document parts from outside PDF
Default valuearray()Details
Type
array
>VPropertyprotected\Zend_Pdf_ElementFactory_Interface $_objFactory = null
PDF objects factory.
Default valuenullDetails
Type
\Zend_Pdf_ElementFactory_Interface
>VPropertyprotectedinteger $_originalOpenOutlinesCount = 0
Original document outlines open elements count Used to track outlines update
Default value0Details
Type
integer
>VPropertyprotectedarray $_originalOutlines = array()
Original document outlines list Used to track outlines update
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_originalProperties = array()
Original properties set.
Used for tracking properties changes
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_pageNumbers = null
Pages collection hash: => Zend_Pdf_Page
Default valuenullDetails
Type
array
>VPropertyprotected\SplObjectStorage $_pageReferences = null
Pages collection hash: => Zend_Pdf_Page
Default valuenullDetails
Type
\SplObjectStorage
>VPropertyprotected\Zend_Pdf_Parser $_parser
Pdf file parser.
It's not used, but has to be destroyed only with Zend_Pdf object
Details
Type
\Zend_Pdf_Parser
>VPropertyprotected\Zend_Pdf_Trailer $_trailer = null
Pdf trailer (last or just created)
Default valuenullDetails
Type
\Zend_Pdf_Trailer
>VPropertypublicarray $outlines = array()
Document outlines
Default valuearray()Details
Type
array
>VPropertypublicarray $pages = array()
Pages collection
Default valuearray()Details
Type
array
Todo
implement it as a class, which supports ArrayAccess and Iterator interfaces, to provide incremental parsing and pages tree updating. That will give good performance and memory (PDF size) benefits.  
>VPropertypublicarray $properties = array()
Document properties
It's an associative array with PDF meta information, values may be string, boolean or float. Returned array could be used directly to access, add, modify or remove document properties. Standard document properties: Title (must be set for PDF/X documents), Author, Subject, Keywords (comma separated list), Creator (the name of the application, that created document, if it was converted from other format), Trapped (must be true, false or null, can not be null for PDF/X documents)
Default valuearray()Details
Type
array

Methods

methodpublic__construct(string $source = null, integer $revision = null,  $load = false) : \Zend_Pdf

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
NameTypeDescription
$sourcestring
  • PDF file to load
$revisioninteger
$load
Returns
TypeDescription
\Zend_Pdf
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodprotected_cleanUpAction(\Zend_Pdf_Action $action,  $refreshPageCollectionHashes = true) : \Zend_Pdf_Action | null

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.
Parameters
NameTypeDescription
$action\Zend_Pdf_Action
$refreshPageCollectionHashes
Returns
TypeDescription
\Zend_Pdf_Action | null
Details
Todo
Give appropriate name and make method public  
methodprotected_dumpNamedDestinations() : void

Dump named destinations

Details
Todo
Create a balanced tree instead of plain structure.  
methodprotected_dumpOutlines() : void

Dump outlines recursively

methodprotected_dumpPages() : void

Orginize pages to tha pages tree structure.

Details
Todo
atomatically attach page to the document, if it's not done yet.  
Todo
check, that page is attached to the current document  
Todo
Dump pages as a balanced tree instead of a plain set.  
methodprotected_loadNamedDestinations(\Zend_Pdf_Element_Reference $root, string $pdfHeaderVersion) : void

Load named destinations recursively

Parameters
NameTypeDescription
$root\Zend_Pdf_Element_Reference

Document catalog entry

$pdfHeaderVersionstring
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodprotected_loadOutlines(\Zend_Pdf_Element_Reference $root) : void

Load outlines recursively

Parameters
NameTypeDescription
$root\Zend_Pdf_Element_Reference

Document catalog entry

methodprotected_loadPages(\Zend_Pdf_Element_Reference $pages, array | null $attributes = array()) : void

Load pages recursively

Parameters
NameTypeDescription
$pages\Zend_Pdf_Element_Reference
$attributesarray | null
methodprotected_refreshPagesHash() : \Zend_Pdf

Refresh page collection hashes

Returns
TypeDescription
\Zend_Pdf
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 document

returns array of Zend_Pdf_Resource_Font_Extracted objects
Returns
TypeDescription
array
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicgetJavaScript() : string

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

Returns
TypeDescription
string
methodpublicgetMemoryManager() : \Zend_Memory_Manager
static

Request used memory manager

Returns
TypeDescription
\Zend_Memory_Manager
methodpublicgetMetadata() : string

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

Returns
TypeDescription
string
methodpublicgetNamedDestination(string $name) : \Zend_Pdf_Destination_Explicit | \Zend_Pdf_Action_GoTo

Return specified named destination

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
\Zend_Pdf_Destination_Explicit | \Zend_Pdf_Action_GoTo
methodpublicgetNamedDestinations() : array

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
TypeDescription
array
methodpublicgetOpenAction() : \Zend_Pdf_Target

Get open Action Returns Zend_Pdf_Target (Zend_Pdf_Destination or Zend_Pdf_Action object)

Returns
TypeDescription
\Zend_Pdf_Target
methodpublicload(string $source = null, integer $revision = null) : \Zend_Pdf
static

Load PDF document from a file

Parameters
NameTypeDescription
$sourcestring
$revisioninteger
Returns
TypeDescription
\Zend_Pdf
methodpublicnewPage(mixed $param1, mixed $param2 = null) : \Zend_Pdf_Page

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
NameTypeDescription
$param1mixed
$param2mixed
Returns
TypeDescription
\Zend_Pdf_Page
methodpublicparse(string $source = null, integer $revision = null) : \Zend_Pdf
static

Create new PDF document from a $source string

Parameters
NameTypeDescription
$sourcestring
$revisioninteger
Returns
TypeDescription
\Zend_Pdf
methodpublicpdfDate(integer $timestamp = null) : string
static

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

Parameters
NameTypeDescription
$timestampinteger

(optional) If omitted, uses the current time.

Returns
TypeDescription
string
Details
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.  
methodpublicrender(boolean $newSegmentOnly = false, resource $outputStream = null) : string

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
NameTypeDescription
$newSegmentOnlyboolean
$outputStreamresource
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicresolveDestination(\Zend_Pdf_Destination $destination,  $refreshPageCollectionHashes = true) : \Zend_Pdf_Page | null

Resolve destination.

Returns Zend_Pdf_Page page object or null if destination is not found within PDF document.
Parameters
NameTypeDescription
$destination\Zend_Pdf_Destination

Destination to resolve

$refreshPageCollectionHashes
Returns
TypeDescription
\Zend_Pdf_Page | null
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicrevisions() : integer

Retrive number of revisions.

Returns
TypeDescription
integer
methodpublicrollback(integer $steps) : void

Rollback document $steps number of revisions.

This method must be invoked before any changes, applied to the document. Otherwise behavior is undefined.
Parameters
NameTypeDescription
$stepsinteger
methodpublicsave(string $filename, boolean $updateOnly = false) : void

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
NameTypeDescription
$filenamestring
$updateOnlyboolean
Throws
ExceptionDescription
\Zend_Pdf_Exception
methodpublicsetJavaScript(string $javascript) : void

Set the document-level JavaScript

Parameters
NameTypeDescription
$javascriptstring
methodpublicsetMemoryManager(\Zend_Memory_Manager $memoryManager) : void
static

Set user defined memory manager

Parameters
NameTypeDescription
$memoryManager\Zend_Memory_Manager
methodpublicsetMetadata(string $metadata) : void

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

Parameters
NameTypeDescription
$metadatastring
methodpublicsetNamedDestination(string $name,  $destination = null) : void

Set specified named destination

Parameters
NameTypeDescription
$namestring
$destination
methodpublicsetOpenAction(\Zend_Pdf_Target $openAction = null) : void

Set open Action which is actually Zend_Pdf_Destination or Zend_Pdf_Action object

Parameters
NameTypeDescription
$openAction\Zend_Pdf_Target
Details
Returns
Zend_Pdf  
Documentation was generated by phpDocumentor 2.2.0 .