API Documentation

Pdf.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: Pdf.php 22655 2010-07-22 18:47:20Z mabe $
Classes
Zend_Pdf

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

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
Constants
PDF_VERSION
PDF_HEADER
Properties
$pages
$properties
$_originalProperties
$_javaScript
$_namedTargets
$outlines
$_originalOutlines
$_originalOpenOutlinesCount
$_trailer
$_objFactory
$_memoryManager
$_parser
$_inheritableAttributes
$_pageReferences
$_pageNumbers
Methods
getMemoryManager
setMemoryManager
parse
load
save
__construct
revisions
rollback
_loadPages
_loadNamedDestinations
_loadOutlines
_dumpPages
_dumpNamedDestinations
_dumpOutlines
newPage
getMetadata
setMetadata
getJavaScript
getOpenAction
setOpenAction
getNamedDestinations
getNamedDestination
setNamedDestination
_refreshPagesHash
resolveDestination
_cleanUpAction
extractFonts
extractFont
render
setJavaScript
pdfDate

Description

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)

Constants

PDF_VERSION

 PDF_VERSION = '1.4'

Version number of generated PDF documents.

Details

value
1.4

PDF_HEADER

 PDF_HEADER = '%PDF-1.4\n%\xE2\xE3\xCF\xD3\n'

PDF file header.

Details

value
%PDF-1.4\n%\xE2\xE3\xCF\xD3\n

Properties

$_inheritableAttributes

array $_inheritableAttributes = 'array'

List of inheritable attributesfor pages tree

Details

$_inheritableAttributes
array
visibility
protected
default
array
final
false
static
true

$_javaScript

string $_javaScript = 'null'

Document level javascript

Details

$_javaScript
string
visibility
protected
default
null
final
false
static
false

$_memoryManager

Zend_Memory_Manager|null $_memoryManager = 'null'

Memory manager for stream objects

Details

$_memoryManager
Zend_Memory_Manager|null
visibility
protected
default
null
final
false
static
true

$_namedTargets

array $_namedTargets = 'array'

Document named destinations or "GoTo..." actions, used to refer document parts from outside PDF

Details

$_namedTargets
array
- array of Zend_Pdf_Target objects
visibility
protected
default
array
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

$_originalOpenOutlinesCount

integer $_originalOpenOutlinesCount = '0'

Original document outlines open elements count Used to track outlines update

Details

$_originalOpenOutlinesCount
integer
visibility
protected
default
0
final
false
static
false

$_originalOutlines

array $_originalOutlines = 'array'

Original document outlines list Used to track outlines update

Details

$_originalOutlines
array
- array of Zend_Pdf_Outline objects
visibility
protected
default
array
final
false
static
false

$_originalProperties

array $_originalProperties = 'array'

Original properties set.

Used for tracking properties changes

Details

$_originalProperties
array
visibility
protected
default
array
final
false
static
false

$_pageNumbers

array $_pageNumbers = 'null'

Pages collection hash: <page number> => Zend_Pdf_Page

Details

$_pageNumbers
array
visibility
protected
default
null
final
false
static
false

$_pageReferences

SplObjectStorage $_pageReferences = 'null'

Pages collection hash: <page dictionary object hash id> => Zend_Pdf_Page

Details

$_pageReferences
SplObjectStorage
visibility
protected
default
null
final
false
static
false

$_parser

Zend_Pdf_Parser $_parser = ''

Pdf file parser.

It's not used, but has to be destroyed only with Zend_Pdf object

Details

$_parser
Zend_Pdf_Parser
visibility
protected
default
final
false
static
false

$_trailer

Zend_Pdf_Trailer $_trailer = 'null'

Pdf trailer (last or just created)

Details

$_trailer
Zend_Pdf_Trailer
visibility
protected
default
null
final
false
static
false

$outlines

array $outlines = 'array'

Document outlines

Details

$outlines
array
- array of Zend_Pdf_Outline objects
visibility
public
default
array
final
false
static
false

$pages

array $pages = 'array'

Pages collection

Details

$pages
array
- array of Zend_Pdf_Page object
visibility
public
default
array
final
false
static
false
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.

$properties

array $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)

Details

$properties
array
visibility
public
default
array
final
false
static
false

Methods

__construct

__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 - currtent version, 1 - previous version, 2 - ...)

Arguments
$source
string
- PDF file to load
$revision
integer
$load
Output
Zend_Pdf
Details
visibility
public
final
false
static
false
throws

_cleanUpAction

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

Arguments
$action
Zend_Pdf_Action
$refreshPageCollectionHashes
Output
Zend_Pdf_Action|null
Details
visibility
protected
final
false
static
false
todo
Give appropriate name and make method public

_dumpNamedDestinations

_dumpNamedDestinations( ) :

Dump named destinations

Details
visibility
protected
final
false
static
false
todo
Create a balanced tree instead of plain structure.

_dumpOutlines

_dumpOutlines( ) :

Dump outlines recursively

Details
visibility
protected
final
false
static
false

_dumpPages

_dumpPages( ) :

