Instead of simply jumping to a destination in the document, an annotation or outline item can specify an action for the viewer application to perform, such as launching an application, playing a sound, or changing an annotation's appearance state.
The following action types are recognized while loading PDF document:
Zend_Pdf_Action_GoTo- go to a destination in the current document.Zend_Pdf_Action_GoToR- go to a destination in another document.Zend_Pdf_Action_GoToE- go to a destination in an embedded file.Zend_Pdf_Action_Launch- launch an application or open or print a document.Zend_Pdf_Action_Thread- begin reading an article thread.Zend_Pdf_Action_URI- resolve a URI.Zend_Pdf_Action_Sound- play a sound.Zend_Pdf_Action_Movie- play a movie.Zend_Pdf_Action_Hide- hides or shows one or more annotations on the screen.-
Zend_Pdf_Action_Named- execute an action predefined by the viewer application:NextPage - Go to the next page of the document.
PrevPage - Go to the previous page of the document.
FirstPage - Go to the first page of the document.
LastPage - Go to the last page of the document.
Zend_Pdf_Action_SubmitForm- send data to a uniform resource locator.Zend_Pdf_Action_ResetForm- set fields to their default values.Zend_Pdf_Action_ImportData- import field values from a file.Zend_Pdf_Action_JavaScript- execute a JavaScript script.Zend_Pdf_Action_SetOCGState- set the state of one or more optional content groups.Zend_Pdf_Action_Rendition- control the playing of multimedia content (begin, stop, pause, or resume a playing rendition).Zend_Pdf_Action_Trans- update the display of a document, using a transition dictionary.Zend_Pdf_Action_GoTo3DView- set the current view of a 3D annotation.
Only Zend_Pdf_Action_GoTo and
Zend_Pdf_Action_URI actions can be created by
user now.
GoTo action object can be created using
Zend_Pdf_Action_GoTo::create($destination) method,
where $destination is a
Zend_Pdf_Destination object or a string which can be used
to identify named destination.
Zend_Pdf_Action_URI::create($uri[, $isMap]) method has
to be used to create a URI action (see API documentation for the
details). Optional $isMap parameter is set to
FALSE by default.
It also supports the following methods:
Actions objects can be chained using Zend_Pdf_Action::$next
public property.
It's an array of Zend_Pdf_Action objects, which also
may have their sub-actions.
Zend_Pdf_Action class supports RecursiveIterator interface,
so child actions may be iterated recursively:
<?php
$pdf = new Zend_Pdf();
$page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
// Page created, but not included into pages list
$page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page1;
$pdf->pages[] = $page2;
$action1 = Zend_Pdf_Action_GoTo::create(
Zend_Pdf_Destination_Fit::create($page2));
$action2 = Zend_Pdf_Action_GoTo::create(
Zend_Pdf_Destination_Fit::create($page3));
$action3 = Zend_Pdf_Action_GoTo::create(
Zend_Pdf_Destination_Named::create('Chapter1'));
$action4 = Zend_Pdf_Action_GoTo::create(
Zend_Pdf_Destination_Named::create('Chapter5'));
$action2->next[] = $action3;
$action2->next[] = $action4;
$action1->next[] = $action2;
$actionsCount = 1; // Note! Iteration doesn't include top level action and
// walks through children only
$iterator = new RecursiveIteratorIterator(
$action1,
RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $chainedAction) {
$actionsCount++;
}
// Prints 'Actions in a tree: 4'
printf("Actions in a tree: %d\n", $actionsCount++);
Special open action may be specify a destination to be displayed or an action to be performed when the document is opened.
Zend_Pdf_Target Zend_Pdf::getOpenAction() method
returns current document open action (or NULL if open action
is not set).
setOpenAction(Zend_Pdf_Target $openAction = null)
method sets document open action or clean it if $openAction
is NULL.




