| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244 |
- <?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 <constant>TRUE</constant> 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> and
- <classname>Zend_Pdf_Action_URI</classname> actions can be created by
- user now.
- </para>
- <para>
- GoTo action object can be created using
- <methodname>Zend_Pdf_Action_GoTo::create($destination)</methodname> method,
- where <varname>$destination</varname> is a
- <classname>Zend_Pdf_Destination</classname> object or a string which can be used
- to identify named destination.
- </para>
- <para>
- <methodname>Zend_Pdf_Action_URI::create($uri[, $isMap])</methodname> method has
- to be used to create a URI action (see <acronym>API</acronym> documentation for the
- details). Optional <varname>$isMap</varname> parameter is set to
- <constant>FALSE</constant> by default.
- </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++;
- }
- // Prints 'Actions in a tree: 4'
- printf("Actions in a tree: %d\n", $actionsCount++);
- ]]></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 <constant>NULL</constant> 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 <constant>NULL</constant>.
- </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> - <constant>TRUE</constant> 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> - <constant>TRUE</constant> 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> - <constant>TRUE</constant> 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 (<constant>NULL</constant> means black).
- </para>
- </listitem>
- <listitem>
- <para>
- <methodname>setColor(Zend_Pdf_Color_Rgb $color)</methodname> - set
- outline text color (<constant>NULL</constant> 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. <constant>NULL</constant> 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:
- </para>
- <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) {
- $OutlineItemTarget->setDestination();
- if ($pdf->resolveDestination($OutlineItemTarget) === 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>
- <note>
- <para>
- All outline items with unresolved destinations (or destinations of GoTo
- actions) are updated while document saving by setting their targets to
- <constant>NULL</constant>. 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:
- -->
|