Zend_Pdf-Drawing.xml 42 KB

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