Zend_Pdf-InteractiveFeatures.xml 47 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 Zoom Faktor der verwendet werden soll wenn die Seite angezeigt wird.
  22. </para>
  23. </listitem>
  24. </itemizedlist>
  25. <para>
  26. Ziele können mit Outline Elementen ((<link
  27. linkend="zend.pdf.pages.interactive-features.outlines">Document Outline
  28. (bookmarks)</link>), Hinweisen (<link
  29. linkend="zend.pdf.pages.interactive-features.annotations">Annotations</link>), oder
  30. Aktionen (<link linkend="zend.pdf.pages.interactive-features.actions">Actions</link>)
  31. verknüpft werden. In jedem Fall spezifiziert das Ziel die Sicht des Dokuments welche
  32. dargestellt werden soll wenn das Outline Element oder der Hinweis geöffnet, oder die
  33. Aktion durchgeführt werden soll. Zusätzlich kann eine optionale Dokument Öffnungs-Aktion
  34. spezifiziert werden.
  35. </para>
  36. <sect3 id="zend.pdf.pages.interactive-features.destinations.types">
  37. <title>Unterstützte Zieltypen</title>
  38. <para>
  39. Die folgenden Typen werden von der <classname>Zend_Pdf</classname> Komponente
  40. unterstützt.
  41. </para>
  42. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.zoom">
  43. <title>Zend_Pdf_Destination_Zoom</title>
  44. <para>
  45. Zeigt die spezifizierte Seite, mit den Koordinaten (Links, Oben) positioniert
  46. an der oberen-linken Ecke des Fensters und dem Inhalt der Seite vergrößert
  47. auf den Zoom Faktor.
  48. </para>
  49. <para>
  50. Zielobjekte können durch Verwendung der
  51. <methodname>Zend_Pdf_Destination_Zoom::create($page, $left = null, $top = null,
  52. $zoom = null)</methodname> Methode erstellt werden.
  53. </para>
  54. <para>
  55. Wobei:
  56. </para>
  57. <itemizedlist>
  58. <listitem>
  59. <para>
  60. <varname>$page</varname> eine Zielseite ist (ein
  61. <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitennummer).
  62. </para>
  63. </listitem>
  64. <listitem>
  65. <para>
  66. <varname>$left</varname> ist die linke Ecke der angezeigten Seite
  67. (float).
  68. </para>
  69. </listitem>
  70. <listitem>
  71. <para>
  72. <varname>$top</varname> ist eine obere Ecke der angezeigten Seite
  73. (float).
  74. </para>
  75. </listitem>
  76. <listitem>
  77. <para>
  78. <varname>$zoom</varname> ist ein Zoom Faktor (float).
  79. </para>
  80. </listitem>
  81. </itemizedlist>
  82. <para>
  83. <constant>NULL</constant>, wenn es für die <varname>$left</varname>,
  84. <varname>$top</varname> or <varname>$zoom</varname> Parameter spezifiziert wird,
  85. heißt "aktueller Wert der Viewer Anwendung".
  86. </para>
  87. <para>
  88. Die <classname>Zend_Pdf_Destination_Zoom</classname> Klasse bietet die folgenden
  89. Methoden an:
  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. Zeigt die spezifizierte Seite an, wobei der Inhalt soweit vergrössert wird,
  116. dass er auf die komplette Seite passt sowohl Horizontal als auch Vertikal im
  117. Fenster. Wenn die benötigten horizontalen und vertikalen Vergrösserungsfaktoren
  118. unterschiedlich sind, wird der kleinere der zwei verwendet, und die Seite im
  119. Fenster mit der anderen Dimension zentriert.
  120. </para>
  121. <para>
  122. Das Zielobjekt kann erstellt werden indem die
  123. <methodname>Zend_Pdf_Destination_Fit::create($page)</methodname> Methode
  124. verwendet wird.
  125. </para>
  126. <para>
  127. Wobei <varname>$page</varname> eine Zielseite ist (ein
  128. <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitennummer).
  129. </para>
  130. </sect4>
  131. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-horizontally">
  132. <title>Zend_Pdf_Destination_FitHorizontally</title>
  133. <para>
  134. Zeigt die spezifizierte Seite, mit den vertikalen Koordinaten an der oberen Ecke
  135. des Fensters positioniert, an und den Inhalt der Seite gerade genug vergrössert
  136. damit die komplette Breite der Seite in das Fenster passt.
  137. </para>
  138. <para>
  139. Das Zielobjekt kann erstellt werden indem die
  140. <methodname>Zend_Pdf_Destination_FitHorizontally::create($page,
  141. $top)</methodname> Methode verwendet wird.
  142. </para>
  143. <para>
  144. Wobei:
  145. </para>
  146. <itemizedlist>
  147. <listitem>
  148. <para>
  149. <varname>$page</varname> ist eine Zielseite
  150. (ein <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitenzahl).
  151. </para>
  152. </listitem>
  153. <listitem>
  154. <para>
  155. <varname>$top</varname> ist die obere Ecke der angezeigten Seite
  156. (float).
  157. </para>
  158. </listitem>
  159. </itemizedlist>
  160. <para>
  161. Die Klasse <classname>Zend_Pdf_Destination_FitHorizontally</classname> bietet
  162. auch die folgenden Methoden:
  163. </para>
  164. <itemizedlist>
  165. <listitem>
  166. <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
  167. </listitem>
  168. <listitem>
  169. <para><methodname>setTopEdge(float $top)</methodname>;</para>
  170. </listitem>
  171. </itemizedlist>
  172. </sect4>
  173. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-vertically">
  174. <title>Zend_Pdf_Destination_FitVertically</title>
  175. <para>
  176. Zeigt die spezifizierte Seite, mit den horizontalen Koordinaten an der oberen
  177. Ecke des Fensters positioniert, an und den Inhalt der Seite gerade genug
  178. vergrössert damit die komplette Höhe der Seite in das Fenster passt.
  179. </para>
  180. <para>
  181. Das Zielobjekt kann erstellt werden indem die
  182. <methodname>Zend_Pdf_Destination_FitVertically::create($page,
  183. $left)</methodname> Methode verwendet wird.
  184. </para>
  185. <para>
  186. Wobei:
  187. </para>
  188. <itemizedlist>
  189. <listitem>
  190. <para>
  191. <varname>$page</varname> ist eine Zielseite
  192. (ein <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitenzahl).
  193. </para>
  194. </listitem>
  195. <listitem>
  196. <para>
  197. <varname>$left</varname> die linke Ecke der angezeigten Seite ist.
  198. (float).
  199. </para>
  200. </listitem>
  201. </itemizedlist>
  202. <para>
  203. Die Klasse <classname>Zend_Pdf_Destination_FitVertically</classname> bietet auch
  204. die folgenden Methoden:
  205. </para>
  206. <itemizedlist>
  207. <listitem>
  208. <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
  209. </listitem>
  210. <listitem>
  211. <para><methodname>setLeftEdge(float $left)</methodname>;</para>
  212. </listitem>
  213. </itemizedlist>
  214. </sect4>
  215. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-rectangle">
  216. <title>Zend_Pdf_Destination_FitRectangle</title>
  217. <para>
  218. Zeigt die spezifizierte Seite an, wobei der Inhalt gerade genug vergrössert ist
  219. damit er komplett in das Rechteck passt das durch die Koordinaten links, unten,
  220. rechts und oben spezifiziert wird sowohl horizontal als auch vertikal. Wenn die
  221. notwendigen horizontalen und vertikalen Vergrösserungsfaktoren unterschiedlich
  222. sind, wird der kleinere der zwei verwendet, wobei das Rechteck im Fenster durch
  223. Verwendung der andern Dimension zentriert wird.
  224. </para>
  225. <para>
  226. Das Zielobjekt kann erstellt werden indem die
  227. <methodname>Zend_Pdf_Destination_FitRectangle::create($page, $left, $bottom,
  228. $right, $top)</methodname> Methode verwendet wird.
  229. </para>
  230. <para>
  231. Wobei:
  232. </para>
  233. <itemizedlist>
  234. <listitem>
  235. <para>
  236. <varname>$page</varname> ist eine Zielseite
  237. (ein <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitenzahl).
  238. </para>
  239. </listitem>
  240. <listitem>
  241. <para>
  242. <varname>$left</varname> die linke Ecke der angezeigten Seite ist.
  243. (float).
  244. </para>
  245. </listitem>
  246. <listitem>
  247. <para>
  248. <varname>$bottom</varname> die untere Ecke der angezeigten Seite ist
  249. (float).
  250. </para>
  251. </listitem>
  252. <listitem>
  253. <para>
  254. <varname>$right</varname> die rechte Ecke der angezeigten Seite ist
  255. (float).
  256. </para>
  257. </listitem>
  258. <listitem>
  259. <para>
  260. <varname>$top</varname> die obere Ecke der angezeigten Seite ist
  261. (float).
  262. </para>
  263. </listitem>
  264. </itemizedlist>
  265. <para>
  266. Die Klasse <classname>Zend_Pdf_Destination_FitRectangle</classname> bietet auch
  267. die folgenden Methoden an:
  268. </para>
  269. <itemizedlist>
  270. <listitem>
  271. <para><type>Float</type><methodname>getLeftEdge()</methodname>;</para>
  272. </listitem>
  273. <listitem>
  274. <para><methodname>setLeftEdge(float $left)</methodname>;</para>
  275. </listitem>
  276. <listitem>
  277. <para><type>Float</type><methodname>getBottomEdge()</methodname>;</para>
  278. </listitem>
  279. <listitem>
  280. <para><methodname>setBottomEdge(float $bottom)</methodname>;</para>
  281. </listitem>
  282. <listitem>
  283. <para><type>Float</type><methodname>getRightEdge()</methodname>;</para>
  284. </listitem>
  285. <listitem>
  286. <para><methodname>setRightEdge(float $right)</methodname>;</para>
  287. </listitem>
  288. <listitem>
  289. <para><type>Float</type><methodname>getTopEdge()</methodname>;</para>
  290. </listitem>
  291. <listitem>
  292. <para><methodname>setTopEdge(float $top)</methodname>;</para>
  293. </listitem>
  294. </itemizedlist>
  295. </sect4>
  296. <sect4 id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box">
  297. <title>Zend_Pdf_Destination_FitBoundingBox</title>
  298. <para>
  299. Zeigt die spezifizierte Seite an, wobei der Inhalt gerade genug vergrössert ist
  300. damit die Zeichenbox komplett in das Fenster passt, sowohl horizontal als auch
  301. vertikal. Wenn die notwendigen horizontalen und vertikalen
  302. Vergrösserungsfaktoren unterschiedlich sind, wird der kleinere der zwei
  303. verwendet, wobei die Zeichenbox im Fenster durch Verwendung der andern Dimension
  304. zentriert wird.
  305. </para>
  306. <para>
  307. Das Zielobjekt kann erstellt werden indem die
  308. <methodname>Zend_Pdf_Destination_FitBoundingBox::create($page, $left, $bottom,
  309. $right, $top)</methodname> Methode verwendet wird.
  310. </para>
  311. <para>
  312. Wobei <varname>$page</varname> eine Zielseite ist
  313. (ein <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitenzahl).
  314. </para>
  315. </sect4>
  316. <sect4
  317. id="zend.pdf.pages.interactive-features.destinations.types.fit-bounding-box-horizontally">
  318. <title>Zend_Pdf_Destination_FitBoundingBoxHorizontally</title>
  319. <para>
  320. Zeigt die spezifizierte Seite, mit den vertikalen Koordinaten an der oberen Ecke
  321. des Fensters positioniert, an und den Inhalt der Seite gerade genug vergrössert
  322. damit die komplette Breite der Zeichenbox in das Fenster passt.
  323. </para>
  324. <para>
  325. Das Zielobjekt kann erstellt werden indem die
  326. <methodname>Zend_Pdf_Destination_FitBoundingBoxHorizontally::create($page,
  327. $top)</methodname> Methode verwendet wird.
  328. </para>
  329. <para>
  330. Wobei
  331. </para>
  332. <itemizedlist>
  333. <listitem>
  334. <para>
  335. <varname>$page</varname> eine Zielseite ist
  336. (ein <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitenzahl).
  337. </para>
  338. </listitem>
  339. <listitem>
  340. <para>
  341. <varname>$top</varname> ist die obere Ecke der angezeigten Seite
  342. (float).
  343. </para>
  344. </listitem>
  345. </itemizedlist>
  346. <para>
  347. Die Klasse
  348. <classname>Zend_Pdf_Destination_FitBoundingBoxHorizontally</classname> bietet
  349. auch die folgenden Methoden:
  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. Zeigt die spezifizierte Seite, mit den horizontalen Koordinaten an der oberen
  365. Ecke des Fensters positioniert, an und den Inhalt der Seite gerade genug
  366. vergrössert damit die komplette Höhe der Zeichenbox in das Fenster passt.
  367. </para>
  368. <para>
  369. Das Zielobjekt kann erstellt werden indem die
  370. <methodname>Zend_Pdf_Destination_FitBoundingBoxVertically::create($page,
  371. $left)</methodname> Methode verwendet wird.
  372. </para>
  373. <para>
  374. Wobei
  375. </para>
  376. <itemizedlist>
  377. <listitem>
  378. <para>
  379. <varname>$page</varname> eine Zielseite ist
  380. (ein <classname>Zend_Pdf_Page</classname> Objekt oder eine Seitenzahl).
  381. </para>
  382. </listitem>
  383. <listitem>
  384. <para>
  385. <varname>$left</varname> ist die linke Ecke der angezeigten Seite
  386. (float).
  387. </para>
  388. </listitem>
  389. </itemizedlist>
  390. <para>
  391. Die Klasse <classname>Zend_Pdf_Destination_FitBoundingBoxVertically</classname>
  392. bietet auch die folgenden Methoden:
  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. Alle oben aufgeführten Ziele sind "Explizite Ziele".
  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. -->