Zend_Pdf-InteractiveFeatures.xml 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  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 <constant>TRUE</constant> by default. It forces
  444. <classname>Zend_Pdf</classname> object to refresh internal page collection hashes
  445. since document pages list may be updated by user using
  446. <varname>Zend_Pdf::$pages</varname> property
  447. (<link linkend="zend.pdf.pages">Working with Pages</link>).
  448. It may be turned off for performance reasons,
  449. if it's known that document pages list wasn't changed since last method
  450. request.
  451. </para>
  452. <para>
  453. Complete list of named destinations can be retrieved using
  454. <methodname>Zend_Pdf::getNamedDestinations()</methodname> method. It returns
  455. an array of <classname>Zend_Pdf_Target</classname> objects, which are actually
  456. either an explicit destination or a GoTo action
  457. (<link linkend="zend.pdf.pages.interactive-features.actions">Actions</link>).
  458. </para>
  459. <para>
  460. <methodname>Zend_Pdf::getNamedDestination(string $name)</methodname> method returns
  461. specified named destination (an explicit destination or a GoTo action).
  462. </para>
  463. <para>
  464. <acronym>PDF</acronym> document named destinations dictionary may be updated with
  465. <methodname>Zend_Pdf::setNamedDestination(string $name, $destination)</methodname>
  466. method, where <varname>$destination</varname> is either an explicit destination
  467. (any destination except <classname>Zend_Pdf_Destination_Named</classname>) or
  468. a GoTo action.
  469. </para>
  470. <para>
  471. If <constant>NULL</constant> is specified in place of
  472. <varname>$destination</varname>, then specified named destination is removed.
  473. </para>
  474. <note>
  475. <para>
  476. Unresolvable named destinations are automatically removed from a document
  477. while document saving.
  478. </para>
  479. </note>
  480. <example id="zend.pdf.interactive-features.destinations.example-1">
  481. <title>Destinations usage example</title>
  482. <programlisting language="php"><![CDATA[
  483. $pdf = new Zend_Pdf();
  484. $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  485. $page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  486. $page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  487. // Page created, but not included into pages list
  488. $pdf->pages[] = $page1;
  489. $pdf->pages[] = $page2;
  490. $destination1 = Zend_Pdf_Destination_Fit::create($page2);
  491. $destination2 = Zend_Pdf_Destination_Fit::create($page3);
  492. // Returns $page2 object
  493. $page = $pdf->resolveDestination($destination1);
  494. // Returns null, page 3 is not included into document yet
  495. $page = $pdf->resolveDestination($destination2);
  496. $pdf->setNamedDestination('Page2', $destination1);
  497. $pdf->setNamedDestination('Page3', $destination2);
  498. // Returns $destination2
  499. $destination = $pdf->getNamedDestination('Page3');
  500. // Returns $destination1
  501. $pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page2'));
  502. // Returns null, page 3 is not included into document yet
  503. $pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page3'));
  504. ]]></programlisting>
  505. </example>
  506. </sect3>
  507. </sect2>
  508. <sect2 id="zend.pdf.pages.interactive-features.actions">
  509. <title>Actions</title>
  510. <para>
  511. Instead of simply jumping to a destination in the document, an annotation or
  512. outline item can specify an action for the viewer application to perform,
  513. such as launching an application, playing a sound, or changing an annotation's
  514. appearance state.
  515. </para>
  516. <sect3 id="zend.pdf.pages.interactive-features.actions.types">
  517. <title>Supported action types</title>
  518. <para>
  519. The following action types are recognized while loading <acronym>PDF</acronym>
  520. document:
  521. </para>
  522. <itemizedlist>
  523. <listitem>
  524. <para>
  525. <classname>Zend_Pdf_Action_GoTo</classname> - go to
  526. a destination in the current document.
  527. </para>
  528. </listitem>
  529. <listitem>
  530. <para>
  531. <classname>Zend_Pdf_Action_GoToR</classname> - go to
  532. a destination in another document.
  533. </para>
  534. </listitem>
  535. <listitem>
  536. <para>
  537. <classname>Zend_Pdf_Action_GoToE</classname> - go to
  538. a destination in an embedded file.
  539. </para>
  540. </listitem>
  541. <listitem>
  542. <para>
  543. <classname>Zend_Pdf_Action_Launch</classname> - launch
  544. an application or open or print a document.
  545. </para>
  546. </listitem>
  547. <listitem>
  548. <para>
  549. <classname>Zend_Pdf_Action_Thread</classname> - begin reading
  550. an article thread.
  551. </para>
  552. </listitem>
  553. <listitem>
  554. <para>
  555. <classname>Zend_Pdf_Action_URI</classname> - resolve a
  556. <acronym>URI</acronym>.
  557. </para>
  558. </listitem>
  559. <listitem>
  560. <para>
  561. <classname>Zend_Pdf_Action_Sound</classname> - play a sound.
  562. </para>
  563. </listitem>
  564. <listitem>
  565. <para>
  566. <classname>Zend_Pdf_Action_Movie</classname> - play a movie.
  567. </para>
  568. </listitem>
  569. <listitem>
  570. <para>
  571. <classname>Zend_Pdf_Action_Hide</classname> - hides or shows
  572. one or more annotations on the screen.
  573. </para>
  574. </listitem>
  575. <listitem>
  576. <para>
  577. <classname>Zend_Pdf_Action_Named</classname> - execute an action
  578. predefined by the viewer application:
  579. </para>
  580. <itemizedlist>
  581. <listitem>
  582. <para>
  583. <emphasis>NextPage</emphasis> - Go to the next page
  584. of the document.
  585. </para>
  586. </listitem>
  587. <listitem>
  588. <para>
  589. <emphasis>PrevPage</emphasis> - Go to the previous
  590. page of the document.
  591. </para>
  592. </listitem>
  593. <listitem>
  594. <para>
  595. <emphasis>FirstPage</emphasis> - Go to the first page
  596. of the document.
  597. </para>
  598. </listitem>
  599. <listitem>
  600. <para>
  601. <emphasis>LastPage</emphasis> - Go to the last page
  602. of the document.
  603. </para>
  604. </listitem>
  605. </itemizedlist>
  606. </listitem>
  607. <listitem>
  608. <para>
  609. <classname>Zend_Pdf_Action_SubmitForm</classname> - send data to
  610. a uniform resource locator.
  611. </para>
  612. </listitem>
  613. <listitem>
  614. <para>
  615. <classname>Zend_Pdf_Action_ResetForm</classname> - set fields
  616. to their default values.
  617. </para>
  618. </listitem>
  619. <listitem>
  620. <para>
  621. <classname>Zend_Pdf_Action_ImportData</classname> - import field
  622. values from a file.
  623. </para>
  624. </listitem>
  625. <listitem>
  626. <para>
  627. <classname>Zend_Pdf_Action_JavaScript</classname> - execute
  628. a JavaScript script.
  629. </para>
  630. </listitem>
  631. <listitem>
  632. <para>
  633. <classname>Zend_Pdf_Action_SetOCGState</classname> - set the state of
  634. one or more optional content groups.
  635. </para>
  636. </listitem>
  637. <listitem>
  638. <para>
  639. <classname>Zend_Pdf_Action_Rendition</classname> - control the
  640. playing of multimedia content (begin, stop, pause, or resume
  641. a playing rendition).
  642. </para>
  643. </listitem>
  644. <listitem>
  645. <para>
  646. <classname>Zend_Pdf_Action_Trans</classname> - update the display
  647. of a document, using a transition dictionary.
  648. </para>
  649. </listitem>
  650. <listitem>
  651. <para>
  652. <classname>Zend_Pdf_Action_GoTo3DView</classname> - set
  653. the current view of a 3D annotation.
  654. </para>
  655. </listitem>
  656. </itemizedlist>
  657. <para>
  658. Only <classname>Zend_Pdf_Action_GoTo</classname> and
  659. <classname>Zend_Pdf_Action_URI</classname> actions can be created by
  660. user now.
  661. </para>
  662. <para>
  663. GoTo action object can be created using
  664. <methodname>Zend_Pdf_Action_GoTo::create($destination)</methodname> method,
  665. where <varname>$destination</varname> is a
  666. <classname>Zend_Pdf_Destination</classname> object or a string which can be used
  667. to identify named destination.
  668. </para>
  669. <para>
  670. <methodname>Zend_Pdf_Action_URI::create($uri[, $isMap])</methodname> method has
  671. to be used to create a URI action (see API documentation for the details).
  672. Optional <varname>$isMap</varname> parameter is set to <constant>FALSE</constant>
  673. by default.
  674. </para>
  675. <para>
  676. It also supports the following methods:
  677. </para>
  678. </sect3>
  679. <sect3 id="zend.pdf.pages.interactive-features.actions.chaining">
  680. <title>Actions chaining</title>
  681. <para>
  682. Actions objects can be chained using <varname>Zend_Pdf_Action::$next</varname>
  683. public property.
  684. </para>
  685. <para>
  686. It's an array of <classname>Zend_Pdf_Action</classname> objects, which also
  687. may have their sub-actions.
  688. </para>
  689. <para>
  690. <classname>Zend_Pdf_Action</classname> class supports RecursiveIterator interface,
  691. so child actions may be iterated recursively:
  692. </para>
  693. <programlisting language="php"><![CDATA[
  694. $pdf = new Zend_Pdf();
  695. $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  696. $page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  697. // Page created, but not included into pages list
  698. $page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
  699. $pdf->pages[] = $page1;
  700. $pdf->pages[] = $page2;
  701. $action1 = Zend_Pdf_Action_GoTo::create(
  702. Zend_Pdf_Destination_Fit::create($page2));
  703. $action2 = Zend_Pdf_Action_GoTo::create(
  704. Zend_Pdf_Destination_Fit::create($page3));
  705. $action3 = Zend_Pdf_Action_GoTo::create(
  706. Zend_Pdf_Destination_Named::create('Chapter1'));
  707. $action4 = Zend_Pdf_Action_GoTo::create(
  708. Zend_Pdf_Destination_Named::create('Chapter5'));
  709. $action2->next[] = $action3;
  710. $action2->next[] = $action4;
  711. $action1->next[] = $action2;
  712. $actionsCount = 1; // Note! Iteration doesn't include top level action and
  713. // walks through children only
  714. $iterator = new RecursiveIteratorIterator(
  715. $action1,
  716. RecursiveIteratorIterator::SELF_FIRST);
  717. foreach ($iterator as $chainedAction) {
  718. $actionsCount++;
  719. }
  720. // Prints 'Actions in a tree: 4'
  721. printf("Actions in a tree: %d\n", $actionsCount++);
  722. ]]></programlisting>
  723. </sect3>
  724. <sect3 id="zend.pdf.pages.interactive-features.actions.open-action">
  725. <title>Document Open Action</title>
  726. <para>
  727. Special open action may be specify a destination to be displayed or an action
  728. to be performed when the document is opened.
  729. </para>
  730. <para>
  731. <methodname>Zend_Pdf_Target Zend_Pdf::getOpenAction()</methodname> method
  732. returns current document open action (or <constant>NULL</constant> if open action
  733. is not set).
  734. </para>
  735. <para>
  736. <methodname>setOpenAction(Zend_Pdf_Target $openAction = null)</methodname>
  737. method sets document open action or clean it if <varname>$openAction</varname>
  738. is <constant>NULL</constant>.
  739. </para>
  740. </sect3>
  741. </sect2>
  742. <sect2 id="zend.pdf.pages.interactive-features.outlines">
  743. <title>Document Outline (bookmarks)</title>
  744. <para>
  745. A PDF document may optionally display a document outline on the screen, allowing
  746. the user to navigate interactively from one part of the document to another.
  747. The outline consists of a tree-structured hierarchy of outline items (sometimes
  748. called bookmarks), which serve as a visual table of contents to display the document's
  749. structure to the user. The user can interactively open and close individual
  750. items by clicking them with the mouse. When an item is open, its immediate children
  751. in the hierarchy become visible on the screen; each child may in turn be
  752. open or closed, selectively revealing or hiding further parts of the hierarchy.
  753. When an item is closed, all of its descendants in the hierarchy are hidden. Clicking
  754. the text of any visible item activates the item, causing the viewer application to
  755. jump to a destination or trigger an action associated with the item.
  756. </para>
  757. <para>
  758. <classname>Zend_Pdf</classname> class provides public property
  759. <varname>$outlines</varname> which is an array of
  760. <classname>Zend_Pdf_Outline</classname> objects.
  761. <programlisting language="php"><![CDATA[
  762. $pdf = Zend_Pdf::load($path);
  763. // Remove outline item
  764. unset($pdf->outlines[0]->childOutlines[1]);
  765. // Set Outline to be displayed in bold
  766. $pdf->outlines[0]->childOutlines[3]->setIsBold(true);
  767. // Add outline entry
  768. $pdf->outlines[0]->childOutlines[5]->childOutlines[] =
  769. Zend_Pdf_Outline::create('Chapter 2', 'chapter_2');
  770. $pdf->save($path, true);
  771. ]]></programlisting>
  772. </para>
  773. <para>
  774. Outline attributes may be retrieved or set using the following methods:
  775. </para>
  776. <itemizedlist>
  777. <listitem>
  778. <para>
  779. <methodname>string getTitle()</methodname> - get outline item title.
  780. </para>
  781. </listitem>
  782. <listitem>
  783. <para>
  784. <methodname>setTitle(string $title)</methodname> - set outline item title.
  785. </para>
  786. </listitem>
  787. <listitem>
  788. <para>
  789. <methodname>boolean isOpen()</methodname> - <constant>TRUE</constant> if outline
  790. is open by default.
  791. </para>
  792. </listitem>
  793. <listitem>
  794. <para>
  795. <methodname>setIsOpen(boolean $isOpen)</methodname> - set isOpen state.
  796. </para>
  797. </listitem>
  798. <listitem>
  799. <para>
  800. <methodname>boolean isItalic()</methodname> - <constant>TRUE</constant> if
  801. outline item is displayed in italic.
  802. </para>
  803. </listitem>
  804. <listitem>
  805. <para>
  806. <methodname>setIsItalic(boolean $isItalic)</methodname> - set
  807. isItalic state.
  808. </para>
  809. </listitem>
  810. <listitem>
  811. <para>
  812. <methodname>boolean isBold()</methodname> - <constant>TRUE</constant> if outline
  813. item is displayed in bold.
  814. </para>
  815. </listitem>
  816. <listitem>
  817. <para>
  818. <methodname>setIsBold(boolean $isBold)</methodname> - set
  819. isBold state.
  820. </para>
  821. </listitem>
  822. <listitem>
  823. <para>
  824. <methodname>Zend_Pdf_Color_Rgb getColor()</methodname> - get outline
  825. text color (<constant>NULL</constant> means black).
  826. </para>
  827. </listitem>
  828. <listitem>
  829. <para>
  830. <methodname>setColor(Zend_Pdf_Color_Rgb $color)</methodname> - set
  831. outline text color (<constant>NULL</constant> means black).
  832. </para>
  833. </listitem>
  834. <listitem>
  835. <para>
  836. <methodname>Zend_Pdf_Target getTarget()</methodname> - get outline
  837. target (action or explicit or named destination object).
  838. </para>
  839. </listitem>
  840. <listitem>
  841. <para>
  842. <methodname>setTarget(Zend_Pdf_Target|string $target)</methodname> - set
  843. outline target (action or destination). String may be used to identify
  844. named destination. <constant>NULL</constant> means 'no target'.
  845. </para>
  846. </listitem>
  847. <listitem>
  848. <para>
  849. <methodname>array getOptions()</methodname> - get outline attributes
  850. as an array.
  851. </para>
  852. </listitem>
  853. <listitem>
  854. <para>
  855. <methodname>setOptions(array $options)</methodname> - set outline options.
  856. The following options are recognized: 'title', 'open', 'color', 'italic',
  857. 'bold', and 'target'.
  858. </para>
  859. </listitem>
  860. </itemizedlist>
  861. <para>
  862. New outline may be created in two ways:
  863. </para>
  864. <itemizedlist>
  865. <listitem>
  866. <para>
  867. <methodname>Zend_Pdf_Outline::create(string $title[, Zend_Pdf_Target|string $target])</methodname>
  868. </para>
  869. </listitem>
  870. <listitem>
  871. <para>
  872. <methodname>Zend_Pdf_Outline::create(array $options)</methodname>
  873. </para>
  874. </listitem>
  875. </itemizedlist>
  876. <para>
  877. Each outline object may have child outline items listed in
  878. <varname>Zend_Pdf_Outline::$childOutlines</varname> public property.
  879. It's an array of <classname>Zend_Pdf_Outline</classname> objects,
  880. so outlines are organized in a tree.
  881. </para>
  882. <para>
  883. <classname>Zend_Pdf_Outline</classname> class implements RecursiveArray interface,
  884. so child outlines may be recursively iterated using RecursiveIteratorIterator:
  885. <programlisting language="php"><![CDATA[
  886. $pdf = Zend_Pdf::load($path);
  887. foreach ($pdf->outlines as $documentRootOutlineEntry) {
  888. $iterator = new RecursiveIteratorIterator(
  889. $documentRootOutlineEntry,
  890. RecursiveIteratorIterator::SELF_FIRST
  891. );
  892. foreach ($iterator as $childOutlineItem) {
  893. $OutlineItemTarget = $childOutlineItem->getTarget();
  894. if ($OutlineItemTarget instanceof Zend_Pdf_Destination) {
  895. if ($pdf->resolveDestination($OutlineItemTarget) === null) {
  896. // Mark Outline item with unresolvable destination
  897. // using RED color
  898. $childOutlineItem->setColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
  899. }
  900. } else if ($OutlineItemTarget instanceof Zend_Pdf_Action_GoTo) {
  901. $OutlineItemTarget->setDestination();
  902. if ($pdf->resolveDestination($OutlineItemTarget) === null) {
  903. // Mark Outline item with unresolvable destination
  904. // using RED color
  905. $childOutlineItem->setColor(new Zend_Pdf_Color_Rgb(1, 0, 0));
  906. }
  907. }
  908. }
  909. }
  910. $pdf->save($path, true);
  911. ]]></programlisting>
  912. </para>
  913. <note>
  914. <para>
  915. All outline items with unresolved destinations (or destinations of GoTo
  916. actions) are updated while document saving by setting their targets to
  917. <constant>NULL</constant>. So document will not be corrupted by removing pages
  918. referenced by outlines.
  919. </para>
  920. </note>
  921. </sect2>
  922. <sect2 id="zend.pdf.pages.interactive-features.annotations">
  923. <title>Annotations</title>
  924. <para>
  925. An annotation associates an object such as a note, sound, or movie with a location
  926. on a page of a PDF document, or provides a way to interact with the user by means
  927. of the mouse and keyboard.
  928. </para>
  929. <para>
  930. All annotations are represented by <classname>Zend_Pdf_Annotation</classname>
  931. abstract class.
  932. </para>
  933. <para>
  934. Annotation may be attached to a page using
  935. <methodname>Zend_Pdf_Page::attachAnnotation(Zend_Pdf_Annotation $annotation)</methodname>
  936. method.
  937. </para>
  938. <para>
  939. Three types of annotations may be created by user now:
  940. </para>
  941. <itemizedlist>
  942. <listitem>
  943. <para>
  944. <methodname>Zend_Pdf_Annotation_Link::create($x1, $y1, $x2, $y2, $target)</methodname>
  945. where <varname>$target</varname> is an action object or a destination or
  946. string (which may be used in place of named destination object).
  947. </para>
  948. </listitem>
  949. <listitem>
  950. <para>
  951. <methodname>Zend_Pdf_Annotation_Text::create($x1, $y1, $x2, $y2, $text)</methodname>
  952. </para>
  953. </listitem>
  954. <listitem>
  955. <para>
  956. <methodname>Zend_Pdf_Annotation_FileAttachment::create($x1, $y1, $x2, $y2, $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. -->