canvas.cls.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <?php
  2. /**
  3. * @package dompdf
  4. * @link http://dompdf.github.com/
  5. * @author Benj Carson <benjcarson@digitaljunkies.ca>
  6. * @author Fabien Ménager <fabien.menager@gmail.com>
  7. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  8. */
  9. /**
  10. * Main rendering interface
  11. *
  12. * Currently {@link CPDF_Adapter}, {@link PDFLib_Adapter}, {@link TCPDF_Adapter}, and {@link GD_Adapter}
  13. * implement this interface.
  14. *
  15. * Implementations should measure x and y increasing to the left and down,
  16. * respectively, with the origin in the top left corner. Implementations
  17. * are free to use a unit other than points for length, but I can't
  18. * guarantee that the results will look any good.
  19. *
  20. * @package dompdf
  21. */
  22. interface Canvas {
  23. function __construct($paper = "letter", $orientation = "portrait", DOMPDF $dompdf);
  24. /**
  25. * @return DOMPDF
  26. */
  27. function get_dompdf();
  28. /**
  29. * Returns the current page number
  30. *
  31. * @return int
  32. */
  33. function get_page_number();
  34. /**
  35. * Returns the total number of pages
  36. *
  37. * @return int
  38. */
  39. function get_page_count();
  40. /**
  41. * Sets the total number of pages
  42. *
  43. * @param int $count
  44. */
  45. function set_page_count($count);
  46. /**
  47. * Draws a line from x1,y1 to x2,y2
  48. *
  49. * See {@link Style::munge_color()} for the format of the color array.
  50. * See {@link Cpdf::setLineStyle()} for a description of the format of the
  51. * $style parameter (aka dash).
  52. *
  53. * @param float $x1
  54. * @param float $y1
  55. * @param float $x2
  56. * @param float $y2
  57. * @param array $color
  58. * @param float $width
  59. * @param array $style
  60. */
  61. function line($x1, $y1, $x2, $y2, $color, $width, $style = null);
  62. /**
  63. * Draws a rectangle at x1,y1 with width w and height h
  64. *
  65. * See {@link Style::munge_color()} for the format of the color array.
  66. * See {@link Cpdf::setLineStyle()} for a description of the $style
  67. * parameter (aka dash)
  68. *
  69. * @param float $x1
  70. * @param float $y1
  71. * @param float $w
  72. * @param float $h
  73. * @param array $color
  74. * @param float $width
  75. * @param array $style
  76. */
  77. function rectangle($x1, $y1, $w, $h, $color, $width, $style = null);
  78. /**
  79. * Draws a filled rectangle at x1,y1 with width w and height h
  80. *
  81. * See {@link Style::munge_color()} for the format of the color array.
  82. *
  83. * @param float $x1
  84. * @param float $y1
  85. * @param float $w
  86. * @param float $h
  87. * @param array $color
  88. */
  89. function filled_rectangle($x1, $y1, $w, $h, $color);
  90. /**
  91. * Starts a clipping rectangle at x1,y1 with width w and height h
  92. *
  93. * @param float $x1
  94. * @param float $y1
  95. * @param float $w
  96. * @param float $h
  97. */
  98. function clipping_rectangle($x1, $y1, $w, $h);
  99. /**
  100. * Starts a rounded clipping rectangle at x1,y1 with width w and height h
  101. *
  102. * @param float $x1
  103. * @param float $y1
  104. * @param float $w
  105. * @param float $h
  106. * @param float $tl
  107. * @param float $tr
  108. * @param float $br
  109. * @param float $bl
  110. *
  111. * @return
  112. */
  113. function clipping_roundrectangle($x1, $y1, $w, $h, $tl, $tr, $br, $bl);
  114. /**
  115. * Ends the last clipping shape
  116. */
  117. function clipping_end();
  118. /**
  119. * Save current state
  120. */
  121. function save();
  122. /**
  123. * Restore last state
  124. */
  125. function restore();
  126. /**
  127. * Rotate
  128. */
  129. function rotate($angle, $x, $y);
  130. /**
  131. * Skew
  132. */
  133. function skew($angle_x, $angle_y, $x, $y);
  134. /**
  135. * Scale
  136. */
  137. function scale($s_x, $s_y, $x, $y);
  138. /**
  139. * Translate
  140. */
  141. function translate($t_x, $t_y);
  142. /**
  143. * Transform
  144. */
  145. function transform($a, $b, $c, $d, $e, $f);
  146. /**
  147. * Draws a polygon
  148. *
  149. * The polygon is formed by joining all the points stored in the $points
  150. * array. $points has the following structure:
  151. * <code>
  152. * array(0 => x1,
  153. * 1 => y1,
  154. * 2 => x2,
  155. * 3 => y2,
  156. * ...
  157. * );
  158. * </code>
  159. *
  160. * See {@link Style::munge_color()} for the format of the color array.
  161. * See {@link Cpdf::setLineStyle()} for a description of the $style
  162. * parameter (aka dash)
  163. *
  164. * @param array $points
  165. * @param array $color
  166. * @param float $width
  167. * @param array $style
  168. * @param bool $fill Fills the polygon if true
  169. */
  170. function polygon($points, $color, $width = null, $style = null, $fill = false);
  171. /**
  172. * Draws a circle at $x,$y with radius $r
  173. *
  174. * See {@link Style::munge_color()} for the format of the color array.
  175. * See {@link Cpdf::setLineStyle()} for a description of the $style
  176. * parameter (aka dash)
  177. *
  178. * @param float $x
  179. * @param float $y
  180. * @param float $r
  181. * @param array $color
  182. * @param float $width
  183. * @param array $style
  184. * @param bool $fill Fills the circle if true
  185. */
  186. function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false);
  187. /**
  188. * Add an image to the pdf.
  189. *
  190. * The image is placed at the specified x and y coordinates with the
  191. * given width and height.
  192. *
  193. * @param string $img_url the path to the image
  194. * @param float $x x position
  195. * @param float $y y position
  196. * @param int $w width (in pixels)
  197. * @param int $h height (in pixels)
  198. * @param string $resolution The resolution of the image
  199. */
  200. function image($img_url, $x, $y, $w, $h, $resolution = "normal");
  201. /**
  202. * Add an arc to the PDF
  203. * See {@link Style::munge_color()} for the format of the color array.
  204. *
  205. * @param float $x X coordinate of the arc
  206. * @param float $y Y coordinate of the arc
  207. * @param float $r1 Radius 1
  208. * @param float $r2 Radius 2
  209. * @param float $astart Start angle in degrees
  210. * @param float $aend End angle in degrees
  211. * @param array $color Color
  212. * @param float $width
  213. * @param array $style
  214. *
  215. * @return void
  216. */
  217. function arc($x, $y, $r1, $r2, $astart, $aend, $color, $width, $style = array());
  218. /**
  219. * Writes text at the specified x and y coordinates
  220. * See {@link Style::munge_color()} for the format of the color array.
  221. *
  222. * @param float $x
  223. * @param float $y
  224. * @param string $text the text to write
  225. * @param string $font the font file to use
  226. * @param float $size the font size, in points
  227. * @param array $color
  228. * @param float $word_space word spacing adjustment
  229. * @param float $char_space char spacing adjustment
  230. * @param float $angle angle
  231. *
  232. * @return void
  233. */
  234. function text($x, $y, $text, $font, $size, $color = array(0,0,0), $word_space = 0.0, $char_space = 0.0, $angle = 0.0);
  235. /**
  236. * Add a named destination (similar to <a name="foo">...</a> in html)
  237. *
  238. * @param string $anchorname The name of the named destination
  239. */
  240. function add_named_dest($anchorname);
  241. /**
  242. * Add a link to the pdf
  243. *
  244. * @param string $url The url to link to
  245. * @param float $x The x position of the link
  246. * @param float $y The y position of the link
  247. * @param float $width The width of the link
  248. * @param float $height The height of the link
  249. *
  250. * @return void
  251. */
  252. function add_link($url, $x, $y, $width, $height);
  253. /**
  254. * Add meta information to the pdf
  255. *
  256. * @param string $name Label of the value (Creator, Producer, etc.)
  257. * @param string $value The text to set
  258. */
  259. function add_info($name, $value);
  260. /**
  261. * Calculates text size, in points
  262. *
  263. * @param string $text the text to be sized
  264. * @param string $font the desired font
  265. * @param float $size the desired font size
  266. * @param float $word_spacing word spacing, if any
  267. * @param float $char_spacing
  268. *
  269. * @return float
  270. */
  271. function get_text_width($text, $font, $size, $word_spacing = 0.0, $char_spacing = 0.0);
  272. /**
  273. * Calculates font height, in points
  274. *
  275. * @param string $font
  276. * @param float $size
  277. *
  278. * @return float
  279. */
  280. function get_font_height($font, $size);
  281. /**
  282. * Calculates font baseline, in points
  283. *
  284. * @param string $font
  285. * @param float $size
  286. *
  287. * @return float
  288. */
  289. function get_font_baseline($font, $size);
  290. /**
  291. * Returns the font x-height, in points
  292. *
  293. * @param string $font
  294. * @param float $size
  295. *
  296. * @return float
  297. */
  298. //function get_font_x_height($font, $size);
  299. /**
  300. * Sets the opacity
  301. *
  302. * @param float $opacity
  303. * @param string $mode
  304. */
  305. function set_opacity($opacity, $mode = "Normal");
  306. /**
  307. * Sets the default view
  308. *
  309. * @param string $view
  310. * 'XYZ' left, top, zoom
  311. * 'Fit'
  312. * 'FitH' top
  313. * 'FitV' left
  314. * 'FitR' left,bottom,right
  315. * 'FitB'
  316. * 'FitBH' top
  317. * 'FitBV' left
  318. * @param array $options
  319. *
  320. * @return void
  321. */
  322. function set_default_view($view, $options = array());
  323. /**
  324. * @param string $script
  325. *
  326. * @return void
  327. */
  328. function javascript($script);
  329. /**
  330. * Starts a new page
  331. *
  332. * Subsequent drawing operations will appear on the new page.
  333. */
  334. function new_page();
  335. /**
  336. * Streams the PDF directly to the browser
  337. *
  338. * @param string $filename the name of the PDF file
  339. * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
  340. */
  341. function stream($filename, $options = null);
  342. /**
  343. * Returns the PDF as a string
  344. *
  345. * @param array $options associative array: 'compress' => 1 or 0
  346. * @return string
  347. */
  348. function output($options = null);
  349. }