Zend_Pdf-Drawing.xml 43 KB

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