<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.pdf.interactive-features">
    <title>Interactive Features</title>
    <sect2 id="zend.pdf.pages.interactive-features.destinations">
        <title>Destinations</title>

        <para>
            A destination defines a particular view of a document, consisting of the following
            items:
        </para>

        <itemizedlist>
            <listitem>
                <para>The page of the document to be displayed.</para>
            </listitem>

            <listitem>
                <para>The location of the document window on that page.</para>
            </listitem>

            <listitem>
                <para>The magnification (zoom) factor to use when displaying the page.</para>
            </listitem>
        </itemizedlist>

        <para>
            Destinations may be associated with outline items (<link
            linkend="zend.pdf.pages.interactive-features.outlines">Document
            Outline (bookmarks)</link>), annotations (<link
            linkend="zend.pdf.pages.interactive-features.annotations">Annotations</link>), or
            actions (<link linkend="zend.pdf.pages.interactive-features.actions">Actions</link>).
            In each case, the destination specifies the view of the document to be presented
            when the outline item or annotation is opened or the action is performed. In addition,
            the optional document open action can be specified.
        </para>

        <sect3 id="zend.pdf.pages.interactive-features.destinations.types">
            <title>Supported Destination Types</title>

            <para>
                The following types are supported by <classname>Zend_Pdf</classname> component.
            </para>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.zoom">
                <title>Zend_Pdf_Destination_Zoom</title>

                <para>
                    Display the specified page, with the coordinates (left, top) positioned at
                    the upper-left corner of the window and the contents of the page magnified
                    by the factor zoom.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_Zoom::create($page, $left = null, $top = null,
                        $zoom = null)</methodname>
                    method.
                </para>

                <para>
                    Where:
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <varname>$page</varname> is a destination page
                            (a <classname>Zend_Pdf_Page</classname> object or a page number).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$left</varname> is a left edge of the displayed page
                            (float).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$top</varname> is a top edge of the displayed page
                            (float).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$zoom</varname> is a zoom factor (float).
                        </para>
                    </listitem>
                </itemizedlist>

                <para>
                   <constant>NULL</constant>, specified for <varname>$left</varname>,
                   <varname>$top</varname> or <varname>$zoom</varname> parameter means
                   "current viewer application value".
                </para>

                <para>
                    <classname>Zend_Pdf_Destination_Zoom</classname> class also provides
                    the following methods:
                </para>

                <itemizedlist>
                    <listitem>
                        <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setLeftEdge(float $left)</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setTopEdge(float $top)</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><type>Float</type><methodname>getZoomFactor()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setZoomFactor(float $zoom)</methodname>;</para>
                    </listitem>
                </itemizedlist>
            </sect4>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit">
                <title>Zend_Pdf_Destination_Fit</title>

                <para>
                    Display the specified page, with the coordinates (left, top) positioned at
                    the upper-left corner of the window and the contents of the page magnified
                    by the factor zoom.
                    Display the specified page, with its contents magnified just enough to fit
                    the entire page within the window both horizontally and vertically. If
                    the required horizontal and vertical magnification factors are different, use
                    the smaller of the two, centering the page within the window in the other
                    dimension.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_Fit::create($page)</methodname>
                    method.
                </para>

                <para>
                    Where <varname>$page</varname> is a destination page
                    (a <classname>Zend_Pdf_Page</classname> object or a page number).
                </para>
            </sect4>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-horizontally">
                <title>Zend_Pdf_Destination_FitHorizontally</title>

                <para>
                    Display the specified page, with the vertical coordinate top positioned at
                    the top edge of the window and the contents of the page magnified just enough
                    to fit the entire width of the page within the window.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_FitHorizontally::create($page,
                        $top)</methodname> method.
                </para>

                <para>
                    Where:
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <varname>$page</varname> is a destination page
                            (a <classname>Zend_Pdf_Page</classname> object or a page number).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$top</varname> is a top edge of the displayed page
                            (float).
                        </para>
                    </listitem>
                </itemizedlist>

                <para>
                    <classname>Zend_Pdf_Destination_FitHorizontally</classname> class also
                    provides the following methods:
                </para>

                <itemizedlist>
                    <listitem>
                        <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setTopEdge(float $top)</methodname>;</para>
                    </listitem>
                </itemizedlist>
            </sect4>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-vertically">
                <title>Zend_Pdf_Destination_FitVertically</title>

                <para>
                    Display the specified page, with the horizontal coordinate left positioned
                    at the left edge of the window and the contents of the page magnified just
                    enough to fit the entire height of the page within the window.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_FitVertically::create($page,
                        $left)</methodname> method.
                </para>

                <para>
                    Where:
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <varname>$page</varname> is a destination page
                            (a <classname>Zend_Pdf_Page</classname> object or a page number).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$left</varname> is a left edge of the displayed page
                            (float).
                        </para>
                    </listitem>
                </itemizedlist>

                <para>
                    <classname>Zend_Pdf_Destination_FitVertically</classname> class also
                    provides the following methods:
                </para>

                <itemizedlist>
                    <listitem>
                        <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setLeftEdge(float $left)</methodname>;</para>
                    </listitem>
                </itemizedlist>
            </sect4>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-rectangle">
                <title>Zend_Pdf_Destination_FitRectangle</title>

                <para>
                    Display the specified page, with its contents magnified just enough to fit
                    the rectangle specified by the coordinates left, bottom, right, and top
                    entirely within the window both horizontally and vertically. If the required
                    horizontal and vertical magnification factors are different, use the smaller
                    of the two, centering the rectangle within the window in the other dimension.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_FitRectangle::create($page, $left, $bottom,
                        $right, $top)</methodname> method.
                </para>

                <para>
                    Where:
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <varname>$page</varname> is a destination page
                            (a <classname>Zend_Pdf_Page</classname> object or a page number).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$left</varname> is a left edge of the displayed page
                            (float).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$bottom</varname> is a bottom edge of the displayed page
                            (float).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$right</varname> is a right edge of the displayed page
                            (float).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$top</varname> is a top edge of the displayed page
                            (float).
                        </para>
                    </listitem>
                </itemizedlist>

                <para>
                    <classname>Zend_Pdf_Destination_FitRectangle</classname> class also
                    provides the following methods:
                </para>

                <itemizedlist>
                    <listitem>
                        <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setLeftEdge(float $left)</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><type>Float</type><methodname>getBottomEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setBottomEdge(float $bottom)</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><type>Float</type><methodname>getRightEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setRightEdge(float $right)</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setTopEdge(float $top)</methodname>;</para>
                    </listitem>
                </itemizedlist>
            </sect4>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box">
                <title>Zend_Pdf_Destination_FitBoundingBox</title>

                <para>
                    Display the specified page, with its contents magnified just enough to fit
                    its bounding box entirely within the window both horizontally and vertically.
                    If the required horizontal and vertical magnification factors are different,
                    use the smaller of the two, centering the bounding box within the window in
                    the other dimension.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_FitBoundingBox::create($page, $left, $bottom,
                        $right, $top)</methodname> method.
                </para>

                <para>
                    Where <varname>$page</varname> is a destination page
                    (a <classname>Zend_Pdf_Page</classname> object or a page number).
                </para>
            </sect4>

            <sect4
                id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box-horizontally">
                <title>Zend_Pdf_Destination_FitBoundingBoxHorizontally</title>

                <para>
                    Display the specified page, with the vertical coordinate top positioned at
                    the top edge of the window and the contents of the page magnified just enough
                    to fit the entire width of its bounding box within the window.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_FitBoundingBoxHorizontally::create($page,
                        $top)</methodname> method.
                </para>

                <para>
                    Where
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <varname>$page</varname> is a destination page
                            (a <classname>Zend_Pdf_Page</classname> object or a page number).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$top</varname> is a top edge of the displayed page
                            (float).
                        </para>
                    </listitem>
                </itemizedlist>

                <para>
                    <classname>Zend_Pdf_Destination_FitBoundingBoxHorizontally</classname> class
                    also provides the following methods:
                </para>

                <itemizedlist>
                    <listitem>
                        <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setTopEdge(float $top)</methodname>;</para>
                    </listitem>
                </itemizedlist>
            </sect4>

            <sect4
                id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box-vertically">
                <title>Zend_Pdf_Destination_FitBoundingBoxVertically</title>

                <para>
                    Display the specified page, with the horizontal coordinate left positioned at
                    the left edge of the window and the contents of the page magnified just
                    enough to fit the entire height of its bounding box within the window.
                </para>

                <para>
                    Destination object may be created using
                    <methodname>Zend_Pdf_Destination_FitBoundingBoxVertically::create($page,
                        $left)</methodname> method.
                </para>

                <para>
                    Where
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <varname>$page</varname> is a destination page
                            (a <classname>Zend_Pdf_Page</classname> object or a page number).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <varname>$left</varname> is a left edge of the displayed page
                            (float).
                        </para>
                    </listitem>
                </itemizedlist>

                <para>
                    <classname>Zend_Pdf_Destination_FitBoundingBoxVertically</classname> class
                    also provides the following methods:
                </para>

                <itemizedlist>
                    <listitem>
                        <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
                    </listitem>

                    <listitem>
                        <para><methodname>setLeftEdge(float $left)</methodname>;</para>
                    </listitem>
                </itemizedlist>
            </sect4>

            <sect4 id="zend.pdf.pages.interactive-features.destinations.types.named">
                <title>Zend_Pdf_Destination_Named</title>

                <para>
                    All destinations listed above are "Explicit Destinations".
                </para>

                <para>
                    In addition to this, <acronym>PDF</acronym> document may contain a dictionary
                    of such destinations which may be used to reference from outside the
                    <acronym>PDF</acronym> (e.g.
                    '<filename>http://www.mycompany.com/document.pdf#chapter3</filename>').
                </para>

                <para>
                    <classname>Zend_Pdf_Destination_Named</classname> objects allow to refer
                    destinations from the document named destinations dictionary.
                </para>

                <para>
                    Named destination object may be created using
                    <methodname>Zend_Pdf_Destination_Named::create(string $name)</methodname>
                    method.
                </para>

                <para>
                    <classname>Zend_Pdf_Destination_Named</classname> class provides the only one
                    additional method:
                </para>

                <para>
                    <type>String</type><methodname>getName()</methodname>;
                </para>
            </sect4>
        </sect3>

        <sect3 id="zend.pdf.pages.interactive-features.destinations.processing">
            <title>Document level destination processing</title>

            <para>
                <classname>Zend_Pdf</classname> class provides a set of destinations processing
                methods.
            </para>

            <para>
                Each destination object (including named destinations) can be resolved using the
                <methodname>resolveDestination($destination)</methodname> method. It returns
                corresponding <classname>Zend_Pdf_Page</classname> object, if destination target
                is found, or <constant>NULL</constant> otherwise.
            </para>

            <para>
                <methodname>Zend_Pdf::resolveDestination()</methodname> method also takes
                an optional boolean parameter <varname>$refreshPageCollectionHashes</varname>,
                which is true by default. It forces <classname>Zend_Pdf</classname> object
                to refresh internal page collection hashes since document pages list may be
                updated by user using <varname>Zend_Pdf::$pages</varname> property
                (<link linkend="zend.pdf.pages">Working with Pages</link>).
                It may be turned off for performance reasons,
                if it's known that document pages list wasn't changed since last method
                request.
            </para>

            <para>
                Complete list of named destinations can be retrieved using
                <methodname>Zend_Pdf::getNamedDestinations()</methodname> method. It returns
                an array of <classname>Zend_Pdf_Target</classname> objects, which are actually
                either an explicit destination or a GoTo action
                (<link linkend="zend.pdf.pages.interactive-features.actions">Actions</link>).
            </para>

            <para>
                <methodname>Zend_Pdf::getNamedDestination(string $name)</methodname> method returns
                specified named destination (an explicit destination or a GoTo action).
            </para>

            <para>
                <acronym>PDF</acronym> document named destinations dictionary may be updated with
                <methodname>Zend_Pdf::setNamedDestination(string $name, $destination)</methodname>
                method, where <varname>$destination</varname> is either an explicit destination
                (any destination except <classname>Zend_Pdf_Destination_Named</classname>) or
                a GoTo action.
            </para>

            <para>
                If <constant>NULL</constant> is specified in place of
                <varname>$destination</varname>, then specified named destination is removed.
            </para>

            <note>
                <para>
                    Unresolvable named destinations are automatically removed from a document
                    while document saving.
                </para>
            </note>

            <example id="zend.pdf.interactive-features.destinations.example-1">
                <title>Destinations usage example</title>

                <programlisting language="php"><![CDATA[
$pdf = new Zend_Pdf();
$page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
// Page created, but not included into pages list

$pdf->pages[] = $page1;
$pdf->pages[] = $page2;

$destination1 = Zend_Pdf_Destination_Fit::create($page2);
$destination2 = Zend_Pdf_Destination_Fit::create($page3);

// Returns $page2 object
$page = $pdf->resolveDestination($destination1);

// Returns null, page 3 is not included into document yet
$page = $pdf->resolveDestination($destination2);

$pdf->setNamedDestination('Page2', $destination1);
$pdf->setNamedDestination('Page3', $destination2);

// Returns $destination2
$destination = $pdf->getNamedDestination('Page3');

// Returns $destination1
$pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page2'));

// Returns null, page 3 is not included into document yet
$pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page3'));
]]></programlisting>
            </example>
        </sect3>
    </sect2>

    <sect2 id="zend.pdf.pages.interactive-features.actions">
        <title>Actions</title>

        <para>
            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.
        </para>

        <sect3 id="zend.pdf.pages.interactive-features.actions.types">
            <title>Supported action types</title>

            <para>
                The following action types are recognized while loading <acronym>PDF</acronym>
                document:
            </para>
            <itemizedlist>
                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_GoTo</classname> - go to
                        a destination in the current document.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_GoToR</classname> - go to
                        a destination in another document.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_GoToE</classname> - go to
                        a destination in an embedded file.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Launch</classname> - launch
                        an application or open or print a document.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Thread</classname> - begin reading
                        an article thread.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_URI</classname> - resolve a
                        <acronym>URI</acronym>.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Sound</classname> - play a sound.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Movie</classname> - play a movie.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Hide</classname> - hides or shows
                        one or more annotations on the screen.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Named</classname> - execute an action
                        predefined by the viewer application:
                    </para>

                    <itemizedlist>
                        <listitem>
                            <para>
                                <emphasis>NextPage</emphasis> - Go to the next page
                                of the document.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>PrevPage</emphasis> - Go to the previous
                                page of the document.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>FirstPage</emphasis> - Go to the first page
                                of the document.
                            </para>
                        </listitem>

                        <listitem>
                            <para>
                                <emphasis>LastPage</emphasis> - Go to the last page
                                of the document.
                            </para>
                        </listitem>
                    </itemizedlist>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_SubmitForm</classname> - send data to
                        a uniform resource locator.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_ResetForm</classname> - set fields
                        to their default values.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_ImportData</classname> - import field
                        values from a file.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_JavaScript</classname> - execute
                        a JavaScript script.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_SetOCGState</classname> - set the state of
                        one or more optional content groups.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Rendition</classname> - control the
                        playing of multimedia content (begin, stop, pause, or resume
                        a playing rendition).
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_Trans</classname> - update the display
                        of a document, using a transition dictionary.
                    </para>
                </listitem>

                <listitem>
                    <para>
                        <classname>Zend_Pdf_Action_GoTo3DView</classname> - set
                        the current view of a 3D annotation.
                    </para>
                </listitem>
            </itemizedlist>

            <para>
                Only <classname>Zend_Pdf_Action_GoTo</classname> actions can be created by
                user now. It can be done using
                <methodname>Zend_Pdf_Action_GoTo::create($destination)</methodname> method,
                where <varname>$destination</varname> is a
                <classname>Zend_Pdf_Destination</classname> object or string which can be used
                to identify named destination.
            </para>

            <para>
                It also supports the following methods:
            </para>
        </sect3>

        <sect3 id="zend.pdf.pages.interactive-features.actions.chaining">
            <title>Actions chaining</title>

            <para>
                Actions objects can be chained using <varname>Zend_Pdf_Action::$next</varname>
                public property.
            </para>

            <para>
                It's an array of <classname>Zend_Pdf_Action</classname> objects, which also
                may have their sub-actions.
            </para>

            <para>
                <classname>Zend_Pdf_Action</classname> class supports RecursiveIterator interface,
                so child actions may be iterated recursively:
            </para>

            <programlisting language="php"><![CDATA[
$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++;
}
printf("Actions in a tree: %d\n", $actionsCount++); // Prints 'Actions in a tree: 4'
]]></programlisting>
        </sect3>

        <sect3 id="zend.pdf.pages.interactive-features.actions.open-action">
            <title>Document Open Action</title>

            <para>
                Special open action may be specify a destination to be displayed or an action
                to be performed when the document is opened.
            </para>

            <para>
                <methodname>Zend_Pdf_Target Zend_Pdf::getOpenAction()</methodname> method
                returns current document open action (or null if open action is not set).
            </para>

            <para>
                <methodname>setOpenAction(Zend_Pdf_Target $openAction = null)</methodname>
                method sets document open action or clean it if <varname>$openAction</varname>
                is null.
            </para>
        </sect3>
    </sect2>

    <sect2 id="zend.pdf.pages.interactive-features.outlines">
        <title>Document Outline (bookmarks)</title>
        <para>
            A PDF document may optionally display a document outline on the screen, allowing
            the user to navigate interactively from one part of the document to another.
            The outline consists of a tree-structured hierarchy of outline items (sometimes
            called bookmarks), which serve as a visual table of contents to display the document’s
            structure to the user. The user can interactively open and close individual
            items by clicking them with the mouse. When an item is open, its immediate children
            in the hierarchy become visible on the screen; each child may in turn be
            open or closed, selectively revealing or hiding further parts of the hierarchy.
            When an item is closed, all of its descendants in the hierarchy are hidden. Clicking
            the text of any visible item activates the item, causing the viewer application to
            jump to a destination or trigger an action associated with the item.
        </para>

        <para>
            <classname>Zend_Pdf</classname> class provides public property
            <varname>$outlines</varname> which is an array of
            <classname>Zend_Pdf_Outline</classname> objects.
            <programlisting language="php"><![CDATA[
$pdf = Zend_Pdf::load($path);

// Remove outline item
unset($pdf->outlines[0]->childOutlines[1]);

// Set Outline to be displayed in bold
$pdf->outlines[0]->childOutlines[3]->setIsBold(true);

// Add outline entry
$pdf->outlines[0]->childOutlines[5]->childOutlines[] =
    Zend_Pdf_Outline::create('Chapter 2', 'chapter_2');

$pdf->save($path, true);
]]></programlisting>
        </para>

        <para>
            Outline attributes may be retrieved or set using the following methods:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>string getTitle()</methodname> - get outline item title.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setTitle(string $title)</methodname> - set outline item title.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>boolean isOpen()</methodname> - true if outline is open
                    by default.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setIsOpen(boolean $isOpen)</methodname> - set isOpen state.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>boolean isItalic()</methodname> - true if outline item
                    is displayed in italic.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setIsItalic(boolean $isItalic)</methodname> - set
                    isItalic state.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>boolean isBold()</methodname> - true if outline item
                    is displayed in bold.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setIsBold(boolean $isBold)</methodname> - set
                    isBold state.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>Zend_Pdf_Color_Rgb getColor()</methodname> - get outline
                    text color (null means black).
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setColor(Zend_Pdf_Color_Rgb $color)</methodname> - set
                    outline text color (null means black).
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>Zend_Pdf_Target getTarget()</methodname> - get outline
                    target (action or explicit or named destination object).
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setTarget(Zend_Pdf_Target|string $target)</methodname> - set
                    outline target (action or destination). String may be used to identify
                    named destination. Null means 'no target'.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>array getOptions()</methodname> - get outline attributes
                    as an array.
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>setOptions(array $options)</methodname> - set outline options.
                    The following options are recognized: 'title', 'open', 'color', 'italic',
                    'bold', and 'target'.
                </para>
            </listitem>
        </itemizedlist>

        <para>
            New outline may be created in two ways:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>Zend_Pdf_Outline::create(string $title[, Zend_Pdf_Target|string $target])</methodname>
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>Zend_Pdf_Outline::create(array $options)</methodname>
                </para>
            </listitem>
        </itemizedlist>

        <para>
            Each outline object may have child outline items listed in
            <varname>Zend_Pdf_Outline::$childOutlines</varname> public property.
            It's an array of <classname>Zend_Pdf_Outline</classname> objects,
            so outlines are organized in a tree.
        </para>

        <para>
            <classname>Zend_Pdf_Outline</classname> class implements RecursiveArray interface,
            so child outlines may be recursively iterated using RecursiveIteratorIterator:
            <programlisting language="php"><![CDATA[
$pdf = Zend_Pdf::load($path);

foreach ($pdf->outlines as $documentRootOutlineEntry) {
    $iterator = new RecursiveIteratorIterator($documentRootOutlineEntry,
                                              RecursiveIteratorIterator::SELF_FIRST);
    foreach ($iterator as $childOutlineItem) {
        $OutlineItemTarget = $childOutlineItem->getTarget();
        if ($OutlineItemTarget instanceof Zend_Pdf_Destination) {
            if ($pdf->resolveDestination($OutlineItemTarget) === null) {
                // Mark Outline item with unresolvable destination using RED color
                $childOutlineItem->setColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
            }
        } else if ($OutlineItemTarget instanceof Zend_Pdf_Action_GoTo) {
            if ($pdf->resolveDestination($OutlineItemTarget->setDestination()) === null) {
                // Mark Outline item with unresolvable destination using RED color
                $childOutlineItem->setColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
            }
        }
    }
}

$pdf->save($path, true);
]]></programlisting>
        </para>

        <note>
            <para>
                All outline items with unresolved destinations (or destinations of GoTo
                actions) are updated while document saving by setting their targets to null.
                So document will not be corrupted by removing pages referenced by outlines.
            </para>
        </note>
    </sect2>

    <sect2 id="zend.pdf.pages.interactive-features.annotations">
        <title>Annotations</title>

        <para>
            An annotation associates an object such as a note, sound, or movie with a location
            on a page of a PDF document, or provides a way to interact with the user by means
            of the mouse and keyboard.
        </para>

        <para>
            All annotations are represented by <classname>Zend_Pdf_Annotation</classname>
            abstract class.
        </para>

        <para>
            Annotation may be attached to a page using
            <methodname>Zend_Pdf_Page::attachAnnotation(Zend_Pdf_Annotation $annotation)</methodname>
            method.
        </para>

        <para>
            Three types of annotations may be created by user now:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>Zend_Pdf_Annotation_Link::create($x1, $y1, $x2, $y2, $target)</methodname>
                    where <varname>$target</varname> is an action object or a destination or
                    string (which may be used in place of named destination object).
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>Zend_Pdf_Annotation_Text::create($x1, $y1, $x2, $y2, $text)</methodname>
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>Zend_Pdf_Annotation_FileAttachment::create($x1, $y1, $x2, $y2, $fileSpecification)</methodname>
                </para>
            </listitem>
        </itemizedlist>

        <para>
            A link annotation represents either a hypertext link to a destination elsewhere in
            the document or an action to be performed.
        </para>

        <para>
            A text annotation represents a "sticky note" attached to a point in the PDF document.
        </para>

        <para>
            A file attachment annotation contains a reference to a file.
        </para>

        <para>
            The following methods are shared between all annotation types:
        </para>

        <itemizedlist>
            <listitem>
                <para><methodname>setLeft(float $left)</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>float getLeft()</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>setRight(float $right)</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>float getRight()</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>setTop(float $top)</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>float getTop()</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>setBottom(float $bottom)</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>float getBottom()</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>setText(string $text)</methodname></para>
            </listitem>

            <listitem>
                <para><methodname>string getText()</methodname></para>
            </listitem>
        </itemizedlist>

        <para>
            Text annotation property is a text to be displayed for the annotation or, if this
            type of annotation does not display text, an alternate description of the annotation’s
            contents in human-readable form.
        </para>

        <para>
            Link annotation objects also provide two additional methods:
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>setDestination(Zend_Pdf_Target|string $target)</methodname>
                </para>
            </listitem>

            <listitem>
                <para>
                    <methodname>Zend_Pdf_Target getDestination()</methodname>
                </para>
            </listitem>
        </itemizedlist>
    </sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->