2
0

Zend_Pdf-Drawing.xml 43 KB

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