Zend_Pdf-InteractiveFeatures.xml 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.pdf.interactive-features">
  4. <title>Interactive Features</title>
  5. <sect2 id="zend.pdf.pages.interactive-features.destinations">
  6. <title>Destinations</title>
  7. <para>
  8. A destination defines a particular view of a document, consisting of the following
  9. items:
  10. </para>
  11. <itemizedlist>
  12. <listitem>
  13. <para>The page of the document to be displayed.</para>
  14. </listitem>
  15. <listitem>
  16. <para>The location of the document window on that page.</para>
  17. </listitem>
  18. <listitem>
  19. <para>The magnification (zoom) factor to use when displaying the page.</para>
  20. </listitem>
  21. </itemizedlist>
  22. <para>
  23. Destinations may be associated with outline items (<link
  24. linkend="zend.pdf.pages.interactive-features.outlines">Document
  25. Outline (bookmarks)</link>), annotations (<link
  26. linkend="zend.pdf.pages.interactive-features.annotations">Annotations</link>), or
  27. actions (<link linkend="zend.pdf.pages.interactive-features.actions">Actions</link>).
  28. In each case, the destination specifies the view of the document to be presented
  29. when the outline item or annotation is opened or the action is performed. In addition,
  30. the optional document open action can be specified.
  31. </para>
  32. <sect3 id="zend.pdf.pages.interactive-features.destinations.types">
  33. <title>Supported Destination Types</title>
  34. <para>
  35. The following types are supported by <classname>Zend_Pdf</classname> component.
  36. </para>
  37. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.zoom">
  38. <title>Zend_Pdf_Destination_Zoom</title>
  39. <para>
  40. Display the specified page, with the coordinates (left, top) positioned at
  41. the upper-left corner of the window and the contents of the page magnified
  42. by the factor zoom.
  43. </para>
  44. <para>
  45. Destination object may be created using
  46. <methodname>Zend_Pdf_Destination_Zoom::create($page, $left = null, $top = null,
  47. $zoom = null)</methodname>
  48. method.
  49. </para>
  50. <para>
  51. Where:
  52. </para>
  53. <itemizedlist>
  54. <listitem>
  55. <para>
  56. <varname>$page</varname> is a destination page
  57. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  58. </para>
  59. </listitem>
  60. <listitem>
  61. <para>
  62. <varname>$left</varname> is a left edge of the displayed page (float).
  63. </para>
  64. </listitem>
  65. <listitem>
  66. <para>
  67. <varname>$top</varname> is a top edge of the displayed page (float).
  68. </para>
  69. </listitem>
  70. <listitem>
  71. <para>
  72. <varname>$zoom</varname> is a zoom factor (float).
  73. </para>
  74. </listitem>
  75. </itemizedlist>
  76. <para>
  77. <constant>NULL</constant>, specified for <varname>$left</varname>,
  78. <varname>$top</varname> or <varname>$zoom</varname> parameter means
  79. "current viewer application value".
  80. </para>
  81. <para>
  82. <classname>Zend_Pdf_Destination_Zoom</classname> class also provides
  83. the following methods:
  84. </para>
  85. <itemizedlist>
  86. <listitem>
  87. <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
  88. </listitem>
  89. <listitem>
  90. <para><methodname>setLeftEdge(float $left)</methodname>;</para>
  91. </listitem>
  92. <listitem>
  93. <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
  94. </listitem>
  95. <listitem>
  96. <para><methodname>setTopEdge(float $top)</methodname>;</para>
  97. </listitem>
  98. <listitem>
  99. <para><type>Float</type><methodname>getZoomFactor()</methodname>;</para>
  100. </listitem>
  101. <listitem>
  102. <para><methodname>setZoomFactor(float $zoom)</methodname>;</para>
  103. </listitem>
  104. </itemizedlist>
  105. </sect4>
  106. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit">
  107. <title>Zend_Pdf_Destination_Fit</title>
  108. <para>
  109. Display the specified page, with the coordinates (left, top) positioned at
  110. the upper-left corner of the window and the contents of the page magnified
  111. by the factor zoom.
  112. Display the specified page, with its contents magnified just enough to fit
  113. the entire page within the window both horizontally and vertically. If
  114. the required horizontal and vertical magnification factors are different, use
  115. the smaller of the two, centering the page within the window in the other
  116. dimension.
  117. </para>
  118. <para>
  119. Destination object may be created using
  120. <methodname>Zend_Pdf_Destination_Fit::create($page)</methodname>
  121. method.
  122. </para>
  123. <para>
  124. Where <varname>$page</varname> is a destination page
  125. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  126. </para>
  127. </sect4>
  128. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-horizontally">
  129. <title>Zend_Pdf_Destination_FitHorizontally</title>
  130. <para>
  131. Display the specified page, with the vertical coordinate top positioned at
  132. the top edge of the window and the contents of the page magnified just enough
  133. to fit the entire width of the page within the window.
  134. </para>
  135. <para>
  136. Destination object may be created using
  137. <methodname>Zend_Pdf_Destination_FitHorizontally::create($page,
  138. $top)</methodname> method.
  139. </para>
  140. <para>
  141. Where:
  142. </para>
  143. <itemizedlist>
  144. <listitem>
  145. <para>
  146. <varname>$page</varname> is a destination page
  147. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  148. </para>
  149. </listitem>
  150. <listitem>
  151. <para>
  152. <varname>$top</varname> is a top edge of the displayed page
  153. (float).
  154. </para>
  155. </listitem>
  156. </itemizedlist>
  157. <para>
  158. <classname>Zend_Pdf_Destination_FitHorizontally</classname> class also
  159. provides the following methods:
  160. </para>
  161. <itemizedlist>
  162. <listitem>
  163. <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
  164. </listitem>
  165. <listitem>
  166. <para><methodname>setTopEdge(float $top)</methodname>;</para>
  167. </listitem>
  168. </itemizedlist>
  169. </sect4>
  170. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-vertically">
  171. <title>Zend_Pdf_Destination_FitVertically</title>
  172. <para>
  173. Display the specified page, with the horizontal coordinate left positioned
  174. at the left edge of the window and the contents of the page magnified just
  175. enough to fit the entire height of the page within the window.
  176. </para>
  177. <para>
  178. Destination object may be created using
  179. <methodname>Zend_Pdf_Destination_FitVertically::create($page,
  180. $left)</methodname> method.
  181. </para>
  182. <para>
  183. Where:
  184. </para>
  185. <itemizedlist>
  186. <listitem>
  187. <para>
  188. <varname>$page</varname> is a destination page
  189. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  190. </para>
  191. </listitem>
  192. <listitem>
  193. <para>
  194. <varname>$left</varname> is a left edge of the displayed page
  195. (float).
  196. </para>
  197. </listitem>
  198. </itemizedlist>
  199. <para>
  200. <classname>Zend_Pdf_Destination_FitVertically</classname> class also
  201. provides the following methods:
  202. </para>
  203. <itemizedlist>
  204. <listitem>
  205. <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
  206. </listitem>
  207. <listitem>
  208. <para><methodname>setLeftEdge(float $left)</methodname>;</para>
  209. </listitem>
  210. </itemizedlist>
  211. </sect4>
  212. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-rectangle">
  213. <title>Zend_Pdf_Destination_FitRectangle</title>
  214. <para>
  215. Display the specified page, with its contents magnified just enough to fit
  216. the rectangle specified by the coordinates left, bottom, right, and top
  217. entirely within the window both horizontally and vertically. If the required
  218. horizontal and vertical magnification factors are different, use the smaller
  219. of the two, centering the rectangle within the window in the other dimension.
  220. </para>
  221. <para>
  222. Destination object may be created using
  223. <methodname>Zend_Pdf_Destination_FitRectangle::create($page, $left, $bottom,
  224. $right, $top)</methodname> method.
  225. </para>
  226. <para>
  227. Where:
  228. </para>
  229. <itemizedlist>
  230. <listitem>
  231. <para>
  232. <varname>$page</varname> is a destination page
  233. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  234. </para>
  235. </listitem>
  236. <listitem>
  237. <para>
  238. <varname>$left</varname> is a left edge of the displayed page
  239. (float).
  240. </para>
  241. </listitem>
  242. <listitem>
  243. <para>
  244. <varname>$bottom</varname> is a bottom edge of the displayed page
  245. (float).
  246. </para>
  247. </listitem>
  248. <listitem>
  249. <para>
  250. <varname>$right</varname> is a right edge of the displayed page (float).
  251. </para>
  252. </listitem>
  253. <listitem>
  254. <para>
  255. <varname>$top</varname> is a top edge of the displayed page (float).
  256. </para>
  257. </listitem>
  258. </itemizedlist>
  259. <para>
  260. <classname>Zend_Pdf_Destination_FitRectangle</classname> class also
  261. provides the following methods:
  262. </para>
  263. <itemizedlist>
  264. <listitem>
  265. <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
  266. </listitem>
  267. <listitem>
  268. <para><methodname>setLeftEdge(float $left)</methodname>;</para>
  269. </listitem>
  270. <listitem>
  271. <para><type>Float</type><methodname>getBottomEdge()</methodname>;</para>
  272. </listitem>
  273. <listitem>
  274. <para><methodname>setBottomEdge(float $bottom)</methodname>;</para>
  275. </listitem>
  276. <listitem>
  277. <para><type>Float</type><methodname>getRightEdge()</methodname>;</para>
  278. </listitem>
  279. <listitem>
  280. <para><methodname>setRightEdge(float $right)</methodname>;</para>
  281. </listitem>
  282. <listitem>
  283. <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
  284. </listitem>
  285. <listitem>
  286. <para><methodname>setTopEdge(float $top)</methodname>;</para>
  287. </listitem>
  288. </itemizedlist>
  289. </sect4>
  290. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box">
  291. <title>Zend_Pdf_Destination_FitBoundingBox</title>
  292. <para>
  293. Display the specified page, with its contents magnified just enough to fit
  294. its bounding box entirely within the window both horizontally and vertically.
  295. If the required horizontal and vertical magnification factors are different,
  296. use the smaller of the two, centering the bounding box within the window in
  297. the other dimension.
  298. </para>
  299. <para>
  300. Destination object may be created using
  301. <methodname>Zend_Pdf_Destination_FitBoundingBox::create($page, $left, $bottom,
  302. $right, $top)</methodname> method.
  303. </para>
  304. <para>
  305. Where <varname>$page</varname> is a destination page
  306. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  307. </para>
  308. </sect4>
  309. <sect4
  310. id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box-horizontally">
  311. <title>Zend_Pdf_Destination_FitBoundingBoxHorizontally</title>
  312. <para>
  313. Display the specified page, with the vertical coordinate top positioned at
  314. the top edge of the window and the contents of the page magnified just enough
  315. to fit the entire width of its bounding box within the window.
  316. </para>
  317. <para>
  318. Destination object may be created using
  319. <methodname>Zend_Pdf_Destination_FitBoundingBoxHorizontally::create($page,
  320. $top)</methodname> method.
  321. </para>
  322. <para>
  323. Where
  324. </para>
  325. <itemizedlist>
  326. <listitem>
  327. <para>
  328. <varname>$page</varname> is a destination page
  329. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  330. </para>
  331. </listitem>
  332. <listitem>
  333. <para>
  334. <varname>$top</varname> is a top edge of the displayed page
  335. (float).
  336. </para>
  337. </listitem>
  338. </itemizedlist>
  339. <para>
  340. <classname>Zend_Pdf_Destination_FitBoundingBoxHorizontally</classname> class
  341. also provides the following methods:
  342. </para>
  343. <itemizedlist>
  344. <listitem>
  345. <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
  346. </listitem>
  347. <listitem>
  348. <para><methodname>setTopEdge(float $top)</methodname>;</para>
  349. </listitem>
  350. </itemizedlist>
  351. </sect4>
  352. <sect4
  353. id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box-vertically">
  354. <title>Zend_Pdf_Destination_FitBoundingBoxVertically</title>
  355. <para>
  356. Display the specified page, with the horizontal coordinate left positioned at
  357. the left edge of the window and the contents of the page magnified just
  358. enough to fit the entire height of its bounding box within the window.
  359. </para>
  360. <para>
  361. Destination object may be created using
  362. <methodname>Zend_Pdf_Destination_FitBoundingBoxVertically::create($page,
  363. $left)</methodname> method.
  364. </para>
  365. <para>
  366. Where
  367. </para>
  368. <itemizedlist>
  369. <listitem>
  370. <para>
  371. <varname>$page</varname> is a destination page
  372. (a <classname>Zend_Pdf_Page</classname> object or a page number).
  373. </para>
  374. </listitem>
  375. <listitem>
  376. <para>
  377. <varname>$left</varname> is a left edge of the displayed page
  378. (float).
  379. </para>
  380. </listitem>
  381. </itemizedlist>
  382. <para>
  383. <classname>Zend_Pdf_Destination_FitBoundingBoxVertically</classname> class
  384. also provides the following methods:
  385. </para>
  386. <itemizedlist>
  387. <listitem>
  388. <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
  389. </listitem>
  390. <listitem>
  391. <para><methodname>setLeftEdge(float $left)</methodname>;</para>
  392. </listitem>
  393. </itemizedlist>
  394. </sect4>
  395. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.named">
  396. <title>Zend_Pdf_Destination_Named</title>
  397. <para>
  398. All destinations listed above are "Explicit Destinations".
  399. </para>
  400. <para>
  401. In addition to this, <acronym>PDF</acronym> document may contain a dictionary
  402. of such destinations which may be used to reference from outside the
  403. <acronym>PDF</acronym> (e.g.
  404. '<filename>http://www.mycompany.com/document.pdf#chapter3</filename>').
  405. </para>
  406. <para>
  407. <classname>Zend_Pdf_Destination_Named</classname> objects allow to refer
  408. destinations from the document named destinations dictionary.
  409. </para>
  410. <para>
  411. Named destination object may be created using
  412. <methodname>Zend_Pdf_Destination_Named::create(string $name)</methodname>
  413. method.
  414. </para>
  415. <para>
  416. <classname>Zend_Pdf_Destination_Named</classname> class provides the only one
  417. additional method:
  418. </para>
  419. <para>
  420. <type>String</type><methodname>getName()</methodname>;
  421. </para>
  422. </sect4>
  423. </sect3>
  424. <sect3 id="zend.pdf.pages.interactive-features.destinations.processing">
  425. <title>Document level destination processing</title>
  426. <para>
  427. <classname>Zend_Pdf</classname> class provides a set of destinations processing
  428. methods.
  429. </para>
  430. <para>
  431. Each destination object (including named destinations) can be resolved using the
  432. <methodname>resolveDestination($destination)</methodname> method. It returns
  433. corresponding <classname>Zend_Pdf_Page</classname> object, if destination target
  434. is found, or <constant>NULL</constant> otherwise.
  435. </para>
  436. <para>
  437. <methodname>Zend_Pdf::resolveDestination()</methodname> method also takes
  438. an optional boolean parameter <varname>$refreshPageCollectionHashes</varname>,
  439. which is <constant>TRUE</constant> by default. It forces
  440. <classname>Zend_Pdf</classname> object to refresh internal page collection hashes
  441. since document pages list may be updated by user using
  442. <varname>Zend_Pdf::$pages</varname> property
  443. (<link linkend="zend.pdf.pages">Working with Pages</link>).
  444. It may be turned off for performance reasons,
  445. if it's known that document pages list wasn't changed since last method
  446. request.
  447. </para>
  448. <para>
  449. Complete list of named destinations can be retrieved using
  450. <methodname>Zend_Pdf::getNamedDestinations()</methodname> method. It returns
  451. an array of <classname>Zend_Pdf_Target</classname> objects, which are actually
  452. either an explicit destination or a GoTo action
  453. (<link linkend="zend.pdf.pages.interactive-features.actions">Actions</link>).
  454. </para>
  455. <para>
  456. <methodname>Zend_Pdf::getNamedDestination(string $name)</methodname> method returns
  457. specified named destination (an explicit destination or a GoTo action).
  458. </para>
  459. <para>
  460. <acronym>PDF</acronym> document named destinations dictionary may be updated with
  461. <methodname>Zend_Pdf::setNamedDestination(string $name, $destination)</methodname>
  462. method, where <varname>$destination</varname> is either an explicit destination
  463. (any destination except <classname>Zend_Pdf_Destination_Named</classname>) or
  464. a GoTo action.
  465. </para>
  466. <para>
  467. If <constant>NULL</constant> is specified in place of
  468. <varname>$destination</varname>, then specified named destination is removed.
  469. </para>
  470. <note>
  471. <para>
  472. Unresolvable named destinations are automatically removed from a document
  473. while document saving.
  474. </para>
  475. </note>
  476. <example id="zend.pdf.interactive-features.destinations.example-1">
  477. <title>Destinations usage example</title>
  478. <programlisting language="php"><![CDATA[
  479. $pdf = new Zend_Pdf();
  480. $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  481. $page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  482. $page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  483. // Page created, but not included into pages list
  484. $pdf->pages[] = $page1;
  485. $pdf->pages[] = $page2;
  486. $destination1 = Zend_Pdf_Destination_Fit::create($page2);
  487. $destination2 = Zend_Pdf_Destination_Fit::create($page3);
  488. // Returns $page2 object
  489. $page = $pdf->resolveDestination($destination1);
  490. // Returns null, page 3 is not included into document yet
  491. $page = $pdf->resolveDestination($destination2);
  492. $pdf->setNamedDestination('Page2', $destination1);
  493. $pdf->setNamedDestination('Page3', $destination2);
  494. // Returns $destination2
  495. $destination = $pdf->getNamedDestination('Page3');
  496. // Returns $destination1
  497. $pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page2'));
  498. // Returns null, page 3 is not included into document yet
  499. $pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page3'));
  500. ]]></programlisting>
  501. </example>
  502. </sect3>
  503. </sect2>
  504. <sect2 id="zend.pdf.pages.interactive-features.actions">
  505. <title>Actions</title>
  506. <para>
  507. Instead of simply jumping to a destination in the document, an annotation or
  508. outline item can specify an action for the viewer application to perform,
  509. such as launching an application, playing a sound, or changing an annotation's
  510. appearance state.
  511. </para>
  512. <sect3 id="zend.pdf.pages.interactive-features.actions.types">
  513. <title>Supported action types</title>
  514. <para>
  515. The following action types are recognized while loading <acronym>PDF</acronym>
  516. document:
  517. </para>
  518. <itemizedlist>
  519. <listitem>
  520. <para>
  521. <classname>Zend_Pdf_Action_GoTo</classname> - go to
  522. a destination in the current document.
  523. </para>
  524. </listitem>
  525. <listitem>
  526. <para>
  527. <classname>Zend_Pdf_Action_GoToR</classname> - go to
  528. a destination in another document.
  529. </para>
  530. </listitem>
  531. <listitem>
  532. <para>
  533. <classname>Zend_Pdf_Action_GoToE</classname> - go to
  534. a destination in an embedded file.
  535. </para>
  536. </listitem>
  537. <listitem>
  538. <para>
  539. <classname>Zend_Pdf_Action_Launch</classname> - launch
  540. an application or open or print a document.
  541. </para>
  542. </listitem>
  543. <listitem>
  544. <para>
  545. <classname>Zend_Pdf_Action_Thread</classname> - begin reading
  546. an article thread.
  547. </para>
  548. </listitem>
  549. <listitem>
  550. <para>
  551. <classname>Zend_Pdf_Action_URI</classname> - resolve a
  552. <acronym>URI</acronym>.
  553. </para>
  554. </listitem>
  555. <listitem>
  556. <para>
  557. <classname>Zend_Pdf_Action_Sound</classname> - play a sound.
  558. </para>
  559. </listitem>
  560. <listitem>
  561. <para>
  562. <classname>Zend_Pdf_Action_Movie</classname> - play a movie.
  563. </para>
  564. </listitem>
  565. <listitem>
  566. <para>
  567. <classname>Zend_Pdf_Action_Hide</classname> - hides or shows
  568. one or more annotations on the screen.
  569. </para>
  570. </listitem>
  571. <listitem>
  572. <para>
  573. <classname>Zend_Pdf_Action_Named</classname> - execute an action
  574. predefined by the viewer application:
  575. </para>
  576. <itemizedlist>
  577. <listitem>
  578. <para>
  579. <emphasis>NextPage</emphasis> - Go to the next page
  580. of the document.
  581. </para>
  582. </listitem>
  583. <listitem>
  584. <para>
  585. <emphasis>PrevPage</emphasis> - Go to the previous
  586. page of the document.
  587. </para>
  588. </listitem>
  589. <listitem>
  590. <para>
  591. <emphasis>FirstPage</emphasis> - Go to the first page
  592. of the document.
  593. </para>
  594. </listitem>
  595. <listitem>
  596. <para>
  597. <emphasis>LastPage</emphasis> - Go to the last page
  598. of the document.
  599. </para>
  600. </listitem>
  601. </itemizedlist>
  602. </listitem>
  603. <listitem>
  604. <para>
  605. <classname>Zend_Pdf_Action_SubmitForm</classname> - send data to
  606. a uniform resource locator.
  607. </para>
  608. </listitem>
  609. <listitem>
  610. <para>
  611. <classname>Zend_Pdf_Action_ResetForm</classname> - set fields
  612. to their default values.
  613. </para>
  614. </listitem>
  615. <listitem>
  616. <para>
  617. <classname>Zend_Pdf_Action_ImportData</classname> - import field
  618. values from a file.
  619. </para>
  620. </listitem>
  621. <listitem>
  622. <para>
  623. <classname>Zend_Pdf_Action_JavaScript</classname> - execute
  624. a JavaScript script.
  625. </para>
  626. </listitem>
  627. <listitem>
  628. <para>
  629. <classname>Zend_Pdf_Action_SetOCGState</classname> - set the state of
  630. one or more optional content groups.
  631. </para>
  632. </listitem>
  633. <listitem>
  634. <para>
  635. <classname>Zend_Pdf_Action_Rendition</classname> - control the
  636. playing of multimedia content (begin, stop, pause, or resume
  637. a playing rendition).
  638. </para>
  639. </listitem>
  640. <listitem>
  641. <para>
  642. <classname>Zend_Pdf_Action_Trans</classname> - update the display
  643. of a document, using a transition dictionary.
  644. </para>
  645. </listitem>
  646. <listitem>
  647. <para>
  648. <classname>Zend_Pdf_Action_GoTo3DView</classname> - set
  649. the current view of a 3D annotation.
  650. </para>
  651. </listitem>
  652. </itemizedlist>
  653. <para>
  654. Only <classname>Zend_Pdf_Action_GoTo</classname> and
  655. <classname>Zend_Pdf_Action_URI</classname> actions can be created by
  656. user now.
  657. </para>
  658. <para>
  659. GoTo action object can be created using
  660. <methodname>Zend_Pdf_Action_GoTo::create($destination)</methodname> method,
  661. where <varname>$destination</varname> is a
  662. <classname>Zend_Pdf_Destination</classname> object or a string which can be used
  663. to identify named destination.
  664. </para>
  665. <para>
  666. <methodname>Zend_Pdf_Action_URI::create($uri[, $isMap])</methodname> method has
  667. to be used to create a URI action (see <acronym>API</acronym> documentation for the
  668. details). Optional <varname>$isMap</varname> parameter is set to
  669. <constant>FALSE</constant> by default.
  670. </para>
  671. <para>
  672. It also supports the following methods:
  673. </para>
  674. </sect3>
  675. <sect3 id="zend.pdf.pages.interactive-features.actions.chaining">
  676. <title>Actions chaining</title>
  677. <para>
  678. Actions objects can be chained using <varname>Zend_Pdf_Action::$next</varname>
  679. public property.
  680. </para>
  681. <para>
  682. It's an array of <classname>Zend_Pdf_Action</classname> objects, which also
  683. may have their sub-actions.
  684. </para>
  685. <para>
  686. <classname>Zend_Pdf_Action</classname> class supports RecursiveIterator interface,
  687. so child actions may be iterated recursively:
  688. </para>
  689. <programlisting language="php"><![CDATA[
  690. $pdf = new Zend_Pdf();
  691. $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  692. $page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  693. // Page created, but not included into pages list
  694. $page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  695. $pdf->pages[] = $page1;
  696. $pdf->pages[] = $page2;
  697. $action1 = Zend_Pdf_Action_GoTo::create(
  698. Zend_Pdf_Destination_Fit::create($page2));
  699. $action2 = Zend_Pdf_Action_GoTo::create(
  700. Zend_Pdf_Destination_Fit::create($page3));
  701. $action3 = Zend_Pdf_Action_GoTo::create(
  702. Zend_Pdf_Destination_Named::create('Chapter1'));
  703. $action4 = Zend_Pdf_Action_GoTo::create(
  704. Zend_Pdf_Destination_Named::create('Chapter5'));
  705. $action2->next[] = $action3;
  706. $action2->next[] = $action4;
  707. $action1->next[] = $action2;
  708. $actionsCount = 1; // Note! Iteration doesn't include top level action and
  709. // walks through children only
  710. $iterator = new RecursiveIteratorIterator(
  711. $action1,
  712. RecursiveIteratorIterator::SELF_FIRST);
  713. foreach ($iterator as $chainedAction) {
  714. $actionsCount++;
  715. }
  716. // Prints 'Actions in a tree: 4'
  717. printf("Actions in a tree: %d\n", $actionsCount++);
  718. ]]></programlisting>
  719. </sect3>
  720. <sect3 id="zend.pdf.pages.interactive-features.actions.open-action">
  721. <title>Document Open Action</title>
  722. <para>
  723. Special open action may be specify a destination to be displayed or an action
  724. to be performed when the document is opened.
  725. </para>
  726. <para>
  727. <methodname>Zend_Pdf_Target Zend_Pdf::getOpenAction()</methodname> method
  728. returns current document open action (or <constant>NULL</constant> if open action
  729. is not set).
  730. </para>
  731. <para>
  732. <methodname>setOpenAction(Zend_Pdf_Target $openAction = null)</methodname>
  733. method sets document open action or clean it if <varname>$openAction</varname>
  734. is <constant>NULL</constant>.
  735. </para>
  736. </sect3>
  737. </sect2>
  738. <sect2 id="zend.pdf.pages.interactive-features.outlines">
  739. <title>Document Outline (bookmarks)</title>
  740. <para>
  741. A PDF document may optionally display a document outline on the screen, allowing
  742. the user to navigate interactively from one part of the document to another.
  743. The outline consists of a tree-structured hierarchy of outline items (sometimes
  744. called bookmarks), which serve as a visual table of contents to display the document's
  745. structure to the user. The user can interactively open and close individual
  746. items by clicking them with the mouse. When an item is open, its immediate children
  747. in the hierarchy become visible on the screen; each child may in turn be
  748. open or closed, selectively revealing or hiding further parts of the hierarchy.
  749. When an item is closed, all of its descendants in the hierarchy are hidden. Clicking
  750. the text of any visible item activates the item, causing the viewer application to
  751. jump to a destination or trigger an action associated with the item.
  752. </para>
  753. <para>
  754. <classname>Zend_Pdf</classname> class provides public property
  755. <varname>$outlines</varname> which is an array of
  756. <classname>Zend_Pdf_Outline</classname> objects.
  757. <programlisting language="php"><![CDATA[
  758. $pdf = Zend_Pdf::load($path);
  759. // Remove outline item
  760. unset($pdf->outlines[0]->childOutlines[1]);
  761. // Set Outline to be displayed in bold
  762. $pdf->outlines[0]->childOutlines[3]->setIsBold(true);
  763. // Add outline entry
  764. $pdf->outlines[0]->childOutlines[5]->childOutlines[] =
  765. Zend_Pdf_Outline::create('Chapter 2', 'chapter_2');
  766. $pdf->save($path, true);
  767. ]]></programlisting>
  768. </para>
  769. <para>
  770. Outline attributes may be retrieved or set using the following methods:
  771. </para>
  772. <itemizedlist>
  773. <listitem>
  774. <para>
  775. <methodname>string getTitle()</methodname> - get outline item title.
  776. </para>
  777. </listitem>
  778. <listitem>
  779. <para>
  780. <methodname>setTitle(string $title)</methodname> - set outline item title.
  781. </para>
  782. </listitem>
  783. <listitem>
  784. <para>
  785. <methodname>boolean isOpen()</methodname> - <constant>TRUE</constant> if outline
  786. is open by default.
  787. </para>
  788. </listitem>
  789. <listitem>
  790. <para>
  791. <methodname>setIsOpen(boolean $isOpen)</methodname> - set isOpen state.
  792. </para>
  793. </listitem>
  794. <listitem>
  795. <para>
  796. <methodname>boolean isItalic()</methodname> - <constant>TRUE</constant> if
  797. outline item is displayed in italic.
  798. </para>
  799. </listitem>
  800. <listitem>
  801. <para>
  802. <methodname>setIsItalic(boolean $isItalic)</methodname> - set
  803. isItalic state.
  804. </para>
  805. </listitem>
  806. <listitem>
  807. <para>
  808. <methodname>boolean isBold()</methodname> - <constant>TRUE</constant> if outline
  809. item is displayed in bold.
  810. </para>
  811. </listitem>
  812. <listitem>
  813. <para>
  814. <methodname>setIsBold(boolean $isBold)</methodname> - set
  815. isBold state.
  816. </para>
  817. </listitem>
  818. <listitem>
  819. <para>
  820. <methodname>Zend_Pdf_Color_Rgb getColor()</methodname> - get outline
  821. text color (<constant>NULL</constant> means black).
  822. </para>
  823. </listitem>
  824. <listitem>
  825. <para>
  826. <methodname>setColor(Zend_Pdf_Color_Rgb $color)</methodname> - set
  827. outline text color (<constant>NULL</constant> means black).
  828. </para>
  829. </listitem>
  830. <listitem>
  831. <para>
  832. <methodname>Zend_Pdf_Target getTarget()</methodname> - get outline
  833. target (action or explicit or named destination object).
  834. </para>
  835. </listitem>
  836. <listitem>
  837. <para>
  838. <methodname>setTarget(Zend_Pdf_Target|string $target)</methodname> - set
  839. outline target (action or destination). String may be used to identify
  840. named destination. <constant>NULL</constant> means 'no target'.
  841. </para>
  842. </listitem>
  843. <listitem>
  844. <para>
  845. <methodname>array getOptions()</methodname> - get outline attributes
  846. as an array.
  847. </para>
  848. </listitem>
  849. <listitem>
  850. <para>
  851. <methodname>setOptions(array $options)</methodname> - set outline options.
  852. The following options are recognized: 'title', 'open', 'color', 'italic',
  853. 'bold', and 'target'.
  854. </para>
  855. </listitem>
  856. </itemizedlist>
  857. <para>
  858. New outline may be created in two ways:
  859. </para>
  860. <itemizedlist>
  861. <listitem>
  862. <para>
  863. <methodname>Zend_Pdf_Outline::create(string $title[, Zend_Pdf_Target|string
  864. $target])</methodname>
  865. </para>
  866. </listitem>
  867. <listitem>
  868. <para>
  869. <methodname>Zend_Pdf_Outline::create(array $options)</methodname>
  870. </para>
  871. </listitem>
  872. </itemizedlist>
  873. <para>
  874. Each outline object may have child outline items listed in
  875. <varname>Zend_Pdf_Outline::$childOutlines</varname> public property.
  876. It's an array of <classname>Zend_Pdf_Outline</classname> objects,
  877. so outlines are organized in a tree.
  878. </para>
  879. <para>
  880. <classname>Zend_Pdf_Outline</classname> class implements RecursiveArray interface,
  881. so child outlines may be recursively iterated using RecursiveIteratorIterator:
  882. </para>
  883. <programlisting language="php"><![CDATA[
  884. $pdf = Zend_Pdf::load($path);
  885. foreach ($pdf->outlines as $documentRootOutlineEntry) {
  886. $iterator = new RecursiveIteratorIterator(
  887. $documentRootOutlineEntry,
  888. RecursiveIteratorIterator::SELF_FIRST
  889. );
  890. foreach ($iterator as $childOutlineItem) {
  891. $OutlineItemTarget = $childOutlineItem->getTarget();
  892. if ($OutlineItemTarget instanceof Zend_Pdf_Destination) {
  893. if ($pdf->resolveDestination($OutlineItemTarget) === null) {
  894. // Mark Outline item with unresolvable destination
  895. // using RED color
  896. $childOutlineItem->setColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
  897. }
  898. } else if ($OutlineItemTarget instanceof Zend_Pdf_Action_GoTo) {
  899. $OutlineItemTarget->setDestination();
  900. if ($pdf->resolveDestination($OutlineItemTarget) === null) {
  901. // Mark Outline item with unresolvable destination
  902. // using RED color
  903. $childOutlineItem->setColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
  904. }
  905. }
  906. }
  907. }
  908. $pdf->save($path, true);
  909. ]]></programlisting>
  910. <note>
  911. <para>
  912. All outline items with unresolved destinations (or destinations of GoTo
  913. actions) are updated while document saving by setting their targets to
  914. <constant>NULL</constant>. So document will not be corrupted by removing pages
  915. referenced by outlines.
  916. </para>
  917. </note>
  918. </sect2>
  919. <sect2 id="zend.pdf.pages.interactive-features.annotations">
  920. <title>Annotations</title>
  921. <para>
  922. An annotation associates an object such as a note, sound, or movie with a location
  923. on a page of a PDF document, or provides a way to interact with the user by means
  924. of the mouse and keyboard.
  925. </para>
  926. <para>
  927. All annotations are represented by <classname>Zend_Pdf_Annotation</classname>
  928. abstract class.
  929. </para>
  930. <para>
  931. Annotation may be attached to a page using
  932. <methodname>Zend_Pdf_Page::attachAnnotation(Zend_Pdf_Annotation
  933. $annotation)</methodname> method.
  934. </para>
  935. <para>
  936. Three types of annotations may be created by user now:
  937. </para>
  938. <itemizedlist>
  939. <listitem>
  940. <para>
  941. <methodname>Zend_Pdf_Annotation_Link::create($x1, $y1, $x2, $y2,
  942. $target)</methodname> where <varname>$target</varname> is an action object
  943. or a destination or string (which may be used in place of named destination
  944. object).
  945. </para>
  946. </listitem>
  947. <listitem>
  948. <para>
  949. <methodname>Zend_Pdf_Annotation_Text::create($x1, $y1, $x2, $y2,
  950. $text)</methodname>
  951. </para>
  952. </listitem>
  953. <listitem>
  954. <para>
  955. <methodname>Zend_Pdf_Annotation_FileAttachment::create($x1, $y1, $x2, $y2,
  956. $fileSpecification)</methodname>
  957. </para>
  958. </listitem>
  959. </itemizedlist>
  960. <para>
  961. A link annotation represents either a hypertext link to a destination elsewhere in
  962. the document or an action to be performed.
  963. </para>
  964. <para>
  965. A text annotation represents a "sticky note" attached to a point in the PDF document.
  966. </para>
  967. <para>
  968. A file attachment annotation contains a reference to a file.
  969. </para>
  970. <para>
  971. The following methods are shared between all annotation types:
  972. </para>
  973. <itemizedlist>
  974. <listitem>
  975. <para><methodname>setLeft(float $left)</methodname></para>
  976. </listitem>
  977. <listitem>
  978. <para><methodname>float getLeft()</methodname></para>
  979. </listitem>
  980. <listitem>
  981. <para><methodname>setRight(float $right)</methodname></para>
  982. </listitem>
  983. <listitem>
  984. <para><methodname>float getRight()</methodname></para>
  985. </listitem>
  986. <listitem>
  987. <para><methodname>setTop(float $top)</methodname></para>
  988. </listitem>
  989. <listitem>
  990. <para><methodname>float getTop()</methodname></para>
  991. </listitem>
  992. <listitem>
  993. <para><methodname>setBottom(float $bottom)</methodname></para>
  994. </listitem>
  995. <listitem>
  996. <para><methodname>float getBottom()</methodname></para>
  997. </listitem>
  998. <listitem>
  999. <para><methodname>setText(string $text)</methodname></para>
  1000. </listitem>
  1001. <listitem>
  1002. <para><methodname>string getText()</methodname></para>
  1003. </listitem>
  1004. </itemizedlist>
  1005. <para>
  1006. Text annotation property is a text to be displayed for the annotation or, if this
  1007. type of annotation does not display text, an alternate description of the annotation's
  1008. contents in human-readable form.
  1009. </para>
  1010. <para>
  1011. Link annotation objects also provide two additional methods:
  1012. </para>
  1013. <itemizedlist>
  1014. <listitem>
  1015. <para>
  1016. <methodname>setDestination(Zend_Pdf_Target|string $target)</methodname>
  1017. </para>
  1018. </listitem>
  1019. <listitem>
  1020. <para>
  1021. <methodname>Zend_Pdf_Target getDestination()</methodname>
  1022. </para>
  1023. </listitem>
  1024. </itemizedlist>
  1025. </sect2>
  1026. </sect1>
  1027. <!--
  1028. vim:se ts=4 sw=4 et:
  1029. -->