Orginize pages to tha pages tree structure.

Details
visibility
protected
final
false
static
false
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.

_loadNamedDestinations

_loadNamedDestinations( Zend_Pdf_Element_Reference $root, string $pdfHeaderVersion ) :

Load named destinations recursively

Arguments
$root
Zend_Pdf_Element_Reference
Document catalog entry
$pdfHeaderVersion
string
Details
visibility
protected
final
false
static
false
throws

_loadOutlines

_loadOutlines( Zend_Pdf_Element_Reference $root ) :

Load outlines recursively

Arguments
$root
Zend_Pdf_Element_Reference
Document catalog entry
Details
visibility
protected
final
false
static
false

_loadPages

_loadPages( Zend_Pdf_Element_Reference $pages, array|null $attributes = array ) :

Load pages recursively

Arguments
$pages
Zend_Pdf_Element_Reference
$attributes
arraynull
Details
visibility
protected
final
false
static
false

_refreshPagesHash

_refreshPagesHash( ) : Zend_Pdf

Refresh page collection hashes

Output
Zend_Pdf
Details
visibility
protected
final
false
static
false

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 document

returns array of Zend_Pdf_Resource_Font_Extracted objects

Output
array
Details
visibility
public
final
false
static
false
throws

getJavaScript

getJavaScript( ) : string

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

Output
string
Details
visibility
public
final
false
static
false

getMemoryManager

getMemoryManager( ) : Zend_Memory_Manager

Request used memory manager

Details
visibility
public
final
false
static
true

getMetadata

getMetadata( ) : string

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

Output
string
Details
visibility
public
final
false
static
false

getNamedDestination

getNamedDestination( string $name ) : Zend_Pdf_Destination_Explicit|Zend_Pdf_Action_GoTo

Return specified named destination

Arguments
$name
string
Details
visibility
public
final
false
static
false

getNamedDestinations

getNamedDestinations( ) : 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'

Output
array
Details
visibility
public
final
false
static
false

getOpenAction

getOpenAction( ) : Zend_Pdf_Target

Get open Action Returns Zend_Pdf_Target (Zend_Pdf_Destination or Zend_Pdf_Action object)

Details
visibility
public
final
false
static
false

load

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

Load PDF document from a file

Arguments
$source
string
$revision
integer
Output
Zend_Pdf
Details
visibility
public
final
false
static
true

newPage

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

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

Arguments
$param1
mixed
$param2
mixed
Output
Zend_Pdf_Page
Details
visibility
public
final
false
static
false

parse

parse( string $source = null, integer $revision = null ) : Zend_Pdf

Create new PDF document from a $source string

Arguments
$source
string
$revision
integer
Output
Zend_Pdf
Details
visibility
public
final
false
static
true

pdfDate

pdfDate( integer $timestamp = null ) : string

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

Arguments
$timestamp
integer
(optional) If omitted, uses the current time.
Output
string
Details
visibility
public
final
false
static
true
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.

render

render( boolean $newSegmentOnly = false, resource $outputStream = null ) : string

Render the completed PDF to a string.

If $newSegmentOnly is true, then only appended part of PDF is returned.

Arguments
$newSegmentOnly
boolean
$outputStream
resource
Output
string
Details
visibility
public
final
false
static
false
throws

resolveDestination

resolveDestination( 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.

Arguments
$destination
Zend_Pdf_Destination
Destination to resolve
$refreshPageCollectionHashes
Output
Zend_Pdf_Page|null
Details
visibility
public
final
false
static
false
throws

revisions

revisions( ) : integer

Retrive number of revisions.

Output
integer
Details
visibility
public
final
false
static
false

rollback

rollback( integer $steps ) :

Rollback document $steps number of revisions.

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

Arguments
$steps
integer
Details
visibility
public
final
false
static
false

save

save( string $filename, boolean $updateOnly = false ) :

Render PDF document and save it.

If $updateOnly is true, then it only appends new section to the end of file.

Arguments
$filename
string
$updateOnly
boolean
Details
visibility
public
final
false
static
false
throws

setJavaScript

setJavaScript( string $javascript ) :

Set the document-level JavaScript

Arguments
$javascript
string
Details
visibility
public
final
false
static
false

setMemoryManager

setMemoryManager( Zend_Memory_Manager $memoryManager ) :

Set user defined memory manager

Arguments
$memoryManager
Zend_Memory_Manager
Details
visibility
public
final
false
static
true

setMetadata

setMetadata( string $metadata ) :

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

Arguments
$metadata
string
Details
visibility
public
final
false
static
false

setNamedDestination

setNamedDestination( string $name,  $destination = null ) :

Set specified named destination

Arguments
$name
string
$destination
Details
visibility
public
final
false
static
false

setOpenAction

setOpenAction( Zend_Pdf_Target $openAction = null ) :

Set open Action which is actually Zend_Pdf_Destination or Zend_Pdf_Action object

Arguments
$openAction
Zend_Pdf_Target
Details
visibility
public
final
false
static
false
returns
Zend_Pdf
Documentation was generated by DocBlox.