Zend_Pdf-Drawing.xml 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 15341 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="zend.pdf.drawing">
  5. <title>Zeichnen</title>
  6. <sect2 id="zend.pdf.drawing.geometry">
  7. <title>Geometrie</title>
  8. <para>
  9. PDF verwendet die selbe Geometrie wie PostScript. Sie beginnt an der linken unteren
  10. Ecke der Seite und wird in Punkten (1/72 Zoll) gemessen.
  11. </para>
  12. <para>
  13. Die Seitengröße kann vom Seitenobjekt erhalten werden:
  14. </para>
  15. <programlisting role="php"><![CDATA[
  16. $width = $pdfPage->getWidth();
  17. $height = $pdfPage->getHeight();
  18. ]]></programlisting>
  19. </sect2>
  20. <sect2 id="zend.pdf.drawing.color">
  21. <title>Farben</title>
  22. <para>
  23. PDF bietet leistungsfähige Möglichkeiten für die Farbdarstellung. Die
  24. <classname>Zend_Pdf</classname> Komponente unterstützt die Grauskala sowie RGB und CYMK
  25. Farbräume. Jede kann überall verwendet werden, wo ein
  26. <classname>Zend_Pdf_Color</classname> Objekt benötigt wird. Die
  27. <classname>Zend_Pdf_Color_GrayScale</classname>,
  28. <classname>Zend_Pdf_Color_Rgb</classname> und <classname>Zend_Pdf_Color_Cmyk</classname>
  29. Klassen stellen folgende Funktionalitäten bereit:
  30. </para>
  31. <programlisting role="php"><![CDATA[
  32. // $grayLevel (Fließkommazahl). 0.0 (schwarz) - 1.0 (weiß)
  33. $color1 = new Zend_Pdf_Color_GrayScale($grayLevel);
  34. // $r, $g, $b (Fließkommazahlen). 0.0 (min Helligkeit) - 1.0 (max Helligkeit)
  35. $color2 = new Zend_Pdf_Color_Rgb($r, $g, $b);
  36. // $c, $m, $y, $k (Fließkommazahlen). 0.0 (min Helligkeit) - 1.0 (max Helligkeit)
  37. $color3 = new Zend_Pdf_Color_Cmyk($c, $m, $y, $k);
  38. ]]></programlisting>
  39. <para>
  40. HTML style colors are also provided with <classname>Zend_Pdf_Color_Html</classname> class:
  41. </para>
  42. <programlisting role="php"><![CDATA[
  43. $color1 = new Zend_Pdf_Color_Html('#3366FF');
  44. $color2 = new Zend_Pdf_Color_Html('silver');
  45. $color3 = new Zend_Pdf_Color_Html('forestgreen');
  46. ]]></programlisting>
  47. </sect2>
  48. <sect2 id="zend.pdf.drawing.shape-drawing">
  49. <title>Zeichnen von Formen</title>
  50. <para>
  51. Alle Zeichenoperationen können im Kontext einer PDF Seite durchgeführt werden.
  52. </para>
  53. <para>
  54. Die <classname>Zend_Pdf_Page</classname> Klass stellt einen Satz von einfachen Formen
  55. bereit:
  56. </para>
  57. <programlisting role="php"><![CDATA[
  58. /**
  59. * Zeichne eine Linie von x1,y1 nach x2,y2.
  60. *
  61. * @param float $x1
  62. * @param float $y1
  63. * @param float $x2
  64. * @param float $y2
  65. * @return Zend_Pdf_Page
  66. */
  67. public function drawLine($x1, $y1, $x2, $y2);
  68. ]]></programlisting>
  69. <programlisting role="php"><![CDATA[
  70. /**
  71. * Zeichne ein Rechteck.
  72. *
  73. * Füllarten:
  74. * Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fülle und strichliere
  75. * das Rechteck (Standard)
  76. * Zend_Pdf_Page::SHAPE_DRAW_STROKE - strichele das Rechteck
  77. * Zend_Pdf_Page::SHAPE_DRAW_FILL - fülle das Rechteck
  78. *
  79. * @param float $x1
  80. * @param float $y1
  81. * @param float $x2
  82. * @param float $y2
  83. * @param integer $fillType
  84. * @return Zend_Pdf_Page
  85. */
  86. public function drawRectangle($x1, $y1, $x2, $y2,
  87. $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
  88. ]]></programlisting>
  89. <programlisting role="php"><![CDATA[
  90. /**
  91. * Zeichne ein Polygon
  92. *
  93. * Wenn $fillType Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE oder
  94. * Zend_Pdf_Page::SHAPE_DRAW_FILL ist, wird das Polygon automatisch geschlossen.
  95. * Für eine detaillierte Beschreibung dieser Methode schaue in eine PDF Dokumentation
  96. * (Kapitel 4.4.2 Path painting Operators, Filling)
  97. *
  98. * @param array $x - Array mit Floats (die X Koordinaten der Eckpunkte)
  99. * @param array $y - Array mit Floats (the Y Koordinaten der Eckpunkte)
  100. * @param integer $fillType
  101. * @param integer $fillMethod
  102. * @return Zend_Pdf_Page
  103. */
  104. public function drawPolygon($x, $y,
  105. $fillType =
  106. Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,
  107. $fillMethod =
  108. Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
  109. ]]></programlisting>
  110. <programlisting role="php"><![CDATA[
  111. /**
  112. * Zeichne einen Kreis mit dem Mittelpunkt x, y dem Radius radius.
  113. *
  114. * Winkel werden im Bogenmaß angegeben
  115. *
  116. * Methoden Signaturen:
  117. * drawCircle($x, $y, $radius);
  118. * drawCircle($x, $y, $radius, $fillType);
  119. * drawCircle($x, $y, $radius, $startAngle, $endAngle);
  120. * drawCircle($x, $y, $radius, $startAngle, $endAngle, $fillType);
  121. *
  122. *
  123. * Es ist kein echter Kreis, weil PDF nur kubische Bezierkurven
  124. * unterstützt. Aber es ist eine sehr Annäherung.
  125. * Es unterscheidet sich von echten Kreisen maximal um 0.00026 Radien
  126. * (Bei PI/8, 3*PI/8, 5*PI/8, 7*PI/8, 9*PI/8, 11*PI/8, 13*PI/8 und
  127. * 15*PI/8 Winkeln). Bei 0, PI/4, PI/2, 3*PI/4, PI, 5*PI/4, 3*PI/2 und
  128. * 7*PI/4 ist es exakt eine Tangente zu einem Kreis.
  129. *
  130. * @param float $x
  131. * @param float $y
  132. * @param float $radius
  133. * @param mixed $param4
  134. * @param mixed $param5
  135. * @param mixed $param6
  136. * @return Zend_Pdf_Page
  137. */
  138. public function drawCircle($x,
  139. $y,
  140. $radius,
  141. $param4 = null,
  142. $param5 = null,
  143. $param6 = null);
  144. ]]></programlisting>
  145. <programlisting role="php"><![CDATA[
  146. /**
  147. * Zeichne eine Ellipse innerhalb des angegebenen Rechtecks.
  148. *
  149. * Methoden Signaturen:
  150. * drawEllipse($x1, $y1, $x2, $y2);
  151. * drawEllipse($x1, $y1, $x2, $y2, $fillType);
  152. * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
  153. * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle, $fillType);
  154. *
  155. * Winkel werden im Bogenmaß angegeben
  156. *
  157. * @param float $x1
  158. * @param float $y1
  159. * @param float $x2
  160. * @param float $y2
  161. * @param mixed $param5
  162. * @param mixed $param6
  163. * @param mixed $param7
  164. * @return Zend_Pdf_Page
  165. */
  166. public function drawEllipse($x1,
  167. $y1,
  168. $x2,
  169. $y2,
  170. $param5 = null,
  171. $param6 = null,
  172. $param7 = null);
  173. ]]></programlisting>
  174. </sect2>
  175. <sect2 id="zend.pdf.drawing.text-drawing">
  176. <title>Zeichnen von Text</title>
  177. <para>
  178. Auch alle Textoperationen können im Kontext einer PDF Seite durchgeführt werden. Du
  179. kannst eine einzige Textzeile an jeder Position auf der Seite durch Übergabe der X und
  180. Y Koordinaten für die Grundlinie zeichnen. Der aktuelle Zeichensatz und die aktuelle
  181. Zeichengröße werden für die Textoperationen verwendet (beachte die detaillierte
  182. Beschreibung unten).
  183. </para>
  184. <programlisting role="php"><![CDATA[
  185. /**
  186. * Zeichne eine Textzeile an einer bestimmten Position.
  187. *
  188. * @param string $text
  189. * @param float $x
  190. * @param float $y
  191. * @param string $charEncoding (optional) Zeichencodierung des
  192. * Quelltexts. Standard ist die aktuelle "locale".
  193. * @throws Zend_Pdf_Exception
  194. * @return Zend_Pdf_Page
  195. */
  196. public function drawText($text, $x, $y, $charEncoding = '');
  197. ]]></programlisting>
  198. <example id="zend.pdf.drawing.text-drawing.example-1">
  199. <title>Zeichne einen String auf der Seite</title>
  200. <programlisting role="php"><![CDATA[
  201. ...
  202. $pdfPage->drawText('Hello world!', 72, 720);
  203. ...
  204. ]]></programlisting>
  205. </example>
  206. <para>
  207. Standardmäßig werden Textstrings unter Verwendung der Zeichenkodierungsmethode der
  208. aktuelle "locale" interpretiert. Wenn du einen String hast, der eine andere
  209. Zeichenkodierungsmethode verwendet (wie zum Beispiel ein UTF-8 String, der aus einer
  210. Datei auf der Platte gelesen wurde, oder ein MacRoman String, der aus einer älteren
  211. Datenbank erhalten wurde), kannst du die Zeichenkodierung zum Zeitpunkt des Zeichnens
  212. angeben und <classname>Zend_Pdf</classname> wird die Konvertierung für dich durchführen.
  213. Du kannst Quellstrings in jeder Kodierungsmethode übergeben, die von PHP's
  214. <code><ulink url="http://www.php.net/manual/function.iconv.php">iconv()</ulink></code>
  215. Funktion unterstützt wird.
  216. </para>
  217. <example id="zend.pdf.drawing.text-drawing.example-2">
  218. <title>Zeiche einen UTF-8 kodierten String auf der Seite</title>
  219. <programlisting role="php"><![CDATA[
  220. ...
  221. // Lese einen UTF-8 kodierten String von der Platte
  222. $unicodeString = fread($fp, 1024);
  223. // Zeichne den String auf der Seite
  224. $pdfPage->drawText($unicodeString, 72, 720, 'UTF-8');
  225. ...
  226. ]]></programlisting>
  227. </example>
  228. </sect2>
  229. <sect2 id="zend.pdf.drawing.using-fonts">
  230. <title>Verwendung von Zeichensätzen</title>
  231. <para>
  232. <classname>Zend_Pdf_Page::drawText()</classname> verwendet den aktuellen Zeichensatz und
  233. die aktuelle Zeichengröße der Seite, die mit der Methode
  234. <classname>Zend_Pdf_Page::setFont()</classname> festgelegt werden:
  235. </para>
  236. <programlisting role="php"><![CDATA[
  237. /**
  238. * Lege den aktuellen Zeichensatz fest.
  239. *
  240. * @param Zend_Pdf_Resource_Font $font
  241. * @param float $fontSize
  242. * @return Zend_Pdf_Page
  243. */
  244. public function setFont(Zend_Pdf_Resource_Font $font, $fontSize);
  245. ]]></programlisting>
  246. <para>
  247. PDF Dokumente unterstützt PostScript Type1 und TrueType Zeichensätze, sowie die zwei
  248. speziellen PDF Typen Type3 und zusammengesetzte Zeichensätze (composite fonts). Es gibt
  249. zudem 14 Type1 Standardzeichensätze, die von jedem PDF Viewer bereit gestellt werden:
  250. Courier (4 Stile), Helvetica (4 Stile), Times (4 Stile), Symbol und Zapf Dingbats.
  251. </para>
  252. <para>
  253. Die <classname>Zend_Pdf</classname> Komponente unterstützt derzeit diese 14
  254. Standardzeichensätze sowie deine eigenen TrueType Zeichensätze. Zeichensatzobjekte
  255. können über eine der zwei Fabrikmethoden (factory methods) erhalten werden:
  256. <classname>Zend_Pdf_Font::fontWithName($fontName)</classname> für die 14 PDF
  257. Standardzeichensätze oder <classname>Zend_Pdf_Font::fontWithPath($filePath)</classname>
  258. für eigene Zeichensätze.
  259. </para>
  260. <example id="zend.pdf.drawing.using-fonts.example-1">
  261. <title>Erstelle einen Standardzeichensatz</title>
  262. <programlisting role="php"><![CDATA[
  263. ...
  264. // Erstelle einen neuen Zeichensatz
  265. $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
  266. // Wende Zeichensatz an
  267. $pdfPage->setFont($font, 36);
  268. ...
  269. ]]></programlisting>
  270. </example>
  271. <para>
  272. Die Zeichensatzkonstanten für die 14 Standardzeichensätze sind innerhalb der
  273. <classname>Zend_Pdf_Font</classname> Klasse definiert:
  274. <itemizedlist>
  275. <listitem>
  276. <para>Zend_Pdf_Font::FONT_COURIER</para>
  277. </listitem>
  278. <listitem>
  279. <para>Zend_Pdf_Font::FONT_COURIER_BOLD</para>
  280. </listitem>
  281. <listitem>
  282. <para>Zend_Pdf_Font::FONT_COURIER_ITALIC</para>
  283. </listitem>
  284. <listitem>
  285. <para>Zend_Pdf_Font::FONT_COURIER_BOLDITALIC</para>
  286. </listitem>
  287. <listitem>
  288. <para>Zend_Pdf_Font::FONT_TIMES_ROMAN</para>
  289. </listitem>
  290. <listitem>
  291. <para>Zend_Pdf_Font::FONT_TIMES_BOLD</para>
  292. </listitem>
  293. <listitem>
  294. <para>Zend_Pdf_Font::FONT_TIMES_ITALIC</para>
  295. </listitem>
  296. <listitem>
  297. <para>Zend_Pdf_Font::FONT_TIMES_BOLDITALIC</para>
  298. </listitem>
  299. <listitem>
  300. <para>Zend_Pdf_Font::FONT_HELVETICA</para>
  301. </listitem>
  302. <listitem>
  303. <para>Zend_Pdf_Font::FONT_HELVETICA_BOLD</para>
  304. </listitem>
  305. <listitem>
  306. <para>Zend_Pdf_Font::FONT_HELVETICA_ITALIC</para>
  307. </listitem>
  308. <listitem>
  309. <para>Zend_Pdf_Font::FONT_HELVETICA_BOLDITALIC</para>
  310. </listitem>
  311. <listitem>
  312. <para>Zend_Pdf_Font::FONT_SYMBOL</para>
  313. </listitem>
  314. <listitem>
  315. <para>Zend_Pdf_Font::FONT_ZAPFDINGBATS</para>
  316. </listitem>
  317. </itemizedlist>
  318. </para>
  319. <para>
  320. Du kannst außerdem jeden individuellen TrueType Zeichensatz (welcher normalerweise eine
  321. '.ttf' Erweiterung hat) oder einen OpenType Zeichensatz ('.otf' Erweiterung) verwenden,
  322. wenn er TrueType Konturen enthält. Bisher nicht unterstützt, aber für zukünftige
  323. Versionen geplant, sind Mac OS X .dfont Dateien und Microsoft TrueType Collection
  324. ('.ttc' Erweiterung) Dateien.
  325. </para>
  326. <para>
  327. Um einen TrueType Zeichensatz zu verwenden, mußt du den kompletten Verzeichnispfad zum
  328. Zeichensatzprogramm angeben. Wenn der Zeichensatz aus welchem Grund auch immer nicht
  329. gelesen werden kann oder wenn es kein TrueType Zeichensatz ist, wird the Fabrikmethode
  330. eine Ausnahme werfen:
  331. </para>
  332. <example id="zend.pdf.drawing.using-fonts.example-2">
  333. <title>Erstelle einen TrueType Zeichensatz</title>
  334. <programlisting role="php"><![CDATA[
  335. ...
  336. // Erstelle einen neuen Zeichensatz
  337. $goodDogCoolFont = Zend_Pdf_Font::fontWithPath('/path/to/GOODDC__.TTF');
  338. // Verwende den Zeichensatz
  339. $pdfPage->setFont($goodDogCoolFont, 36);
  340. ...
  341. ]]></programlisting>
  342. </example>
  343. <para>
  344. Standardmäßig werden eigene Zeichensätze in das erstellte PDF Dokument eingebettet. Dies
  345. ermöglicht den Empfänger, die Seite wie beabsichtigt anzuschauen, sogar wenn sie den
  346. entsprechenden Zeichensatz auf ihrem System gar nicht installiert haben. Wenn du dich
  347. über die Dateigröße sorgst, kannst du angeben, dass das Zeichensatzprogramm nicht
  348. eingebettet wird, indem du eine 'nicht einbetten' Option an die Fabrikmethode übergibst:
  349. </para>
  350. <example id="zend.pdf.drawing.using-fonts.example-3">
  351. <title>
  352. Erstelle einen TrueType Zeichensatz, aber bette ihn nicht in das PDF Dokument ein.
  353. </title>
  354. <programlisting role="php"><![CDATA[
  355. ...
  356. // Erstelle einen neuen Zeichensatz
  357. $goodDogCoolFont = Zend_Pdf_Font::fontWithPath('/path/to/GOODDC__.TTF',
  358. Zend_Pdf_Font::EMBED_DONT_EMBED);
  359. // Verwende den Zeichensatz
  360. $pdfPage->setFont($goodDogCoolFont, 36);
  361. ...
  362. ]]></programlisting>
  363. </example>
  364. <para>
  365. Wenn das Zeichensatzprogramm nicht eingebettet wurde, aber den Empfänger der PDF Datei
  366. diesen Zeichensatz auf seinem System installiert hat, wird er das Dokument so sehen wie
  367. beabsichtigt. Wenn sie nicht den korrekten Zeichensatz installiert haben, wird der PDF
  368. Viewer sich bemühen, um einen Ersatz herzustellen.
  369. </para>
  370. <para>
  371. Einige Zeichensätze haben sehr spezielle Lizensierungsregeln, die das Einbetten in PDF
  372. Dokumente verhindern. Damit du dadurch nicht überrascht wirst, wenn du versuchst einen
  373. Zeichensatz einzubetten, der nicht eingebettet werden kann, wird die Fabrikmethode eine
  374. Ausnahme werfen.
  375. </para>
  376. <para>
  377. Du kannst diese Zeichensätze weiterhin verwenden, aber du mußt entweder die 'nicht
  378. einbetten' Option übergeben wie oben beschrieben oder du kannst einfach die Ausnahme
  379. unterdrücken:
  380. </para>
  381. <example id="zend.pdf.drawing.using-fonts.example-4">
  382. <title>
  383. Werfe keine Ausnahme für Zeichensätze, die nicht eingebettet werden können.
  384. </title>
  385. <programlisting role="php"><![CDATA[
  386. ...
  387. $font = Zend_Pdf_Font::fontWithPath(
  388. '/path/to/unEmbeddableFont.ttf',
  389. Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION
  390. );
  391. ...
  392. ]]></programlisting>
  393. </example>
  394. <para>
  395. Diese Unterdrückungstechnik wird bevorzugt, wenn du einen Endnutzer erlaubst, seine
  396. eigenen Zeichensätze auszuwählen. Zeichensätze, die in ein PDF Dokument eingebettet
  397. werden können, werden eingebettet, andere nicht.
  398. </para>
  399. <para>
  400. Zeichensatzprogramme können sehr groß sein, manche erreichen Dutzende von Megabytes.
  401. Standardmäßig werden alle eingebetteten Zeichensätze unter Verwendung des Flate
  402. Kompressionsschemas komprimiert, woraus im Schnitt 50% an Speicherplatz gespart werden
  403. kann. Wenn du aus welchem Grund auch immer nicht möchtest, dass das Zeichensatzprogramm
  404. kompimiert wird, kannst du dies mit einer Option abschalten:
  405. </para>
  406. <example id="zend.pdf.drawing.using-fonts.example-5">
  407. <title>Komprimiere einen eingebetten Zeichensatz nicht.</title>
  408. <programlisting role="php"><![CDATA[
  409. ...
  410. $font = Zend_Pdf_Font::fontWithPath('/path/to/someReallyBigFont.ttf',
  411. Zend_Pdf_Font::EMBED_DONT_COMPRESS);
  412. ...
  413. ]]></programlisting>
  414. </example>
  415. <para>
  416. Zuguterletzt, kannst du die Einbettungsoptionen mit Hilfe des OR Operators kombinieren,
  417. wenn notwendig:
  418. </para>
  419. <example id="zend.pdf.drawing.using-fonts.example-6">
  420. <title>Kombiniere die Zeichensatz Einbettungsoptionen.</title>
  421. <programlisting role="php"><![CDATA[
  422. ...
  423. $font = Zend_Pdf_Font::fontWithPath(
  424. $someUserSelectedFontPath,
  425. (Zend_Pdf_Font::EMBED_SUPPRESS_EMBED_EXCEPTION |
  426. Zend_Pdf_Font::EMBED_DONT_COMPRESS));
  427. ...
  428. ]]></programlisting>
  429. </example>
  430. </sect2>
  431. <sect2 id="zend.pdf.drawing.standard-fonts-limitations">
  432. <title>Limits der Standard PDF Schriften</title>
  433. <para>
  434. Die Standard PDF Schriften verwendetn intern verschiedene Single-Byte Encodings (siehe
  435. <ulink url="http://www.adobe.com/devnet/acrobat/pdfs/pdf_reference_1-7.pdf">PDF
  436. Reference, Sixth Edition, version 1.7</ulink> Anhang D für Details). Diese sind
  437. generell gleich wie beim Latin1 Zeichensatz (ausser den Symbol und ZapfDingbats
  438. Schriften).
  439. </para>
  440. <para>
  441. <classname>Zend_Pdf</classname> verwendet CP1252 (WinLatin1) für das Zeichnen von Text
  442. mit Standardschriften.
  443. </para>
  444. <para>
  445. Text kann trotzdem in jedem anderen Encoding angegeben werden, welches spezifiziert
  446. werden muß wenn es sich vom aktuellen Gebietsschema unterscheidet. Nur WinLatin1 Zeichen
  447. werden aktuell gezeichnet.
  448. </para>
  449. <example id="zend.pdf.drawing.using-fonts.example-7">
  450. <title>Kombinieren mit in Schriften enthaltenen Optionen</title>
  451. <programlisting role="php"><![CDATA[
  452. ...
  453. $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER);
  454. $pdfPage->setFont($font, 36)
  455. ->drawText('Euro sign - €', 72, 720, 'UTF-8')
  456. ->drawText('Text with umlauts - à è ì', 72, 650, 'UTF-8');
  457. ...
  458. ]]></programlisting>
  459. </example>
  460. </sect2>
  461. <sect2 id="zend.pdf.drawing.extracting-fonts">
  462. <title>Schriften extrahieren</title>
  463. <para>
  464. Das <classname>Zend_Pdf</classname> Modul bietet die Möglichkeit Schriften von geladenen
  465. Dokumenten zu extrahieren.
  466. </para>
  467. <para>
  468. Das kann für aufsteigende Dokumenten Updates nützlich sein. Ohne diese Funktionalität
  469. müssen Schriften jedes Mal in ein Dokument hinzugefügt und möglicherweise eingebetten
  470. werden, wenn es aktualisiert werden soll.
  471. </para>
  472. <para>
  473. Die <classname>Zend_Pdf</classname> und <classname>Zend_Pdf_Page</classname> Objekte
  474. bieten spezielle Methoden um alle genannten Schriften innerhalb eines Dokuments oder
  475. einer Seite zu extrahieren:
  476. </para>
  477. <example id="zend.pdf.drawing.extracting-fonts.example-1">
  478. <title>Schriften von einem geladenen Dokument extrahieren</title>
  479. <programlisting role="php"><![CDATA[
  480. ...
  481. $pdf = Zend_Pdf::load($documentPath);
  482. ...
  483. // Alle Schriften des Dokuments bekommen
  484. $fontList = $pdf->extractFonts();
  485. $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4));
  486. $yPosition = 700;
  487. foreach ($fontList as $font) {
  488. $page->setFont($font, 15);
  489. $fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT,
  490. 'en',
  491. 'UTF-8');
  492. $page->drawText($fontName . ': Der schnelle braune Fuchs springt '
  493. . 'über den lahmen Hund',
  494. 100,
  495. $yPosition,
  496. 'UTF-8');
  497. $yPosition -= 30;
  498. }
  499. ...
  500. // Alle Schriften die in der ersten Seite des Dokuments referenziert sind erhalten
  501. $firstPage = reset($pdf->pages);
  502. $firstPageFonts = $firstPage->extractFonts();
  503. ...
  504. ]]></programlisting>
  505. </example>
  506. <example id="zend.pdf.drawing.extracting-fonts.example-2">
  507. <title>
  508. Eine Schrift von einem geladenen Dokument extrahieren durch die Angabe des
  509. Schriftnamens
  510. </title>
  511. <programlisting role="php"><![CDATA[
  512. ...
  513. $pdf = new Zend_Pdf();
  514. ...
  515. $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4));
  516. $font = Zend_Pdf_Font::fontWithPath($fontPath);
  517. $page->setFont($font, $fontSize);
  518. $page->drawText($text, $x, $y);
  519. ...
  520. // Diese Schrift sollte woanders gespeichert werden...
  521. $fontName = $font->getFontName(Zend_Pdf_Font::NAME_POSTSCRIPT,
  522. 'en',
  523. 'UTF-8');
  524. ...
  525. $pdf->save($docPath);
  526. ...
  527. ]]></programlisting>
  528. <programlisting role="php"><![CDATA[
  529. ...
  530. $pdf = Zend_Pdf::load($docPath);
  531. ...
  532. $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4));
  533. /* $srcPage->extractFont($fontName) kann auch hier verwendet werden */
  534. $font = $pdf->extractFont($fontName);
  535. $page->setFont($font, $fontSize);
  536. $page->drawText($text, $x, $y);
  537. ...
  538. $pdf->save($docPath, true /* aufsteigender Update Modus */);
  539. ...
  540. ]]></programlisting>
  541. </example>
  542. <para>
  543. Extrahierte Schriften können statt jeder anderen Schrift mit den folgenden
  544. Einschränkungen verwendet werden:
  545. <itemizedlist>
  546. <listitem><para>Eine extrahierte Schrift kann nur im Kontext des Dokuments verwendet
  547. werden von dem es extrahiert wurde.</para></listitem>
  548. <listitem>
  549. <para>
  550. Ein möglicherweise eingebettetes Schriftprogramm wird aktuell nicht
  551. extrahiert. Deswegen können extrahierte Schriften keine richtigen
  552. Schriftmaße bieten und die originale Schrift wird für die Berechnung der
  553. Breite verwendet:
  554. <programlisting role="php"><![CDATA[
  555. ...
  556. $font = $pdf->extractFont($fontName);
  557. $originalFont = Zend_Pdf_Font::fontWithPath($fontPath);
  558. $page->setFont($font /* Die extrahierte Schrift für das Zeichnen verwenden */, $fontSize);
  559. $xPosition = $x;
  560. for ($charIndex = 0; $charIndex < strlen($text); $charIndex++) {
  561. $page->drawText($text[$charIndex], xPosition, $y);
  562. // Die originale Schrift für die Berechnung der Breite des Textes verwenden
  563. $width += $originalFont->widthForGlyph(
  564. $originalFont->glyphNumberForCharacter($text[$charIndex])
  565. );
  566. $xPosition += $width/$originalFont->getUnitsPerEm()*$fontSize;
  567. }
  568. ...
  569. ]]></programlisting>
  570. </para>
  571. </listitem>
  572. </itemizedlist>
  573. </para>
  574. </sect2>
  575. <sect2 id="zend.pdf.drawing.image-drawing">
  576. <title>Zeichnen von Grafiken</title>
  577. <para>
  578. Die <classname>Zend_Pdf_Page</classname> Klasse stellt die drawImage() Methode für das
  579. Zeichnen von Grafiken bereit:
  580. </para>
  581. <programlisting role="php"><![CDATA[
  582. /**
  583. * Zeichne eine Grafik an der angegebenen Position der Seite.
  584. *
  585. * @param Zend_Pdf_Ressource_Image $image
  586. * @param float $x1
  587. * @param float $y1
  588. * @param float $x2
  589. * @param float $y2
  590. * @return Zend_Pdf_Page
  591. */
  592. public function drawImage(Zend_Pdf_Ressource_Image $image, $x1, $y1, $x2, $y2);
  593. ]]></programlisting>
  594. <para>
  595. Grafikobjekte sollten mit der Methode
  596. <classname>Zend_Pdf_Image::imageWithPath($filePath)</classname> erzeugt werden. (Es
  597. werden zur Zeit JPG, PNG und TIFF Grafiken unterstützt):
  598. </para>
  599. <example id="zend.pdf.drawing.image-drawing.example-1">
  600. <title>Zeichnen von Grafiken</title>
  601. <programlisting role="php"><![CDATA[
  602. ...
  603. // Lade die Grafik
  604. $image = Zend_Pdf_Image::imageWithPath('my_image.jpg');
  605. $pdfPage->drawImage($image, 100, 100, 400, 300);
  606. ...
  607. ]]></programlisting>
  608. </example>
  609. <para>
  610. <emphasis>Wichtig! JPG Support setzt voraus, dass die GD Erweiterung für PHP
  611. konfiguriert wurde.</emphasis>
  612. <emphasis>Wichtig! PNG Support setzt voraus, dass die ZLIB Erweiterung konfiguriert
  613. wurde, um mit Grafiken mit Alphakanal zu arbeiten.</emphasis>
  614. </para>
  615. <para>
  616. Wende dich an die PHP Dokumentation für weitere Informationen (<ulink
  617. url="http://www.php.net/manual/de/ref.image.php">http://www.php.net/manual/de/ref.image.php</ulink>).
  618. (<ulink url="http://www.php.net/manual/de/ref.zlib.php">http://www.php.net/manual/de/ref.zlib.php</ulink>).
  619. </para>
  620. </sect2>
  621. <sect2 id="zend.pdf.drawing.line-drawing-style">
  622. <title>Stil der Strichzeichnungen</title>
  623. <para>
  624. Der Stil der Strichzeichnungen wurd durch die Linienbreite, die Linienfarbe und das
  625. Strichmuster definiert. Alle diese Parameter können an die Klassenmethoden von
  626. <classname>Zend_Pdf_Page</classname> übergeben werden:
  627. </para>
  628. <programlisting role="php"><![CDATA[
  629. /** Setze die Linienfarbe. */
  630. public function setLineColor(Zend_Pdf_Color $color);
  631. /** Setze die Linienbreite. */
  632. public function setLineWidth(float $width);
  633. /**
  634. * Setze das Strichmuster.
  635. *
  636. * Pattern ist ein Array mit Fließkommazahlen:
  637. * array(on_length, off_length, on_length, off_length, ...)
  638. * Phase is shift from the beginning of line.
  639. *
  640. * @param array $pattern
  641. * @param array $phase
  642. * @return Zend_Pdf_Page
  643. */
  644. public function setLineDashingPattern($pattern, $phase = 0);
  645. ]]></programlisting>
  646. </sect2>
  647. <sect2 id="zend.pdf.drawing.fill-style">
  648. <title>Füllstil</title>
  649. <para>
  650. Die Methoden <classname>Zend_Pdf_Page::drawRectangle()</classname>,
  651. <classname>Zend_Pdf_Page::drawPolygon()</classname>,
  652. <classname>Zend_Pdf_Page::drawCircle()</classname> und
  653. <classname>Zend_Pdf_Page::drawEllipse()</classname> akzeptieren das
  654. <code>$fillType</code> Argument als optionalen Parameter. Es kann lauten:
  655. </para>
  656. <itemizedlist>
  657. <listitem>
  658. <para>Zend_Pdf_Page::SHAPE_DRAW_STROKE - strichele die Form</para>
  659. </listitem>
  660. <listitem>
  661. <para>Zend_Pdf_Page::SHAPE_DRAW_FILL - fülle die Form</para>
  662. </listitem>
  663. <listitem>
  664. <para>Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fülle und strichele die Form
  665. (Standardverhalten)</para>
  666. </listitem>
  667. </itemizedlist>
  668. <para>
  669. Die <classname>Zend_Pdf_Page::drawPolygon()</classname> Methode akzeptiert
  670. <code>$fillMethod</code> als zusätzlichen Parameter:
  671. </para>
  672. <itemizedlist>
  673. <listitem>
  674. <para>Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING (Standardverhalten)</para>
  675. <para>
  676. <citetitle>Die PDF Referenz</citetitle> beschreibt diese Regel wie folgt:
  677. <blockquote>
  678. <para>
  679. The nonzero winding number rule determines whether a given point is inside
  680. a path by conceptually drawing a ray from that point to infinity in any
  681. direction and then examining the places where a segment of the path crosses
  682. the ray. Starting with a count of 0, the rule adds 1 each time a path
  683. segment crosses the ray from left to right and subtracts 1 each time a
  684. segment crosses from right to left. After counting all the crossings, if the
  685. result is 0 then the point is outside the path; otherwise it is inside.
  686. Note: The method just described does not specify what to do if a path
  687. segment coincides with or is tangent to the chosen ray. Since the direction
  688. of the ray is arbitrary, the rule simply chooses a ray that does not
  689. encounter such problem intersections. For simple convex paths, the nonzero
  690. winding number rule defines the inside and outside as one would intuitively
  691. expect. The more interesting cases are those involving complex or
  692. self-intersecting paths like the ones shown in Figure 4.10 (in a PDF
  693. Reference).
  694. For a path consisting of a five-pointed star, drawn with five connected
  695. straight line segments intersecting each other, the rule considers the
  696. inside to be the entire area enclosed by the star, including the pentagon in
  697. the center. For a path composed of two concentric circles, the areas
  698. enclosed by both circles are considered to be inside, provided that both are
  699. drawn in the same direction. If the circles are drawn in opposite
  700. directions, only the "doughnut" shape between them is inside, according to
  701. the rule; the "doughnut hole" is outside.
  702. </para>
  703. </blockquote>
  704. </para>
  705. </listitem>
  706. <listitem>
  707. <para>Zend_Pdf_Page::FILL_METHOD_EVEN_ODD</para>
  708. <para>
  709. <citetitle>Die PDF Referenz</citetitle> beschreibt diese Regel wie folgt:
  710. <blockquote>
  711. <para>
  712. An alternative to the nonzero winding number rule is the even-odd rule. This
  713. rule determines the "insideness" of a point by drawing a ray from that point
  714. in any direction and simply counting the number of path segments that cross
  715. the ray, regardless of direction. If this number is odd, the point is
  716. inside; if even, the point is outside. This yields the same results as the
  717. nonzero winding number rule for paths with simple shapes, but produces
  718. different results for more complex shapes.
  719. Figure 4.11 (in a PDF Reference) shows the effects of applying the even-odd
  720. rule to complex paths. For the five-pointed star, the rule considers the
  721. triangular points to be inside the path, but not the pentagon in the center.
  722. For the two concentric circles, only the "doughnut" shape between the two
  723. circles is considered inside, regardless of the directions in which the
  724. circles are drawn.
  725. </para>
  726. </blockquote>
  727. </para>
  728. </listitem>
  729. </itemizedlist>
  730. </sect2>
  731. <sect2 id="zend.pdf.drawing.linear-transformations">
  732. <title>Lineare Transformationen</title>
  733. <sect3 id="zend.pdf.drawing.linear-transformations.rotations">
  734. <title>Drehungen</title>
  735. <para>
  736. Bevor eine Zeichenoperation angewendet wird, können PDF Seiten gedreht werden. Dies
  737. kann mit Hilfe der <classname>Zend_Pdf_Page::rotate()</classname> Methode
  738. durchgeführt werden:
  739. </para>
  740. <programlisting role="php"><![CDATA[
  741. /**
  742. * Drehe die Seite
  743. *
  744. * @param float $x - die X Koordinate des Rotationspunktes
  745. * @param float $y - die Y Koordinate des Rotationspunktes
  746. * @param float $angle - der Rotationswinkel
  747. * @return Zend_Pdf_Page
  748. */
  749. public function rotate($x, $y, $angle);
  750. ]]></programlisting>
  751. </sect3>
  752. <sect3 id="zend.pdf.drawing.linear-transformations.scale">
  753. <title>Beginnend mit ZF 1.8, Skalierung</title>
  754. <para>
  755. Skalenänderungen werden durch die <classname>Zend_Pdf_Page::scale()</classname>
  756. Methode angeboten:
  757. </para>
  758. <programlisting role="php"><![CDATA[
  759. /**
  760. * Koordinationssystem für die Skala
  761. *
  762. * @param float $xScale - Skalierungsfaktor für die X Dimension
  763. * @param float $yScale - Skalierungsfaktor für die Y Dimension
  764. * @return Zend_Pdf_Page
  765. */
  766. public function scale($xScale, $yScale);
  767. ]]></programlisting>
  768. </sect3>
  769. <sect3 id="zend.pdf.drawing.linear-transformations.translate">
  770. <title>Beginnend mit ZF 1.8, Bewegungen</title>
  771. <para>
  772. Das bewegen des Koordinationssystem wird von der
  773. <classname>Zend_Pdf_Page::translate()</classname> Methode durchgeführt:
  774. </para>
  775. <programlisting role="php"><![CDATA[
  776. /**
  777. * Bewegen des Koordinationssystems
  778. *
  779. * @param float $xShift - X Koordinate für die Bewegung
  780. * @param float $yShift - Y Koordinate für die Bewegung
  781. * @return Zend_Pdf_Page
  782. */
  783. public function translate($xShift, $yShift);
  784. ]]></programlisting>
  785. </sect3>
  786. <sect3 id="zend.pdf.drawing.linear-transformations.skew">
  787. <title>Beginnend mit ZF 1.8, Drehungen</title>
  788. <para>
  789. Das Drehen der Seite kann durch Verwendung der
  790. <classname>Zend_Pdf_Page::skew()</classname> Methode durchgeführt werden:
  791. </para>
  792. <programlisting role="php"><![CDATA[
  793. /**
  794. * Bewegen des Koordinationssystems
  795. *
  796. * @param float $x - Die X Koordinate des Achsen-Drehpunktes
  797. * @param float $y - Die Y Koordinate des Achsen-Drehpunktes
  798. * @param float $xAngle - X Winkel der Achse
  799. * @param float $yAngle - Y Winkel der Achse
  800. * @return Zend_Pdf_Page
  801. */
  802. public function skew($x, $y, $xAngle, $yAngle);
  803. ]]></programlisting>
  804. </sect3>
  805. </sect2>
  806. <sect2 id="zend.pdf.drawing.save-restore">
  807. <title>Speichern/Wiederherstellen des Grafikzustand</title>
  808. <para>
  809. Jederzeit kann der Grafikzustand der Seite (aktueller Zeichensatz, Schriftgröße,
  810. Linienfarbe, Füllfarbe, Linienstil, Seitendrehung, Zeichenbereich) gespeichert und
  811. wiederhergestellt werden. Speicheroperationen legen die Daten auf einen Grafikzustand
  812. Stapel, Wiederherstelloperationen holen Sie daher zurück.
  813. </para>
  814. <para>
  815. In der <classname>Zend_Pdf_Page</classname> Klasse gibt es für diese Operationen zwei
  816. Methoden:
  817. </para>
  818. <programlisting role="php"><![CDATA[
  819. /**
  820. * Speichere den Grafikzustand dieser Seite.
  821. * Es wir ein Schnappschuss vom aktuell festgelegten Stil, Position,
  822. * Zeichenbereich und jeder festgelegten Drehung/Umrechnung/Skalierung
  823. * erstellt.
  824. *
  825. * @return Zend_Pdf_Page
  826. */
  827. public function saveGS();
  828. /**
  829. * Stelle den Grafikzustand wieder her, der mit dem letzten Aufruf von
  830. * saveGS() gespeichert wurde
  831. *
  832. * @return Zend_Pdf_Page
  833. */
  834. public function restoreGS();
  835. ]]></programlisting>
  836. </sect2>
  837. <sect2 id="zend.pdf.drawing.clipping">
  838. <title>Zeichenbereich</title>
  839. <para>
  840. PDF und die <classname>Zend_Pdf</classname> Komponente unterstützen die Begrenzung des
  841. Zeichenbereichs. Der aktuelle Zeichenbereich begrenzt den Seitenbereich, der von
  842. Zeichenoperationen beeinflusst werden kann. Zu Beginn ist dies die gesamte Seite.
  843. </para>
  844. <para>
  845. Die <classname>Zend_Pdf_Page</classname> Klasse stellt einen Satz von Methoden für die
  846. Begrenzung bereit.
  847. </para>
  848. <programlisting role="php"><![CDATA[
  849. /**
  850. * Durchschneide den aktuellen Zeichenbereich mit einem Rechteck.
  851. *
  852. * @param float $x1
  853. * @param float $y1
  854. * @param float $x2
  855. * @param float $y2
  856. * @return Zend_Pdf_Page
  857. */
  858. public function clipRectangle($x1, $y1, $x2, $y2);
  859. ]]></programlisting>
  860. <programlisting role="php"><![CDATA[
  861. /**
  862. * Durchschneide den aktuellen Zeichenbereich mit einem Polygon.
  863. *
  864. * @param array $x - Array mit Floats (die X Koordinaten der Eckpunkte)
  865. * @param array $y - Array mit Floats (die Y Koordinaten der Eckpunkte)
  866. * @param integer $fillMethod
  867. * @return Zend_Pdf_Page
  868. */
  869. public function clipPolygon($x,
  870. $y,
  871. $fillMethod =
  872. Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
  873. ]]></programlisting>
  874. <programlisting role="php"><![CDATA[
  875. /**
  876. * Durchschneide den aktuellen Zeichenbereich mit einem Kreis.
  877. *
  878. * @param float $x
  879. * @param float $y
  880. * @param float $radius
  881. * @param float $startAngle
  882. * @param float $endAngle
  883. * @return Zend_Pdf_Page
  884. */
  885. public function clipCircle($x,
  886. $y,
  887. $radius,
  888. $startAngle = null,
  889. $endAngle = null);
  890. ]]></programlisting>
  891. <programlisting role="php"><![CDATA[
  892. /**
  893. * Durchschneide den aktuellen Zeichenbereich mit einer Ellipse.
  894. *
  895. * Methoden Signaturen:
  896. * drawEllipse($x1, $y1, $x2, $y2);
  897. * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
  898. *
  899. * @todo verarbeite die Sonderfälle mit $x2-$x1 == 0 oder $y2-$y1 == 0
  900. *
  901. * @param float $x1
  902. * @param float $y1
  903. * @param float $x2
  904. * @param float $y2
  905. * @param float $startAngle
  906. * @param float $endAngle
  907. * @return Zend_Pdf_Page
  908. */
  909. public function clipEllipse($x1,
  910. $y1,
  911. $x2,
  912. $y2,
  913. $startAngle = null,
  914. $endAngle = null);
  915. ]]></programlisting>
  916. </sect2>
  917. <sect2 id="zend.pdf.drawing.styles">
  918. <title>Stile</title>
  919. <para>
  920. Die <classname>Zend_Pdf_Style</classname> Klasse stellt Stilfunktionalitäten bereit.
  921. </para>
  922. <para>
  923. Stile können verwendet werden, um mit einer Operation die Parameter für den
  924. Grafikzustand zu speichern und auf eine PDF Seite anzuwenden:
  925. </para>
  926. <programlisting role="php"><![CDATA[
  927. /**
  928. * Lege den Stil für zukünftige Zeichenoperationen auf dieser Seite fest
  929. *
  930. * @param Zend_Pdf_Style $style
  931. * @return Zend_Pdf_Page
  932. */
  933. public function setStyle(Zend_Pdf_Style $style);
  934. /**
  935. * Gebe den Stil der Seite zurück.
  936. *
  937. * @return Zend_Pdf_Style|null
  938. */
  939. public function getStyle();
  940. ]]></programlisting>
  941. <para>
  942. Die <classname>Zend_Pdf_Style</classname> Klasse stellt einen Satz von Methoden bereit,
  943. um verschiedene Parameter des Grafikstadiums zu setzen und zu holen:
  944. </para>
  945. <programlisting role="php"><![CDATA[
  946. /**
  947. * Setze die Linienfarbe.
  948. *
  949. * @param Zend_Pdf_Color $color
  950. * @return Zend_Pdf_Page
  951. */
  952. public function setLineColor(Zend_Pdf_Color $color);
  953. ]]></programlisting>
  954. <programlisting role="php"><![CDATA[
  955. /**
  956. * Hole die Linienfarbe.
  957. *
  958. * @return Zend_Pdf_Color|null
  959. */
  960. public function getLineColor();
  961. ]]></programlisting>
  962. <programlisting role="php"><![CDATA[
  963. /**
  964. * Setze die Linienbreite.
  965. *
  966. * @param float $width
  967. * @return Zend_Pdf_Page
  968. */
  969. public function setLineWidth($width);
  970. ]]></programlisting>
  971. <programlisting role="php"><![CDATA[
  972. /**
  973. * Hole die Linienbreite.
  974. *
  975. * @return float
  976. */
  977. public function getLineWidth();
  978. ]]></programlisting>
  979. <programlisting role="php"><![CDATA[
  980. /**
  981. * Setze das Strichmuster
  982. *
  983. * @param array $pattern
  984. * @param float $phase
  985. * @return Zend_Pdf_Page
  986. */
  987. public function setLineDashingPattern($pattern, $phase = 0);
  988. ]]></programlisting>
  989. <programlisting role="php"><![CDATA[
  990. /**
  991. * Hole das Strichmuster
  992. *
  993. * @return array
  994. */
  995. public function getLineDashingPattern();
  996. ]]></programlisting>
  997. <programlisting role="php"><![CDATA[
  998. /**
  999. * Get line dashing phase
  1000. *
  1001. * @return float
  1002. */
  1003. public function getLineDashingPhase();
  1004. ]]></programlisting>
  1005. <programlisting role="php"><![CDATA[
  1006. /**
  1007. * Setze die Füllfarbe
  1008. *
  1009. * @param Zend_Pdf_Color $color
  1010. * @return Zend_Pdf_Page
  1011. */
  1012. public function setFillColor(Zend_Pdf_Color $color);
  1013. ]]></programlisting>
  1014. <programlisting role="php"><![CDATA[
  1015. /**
  1016. * Hole die Füllfarbe.
  1017. *
  1018. * @return Zend_Pdf_Color|null
  1019. */
  1020. public function getFillColor();
  1021. ]]></programlisting>
  1022. <programlisting role="php"><![CDATA[
  1023. /**
  1024. * Ändere den Zeichensatz.
  1025. *
  1026. * @param Zend_Pdf_Resource_Font $font
  1027. * @param float $fontSize
  1028. * @return Zend_Pdf_Page
  1029. */
  1030. public function setFont(Zend_Pdf_Resource_Font $font, $fontSize);
  1031. ]]></programlisting>
  1032. <programlisting role="php"><![CDATA[
  1033. /**
  1034. * Ändere die Schriftgröße
  1035. *
  1036. * @param float $fontSize
  1037. * @return Zend_Pdf_Page
  1038. */
  1039. public function setFontSize($fontSize);
  1040. ]]></programlisting>
  1041. <programlisting role="php"><![CDATA[
  1042. /**
  1043. * Hole den Zeichensatz.
  1044. *
  1045. * @return Zend_Pdf_Resource_Font $font
  1046. */
  1047. public function getFont();
  1048. ]]></programlisting>
  1049. <programlisting role="php"><![CDATA[
  1050. /**
  1051. * Hole die Schriftgröße
  1052. *
  1053. * @return float $fontSize
  1054. */
  1055. public function getFontSize();
  1056. ]]></programlisting>
  1057. </sect2>
  1058. <sect2 id="zend.pdf.drawing.alpha">
  1059. <title>Transparenz</title>
  1060. <para>
  1061. Das <classname>Zend_Pdf</classname> Modul unterstützt die Handhabung von Transparenz.
  1062. </para>
  1063. <para>
  1064. Transparenz kann durch Verwendung der <classname>Zend_Pdf_Page::setAlpha()</classname>
  1065. Methode gesetzt werden:
  1066. <programlisting role="php"><![CDATA[
  1067. /**
  1068. * Setzt die Transparenz
  1069. *
  1070. * $alpha == 0 - Transparent
  1071. * $alpha == 1 - Opaque
  1072. *
  1073. * Von PDF unterstützte Transparent-Modi:
  1074. * Normal (standard), Multiply, Screen, Overlay, Darken, Lighten,
  1075. * ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion
  1076. *
  1077. * @param float $alpha
  1078. * @param string $mode
  1079. * @throws Zend_Pdf_Exception
  1080. * @return Zend_Pdf_Page
  1081. */
  1082. public function setAlpha($alpha, $mode = 'Normal');
  1083. ]]></programlisting>
  1084. </para>
  1085. </sect2>
  1086. </sect1>