Interface.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: Style.php 20096 2010-01-06 02:05:09Z bkarwin $
  20. */
  21. /**
  22. * Canvas is an abstract rectangle drawing area which can be dropped into
  23. * page object at specified place.
  24. *
  25. * @package Zend_Pdf
  26. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. interface Zend_Pdf_Canvas_Interface
  30. {
  31. /**
  32. * Return canvas height.
  33. *
  34. * @return float
  35. */
  36. public function getHeight();
  37. /**
  38. * Return canvas width.
  39. *
  40. * @return float
  41. */
  42. public function getWidth();
  43. /**
  44. * Draw a canvas at the specified location
  45. *
  46. * If upper right corner is not specified then canvas heght and width
  47. * are used.
  48. *
  49. * @param Zend_Pdf_Canvas_Interface $canvas
  50. * @param float $x1
  51. * @param float $y1
  52. * @param float $x2
  53. * @param float $y2
  54. * @return Zend_Pdf_Canvas_Interface
  55. */
  56. public function drawCanvas($canvas, $x1, $y1, $x2 = null, $y2 = null);
  57. /**
  58. * Set fill color.
  59. *
  60. * @param Zend_Pdf_Color $color
  61. * @return Zend_Pdf_Canvas_Interface
  62. */
  63. public function setFillColor(Zend_Pdf_Color $color);
  64. /**
  65. * Set line color.
  66. *
  67. * @param Zend_Pdf_Color $color
  68. * @return Zend_Pdf_Canvas_Interface
  69. */
  70. public function setLineColor(Zend_Pdf_Color $color);
  71. /**
  72. * Set line width.
  73. *
  74. * @param float $width
  75. * @return Zend_Pdf_Canvas_Interface
  76. */
  77. public function setLineWidth($width);
  78. /**
  79. * Set line dashing pattern
  80. *
  81. * Pattern is an array of floats: array(on_length, off_length, on_length, off_length, ...)
  82. * or Zend_Pdf_Page::LINE_DASHING_SOLID constant
  83. * Phase is shift from the beginning of line.
  84. *
  85. * @param mixed $pattern
  86. * @param array $phase
  87. * @return Zend_Pdf_Canvas_Interface
  88. */
  89. public function setLineDashingPattern($pattern, $phase = 0);
  90. /**
  91. * Set current font.
  92. *
  93. * @param Zend_Pdf_Resource_Font $font
  94. * @param float $fontSize
  95. * @return Zend_Pdf_Canvas_Interface
  96. */
  97. public function setFont(Zend_Pdf_Resource_Font $font, $fontSize);
  98. /**
  99. * Set the style to use for future drawing operations on this page
  100. *
  101. * @param Zend_Pdf_Style $style
  102. * @return Zend_Pdf_Canvas_Interface
  103. */
  104. public function setStyle(Zend_Pdf_Style $style);
  105. /**
  106. * Get current font.
  107. *
  108. * @return Zend_Pdf_Resource_Font $font
  109. */
  110. public function getFont();
  111. /**
  112. * Get current font size
  113. *
  114. * @return float $fontSize
  115. */
  116. public function getFontSize();
  117. /**
  118. * Return the style, applied to the page.
  119. *
  120. * @return Zend_Pdf_Style|null
  121. */
  122. public function getStyle();
  123. /**
  124. * Save the graphics state of this page.
  125. * This takes a snapshot of the currently applied style, position, clipping area and
  126. * any rotation/translation/scaling that has been applied.
  127. *
  128. * @throws Zend_Pdf_Exception - if a save is performed with an open path
  129. * @return Zend_Pdf_Page
  130. */
  131. public function saveGS();
  132. /**
  133. * Set the transparancy
  134. *
  135. * $alpha == 0 - transparent
  136. * $alpha == 1 - opaque
  137. *
  138. * Transparency modes, supported by PDF:
  139. * Normal (default), Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight,
  140. * SoftLight, Difference, Exclusion
  141. *
  142. * @param float $alpha
  143. * @param string $mode
  144. * @throws Zend_Pdf_Exception
  145. * @return Zend_Pdf_Canvas_Interface
  146. */
  147. public function setAlpha($alpha, $mode = 'Normal');
  148. /**
  149. * Intersect current clipping area with a circle.
  150. *
  151. * @param float $x
  152. * @param float $y
  153. * @param float $radius
  154. * @param float $startAngle
  155. * @param float $endAngle
  156. * @return Zend_Pdf_Canvas_Interface
  157. */
  158. public function clipCircle($x, $y, $radius, $startAngle = null, $endAngle = null);
  159. /**
  160. * Intersect current clipping area with a polygon.
  161. *
  162. * Method signatures:
  163. * drawEllipse($x1, $y1, $x2, $y2);
  164. * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
  165. *
  166. * @todo process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
  167. *
  168. * @param float $x1
  169. * @param float $y1
  170. * @param float $x2
  171. * @param float $y2
  172. * @param float $startAngle
  173. * @param float $endAngle
  174. * @return Zend_Pdf_Canvas_Interface
  175. */
  176. public function clipEllipse($x1, $y1, $x2, $y2, $startAngle = null, $endAngle = null);
  177. /**
  178. * Intersect current clipping area with a polygon.
  179. *
  180. * @param array $x - array of float (the X co-ordinates of the vertices)
  181. * @param array $y - array of float (the Y co-ordinates of the vertices)
  182. * @param integer $fillMethod
  183. * @return Zend_Pdf_Canvas_Interface
  184. */
  185. public function clipPolygon($x, $y, $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
  186. /**
  187. * Intersect current clipping area with a rectangle.
  188. *
  189. * @param float $x1
  190. * @param float $y1
  191. * @param float $x2
  192. * @param float $y2
  193. * @return Zend_Pdf_Canvas_Interface
  194. */
  195. public function clipRectangle($x1, $y1, $x2, $y2);
  196. /**
  197. * Draw a circle centered on x, y with a radius of radius.
  198. *
  199. * Method signatures:
  200. * drawCircle($x, $y, $radius);
  201. * drawCircle($x, $y, $radius, $fillType);
  202. * drawCircle($x, $y, $radius, $startAngle, $endAngle);
  203. * drawCircle($x, $y, $radius, $startAngle, $endAngle, $fillType);
  204. *
  205. *
  206. * It's not a really circle, because PDF supports only cubic Bezier curves.
  207. * But _very_ good approximation.
  208. * It differs from a real circle on a maximum 0.00026 radiuses
  209. * (at PI/8, 3*PI/8, 5*PI/8, 7*PI/8, 9*PI/8, 11*PI/8, 13*PI/8 and 15*PI/8 angles).
  210. * At 0, PI/4, PI/2, 3*PI/4, PI, 5*PI/4, 3*PI/2 and 7*PI/4 it's exactly a tangent to a circle.
  211. *
  212. * @param float $x
  213. * @param float $y
  214. * @param float $radius
  215. * @param mixed $param4
  216. * @param mixed $param5
  217. * @param mixed $param6
  218. * @return Zend_Pdf_Canvas_Interface
  219. */
  220. public function drawCircle($x, $y, $radius, $param4 = null, $param5 = null, $param6 = null);
  221. /**
  222. * Draw an ellipse inside the specified rectangle.
  223. *
  224. * Method signatures:
  225. * drawEllipse($x1, $y1, $x2, $y2);
  226. * drawEllipse($x1, $y1, $x2, $y2, $fillType);
  227. * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle);
  228. * drawEllipse($x1, $y1, $x2, $y2, $startAngle, $endAngle, $fillType);
  229. *
  230. * @todo process special cases with $x2-$x1 == 0 or $y2-$y1 == 0
  231. *
  232. * @param float $x1
  233. * @param float $y1
  234. * @param float $x2
  235. * @param float $y2
  236. * @param mixed $param5
  237. * @param mixed $param6
  238. * @param mixed $param7
  239. * @return Zend_Pdf_Canvas_Interface
  240. */
  241. public function drawEllipse($x1, $y1, $x2, $y2, $param5 = null, $param6 = null, $param7 = null);
  242. /**
  243. * Draw an image at the specified position on the page.
  244. *
  245. * @param Zend_Pdf_Image $image
  246. * @param float $x1
  247. * @param float $y1
  248. * @param float $x2
  249. * @param float $y2
  250. * @return Zend_Pdf_Canvas_Interface
  251. */
  252. public function drawImage(Zend_Pdf_Resource_Image $image, $x1, $y1, $x2, $y2);
  253. /**
  254. * Draw a LayoutBox at the specified position on the page.
  255. *
  256. * @internal (not implemented now)
  257. *
  258. * @param Zend_Pdf_Element_LayoutBox $box
  259. * @param float $x
  260. * @param float $y
  261. * @return Zend_Pdf_Canvas_Interface
  262. */
  263. public function drawLayoutBox($box, $x, $y);
  264. /**
  265. * Draw a line from x1,y1 to x2,y2.
  266. *
  267. * @param float $x1
  268. * @param float $y1
  269. * @param float $x2
  270. * @param float $y2
  271. * @return Zend_Pdf_Canvas_Interface
  272. */
  273. public function drawLine($x1, $y1, $x2, $y2);
  274. /**
  275. * Draw a polygon.
  276. *
  277. * If $fillType is Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE or
  278. * Zend_Pdf_Page::SHAPE_DRAW_FILL, then polygon is automatically closed.
  279. * See detailed description of these methods in a PDF documentation
  280. * (section 4.4.2 Path painting Operators, Filling)
  281. *
  282. * @param array $x - array of float (the X co-ordinates of the vertices)
  283. * @param array $y - array of float (the Y co-ordinates of the vertices)
  284. * @param integer $fillType
  285. * @param integer $fillMethod
  286. * @return Zend_Pdf_Canvas_Interface
  287. */
  288. public function drawPolygon($x, $y,
  289. $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE,
  290. $fillMethod = Zend_Pdf_Page::FILL_METHOD_NON_ZERO_WINDING);
  291. /**
  292. * Draw a rectangle.
  293. *
  294. * Fill types:
  295. * Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)
  296. * Zend_Pdf_Page::SHAPE_DRAW_STROKE - stroke rectangle
  297. * Zend_Pdf_Page::SHAPE_DRAW_FILL - fill rectangle
  298. *
  299. * @param float $x1
  300. * @param float $y1
  301. * @param float $x2
  302. * @param float $y2
  303. * @param integer $fillType
  304. * @return Zend_Pdf_Canvas_Interface
  305. */
  306. public function drawRectangle($x1, $y1, $x2, $y2, $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
  307. /**
  308. * Draw a rounded rectangle.
  309. *
  310. * Fill types:
  311. * Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE - fill rectangle and stroke (default)
  312. * Zend_Pdf_Page::SHAPE_DRAW_STROKE - stroke rectangle
  313. * Zend_Pdf_Page::SHAPE_DRAW_FILL - fill rectangle
  314. *
  315. * radius is an integer representing radius of the four corners, or an array
  316. * of four integers representing the radius starting at top left, going
  317. * clockwise
  318. *
  319. * @param float $x1
  320. * @param float $y1
  321. * @param float $x2
  322. * @param float $y2
  323. * @param integer|array $radius
  324. * @param integer $fillType
  325. * @return Zend_Pdf_Canvas_Interface
  326. */
  327. public function drawRoundedRectangle($x1, $y1, $x2, $y2, $radius,
  328. $fillType = Zend_Pdf_Page::SHAPE_DRAW_FILL_AND_STROKE);
  329. /**
  330. * Draw a line of text at the specified position.
  331. *
  332. * @param string $text
  333. * @param float $x
  334. * @param float $y
  335. * @param string $charEncoding (optional) Character encoding of source text.
  336. * Defaults to current locale.
  337. * @throws Zend_Pdf_Exception
  338. * @return Zend_Pdf_Canvas_Interface
  339. */
  340. public function drawText($text, $x, $y, $charEncoding = '');
  341. /**
  342. * Close the path by drawing a straight line back to it's beginning.
  343. *
  344. * @internal (needs implementation)
  345. *
  346. * @throws Zend_Pdf_Exception - if a path hasn't been started with pathMove()
  347. * @return Zend_Pdf_Canvas_Interface
  348. */
  349. public function pathClose();
  350. /**
  351. * Continue the open path in a straight line to the specified position.
  352. *
  353. * @internal (needs implementation)
  354. *
  355. * @param float $x - the X co-ordinate to move to
  356. * @param float $y - the Y co-ordinate to move to
  357. * @return Zend_Pdf_Canvas_Interface
  358. */
  359. public function pathLine($x, $y);
  360. /**
  361. * Start a new path at the specified position. If a path has already been started,
  362. * move the cursor without drawing a line.
  363. *
  364. * @internal (needs implementation)
  365. *
  366. * @param float $x - the X co-ordinate to move to
  367. * @param float $y - the Y co-ordinate to move to
  368. * @return Zend_Pdf_Canvas_Interface
  369. */
  370. public function pathMove($x, $y);
  371. /**
  372. * Rotate the page.
  373. *
  374. * @param float $x - the X co-ordinate of rotation point
  375. * @param float $y - the Y co-ordinate of rotation point
  376. * @param float $angle - rotation angle
  377. * @return Zend_Pdf_Canvas_Interface
  378. */
  379. public function rotate($x, $y, $angle);
  380. /**
  381. * Scale coordination system.
  382. *
  383. * @param float $xScale - X dimention scale factor
  384. * @param float $yScale - Y dimention scale factor
  385. * @return Zend_Pdf_Canvas_Interface
  386. */
  387. public function scale($xScale, $yScale);
  388. /**
  389. * Translate coordination system.
  390. *
  391. * @param float $xShift - X coordinate shift
  392. * @param float $yShift - Y coordinate shift
  393. * @return Zend_Pdf_Canvas_Interface
  394. */
  395. public function translate($xShift, $yShift);
  396. /**
  397. * Translate coordination system.
  398. *
  399. * @param float $x - the X co-ordinate of axis skew point
  400. * @param float $y - the Y co-ordinate of axis skew point
  401. * @param float $xAngle - X axis skew angle
  402. * @param float $yAngle - Y axis skew angle
  403. * @return Zend_Pdf_Canvas_Interface
  404. */
  405. public function skew($x, $y, $xAngle, $yAngle);
  406. /**
  407. * Writes the raw data to the page's content stream.
  408. *
  409. * Be sure to consult the PDF reference to ensure your syntax is correct. No
  410. * attempt is made to ensure the validity of the stream data.
  411. *
  412. * @param string $data
  413. * @param string $procSet (optional) Name of ProcSet to add.
  414. * @return Zend_Pdf_Canvas_Interface
  415. */
  416. public function rawWrite($data, $procSet = null);
  417. }