Zend_Pdf-InteractiveFeatures.xml 46 KB

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