Zend_Pdf-InteractiveFeatures.xml 46 KB

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