@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: gd_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -49,73 +48,73 @@ discard block |
||
49 | 48 | */ |
50 | 49 | class GD_Adapter implements Canvas { |
51 | 50 | |
52 | - /** |
|
53 | - * Resoure handle for the image |
|
54 | - * |
|
55 | - * @var resource |
|
56 | - */ |
|
57 | - private $_img; |
|
58 | - |
|
59 | - /** |
|
60 | - * Image width in pixels |
|
61 | - * |
|
62 | - * @var int |
|
63 | - */ |
|
64 | - private $_width; |
|
65 | - |
|
66 | - /** |
|
67 | - * Image height in pixels |
|
68 | - * |
|
69 | - * @var int |
|
70 | - */ |
|
71 | - private $_height; |
|
72 | - |
|
73 | - /** |
|
74 | - * Image antialias factor |
|
75 | - * |
|
76 | - * @var float |
|
77 | - */ |
|
78 | - private $_aa_factor; |
|
79 | - |
|
80 | - /** |
|
81 | - * Allocated colors |
|
82 | - * |
|
83 | - * @var array |
|
84 | - */ |
|
85 | - private $_colors; |
|
86 | - |
|
87 | - /** |
|
88 | - * Background color |
|
89 | - * |
|
90 | - * @var int |
|
91 | - */ |
|
92 | - private $_bg_color; |
|
51 | + /** |
|
52 | + * Resoure handle for the image |
|
53 | + * |
|
54 | + * @var resource |
|
55 | + */ |
|
56 | + private $_img; |
|
57 | + |
|
58 | + /** |
|
59 | + * Image width in pixels |
|
60 | + * |
|
61 | + * @var int |
|
62 | + */ |
|
63 | + private $_width; |
|
64 | + |
|
65 | + /** |
|
66 | + * Image height in pixels |
|
67 | + * |
|
68 | + * @var int |
|
69 | + */ |
|
70 | + private $_height; |
|
71 | + |
|
72 | + /** |
|
73 | + * Image antialias factor |
|
74 | + * |
|
75 | + * @var float |
|
76 | + */ |
|
77 | + private $_aa_factor; |
|
78 | + |
|
79 | + /** |
|
80 | + * Allocated colors |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + private $_colors; |
|
85 | + |
|
86 | + /** |
|
87 | + * Background color |
|
88 | + * |
|
89 | + * @var int |
|
90 | + */ |
|
91 | + private $_bg_color; |
|
93 | 92 | |
94 | - /** |
|
95 | - * Class constructor |
|
96 | - * |
|
97 | - * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
98 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
100 | - * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
101 | - */ |
|
102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
93 | + /** |
|
94 | + * Class constructor |
|
95 | + * |
|
96 | + * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
97 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
98 | + * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
99 | + * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
100 | + */ |
|
101 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
103 | 102 | |
104 | 103 | if ( !is_array($size) ) { |
105 | 104 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
105 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
107 | 106 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
108 | - else |
|
107 | + else |
|
109 | 108 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
110 | 109 | |
111 | 110 | } |
112 | 111 | |
113 | 112 | if ( strtolower($orientation) === "landscape" ) { |
114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
113 | + list($size[2],$size[3]) = array($size[3],$size[2]); |
|
115 | 114 | } |
116 | 115 | |
117 | 116 | if ( $aa_factor < 1 ) |
118 | - $aa_factor = 1; |
|
117 | + $aa_factor = 1; |
|
119 | 118 | |
120 | 119 | $this->_aa_factor = $aa_factor; |
121 | 120 | |
@@ -128,8 +127,8 @@ discard block |
||
128 | 127 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
129 | 128 | |
130 | 129 | if ( is_null($bg_color) || !is_array($bg_color) ) { |
131 | - // Pure white bg |
|
132 | - $bg_color = array(1,1,1,0); |
|
130 | + // Pure white bg |
|
131 | + $bg_color = array(1,1,1,0); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -137,68 +136,68 @@ discard block |
||
137 | 136 | imagesavealpha($this->_img, true); |
138 | 137 | imagefill($this->_img, 0, 0, $this->_bg_color); |
139 | 138 | |
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Return the GF image resource |
|
144 | - * |
|
145 | - * @return resource |
|
146 | - */ |
|
147 | - function get_image() { return $this->_img; } |
|
148 | - |
|
149 | - /** |
|
150 | - * Return the image's width in pixels |
|
151 | - * |
|
152 | - * @return float |
|
153 | - */ |
|
154 | - function get_width() { return $this->_width / $this->_aa_factor; } |
|
155 | - |
|
156 | - /** |
|
157 | - * Return the image's height in pixels |
|
158 | - * |
|
159 | - * @return float |
|
160 | - */ |
|
161 | - function get_height() { return $this->_height / $this->_aa_factor; } |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Return the GF image resource |
|
143 | + * |
|
144 | + * @return resource |
|
145 | + */ |
|
146 | + function get_image() { return $this->_img; } |
|
147 | + |
|
148 | + /** |
|
149 | + * Return the image's width in pixels |
|
150 | + * |
|
151 | + * @return float |
|
152 | + */ |
|
153 | + function get_width() { return $this->_width / $this->_aa_factor; } |
|
154 | + |
|
155 | + /** |
|
156 | + * Return the image's height in pixels |
|
157 | + * |
|
158 | + * @return float |
|
159 | + */ |
|
160 | + function get_height() { return $this->_height / $this->_aa_factor; } |
|
162 | 161 | |
163 | - /** |
|
164 | - * Returns the current page number |
|
165 | - * |
|
166 | - * @return int |
|
167 | - */ |
|
168 | - function get_page_number() { |
|
162 | + /** |
|
163 | + * Returns the current page number |
|
164 | + * |
|
165 | + * @return int |
|
166 | + */ |
|
167 | + function get_page_number() { |
|
169 | 168 | // FIXME |
170 | - } |
|
169 | + } |
|
171 | 170 | |
172 | - /** |
|
173 | - * Returns the total number of pages |
|
174 | - * |
|
175 | - * @return int |
|
176 | - */ |
|
177 | - function get_page_count() { |
|
171 | + /** |
|
172 | + * Returns the total number of pages |
|
173 | + * |
|
174 | + * @return int |
|
175 | + */ |
|
176 | + function get_page_count() { |
|
178 | 177 | // FIXME |
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Sets the total number of pages |
|
183 | - * |
|
184 | - * @param int $count |
|
185 | - */ |
|
186 | - function set_page_count($count) { |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Sets the total number of pages |
|
182 | + * |
|
183 | + * @param int $count |
|
184 | + */ |
|
185 | + function set_page_count($count) { |
|
187 | 186 | // FIXME |
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Allocate a new color. Allocate with GD as needed and store |
|
192 | - * previously allocated colors in $this->_colors. |
|
193 | - * |
|
194 | - * @param array $color The new current color |
|
195 | - * @return int The allocated color |
|
196 | - */ |
|
197 | - private function _allocate_color($color) { |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Allocate a new color. Allocate with GD as needed and store |
|
191 | + * previously allocated colors in $this->_colors. |
|
192 | + * |
|
193 | + * @param array $color The new current color |
|
194 | + * @return int The allocated color |
|
195 | + */ |
|
196 | + private function _allocate_color($color) { |
|
198 | 197 | |
199 | 198 | // Full opacity if no alpha set |
200 | 199 | if ( !isset($color[3]) ) |
201 | - $color[3] = 0; |
|
200 | + $color[3] = 0; |
|
202 | 201 | |
203 | 202 | list($r,$g,$b,$a) = $color; |
204 | 203 | |
@@ -221,33 +220,33 @@ discard block |
||
221 | 220 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 221 | |
223 | 222 | if ( isset($this->_colors[$key]) ) |
224 | - return $this->_colors[$key]; |
|
223 | + return $this->_colors[$key]; |
|
225 | 224 | |
226 | 225 | if ( $a != 0 ) |
227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
226 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
228 | 227 | else |
229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
228 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
230 | 229 | |
231 | 230 | return $this->_colors[$key]; |
232 | 231 | |
233 | - } |
|
232 | + } |
|
234 | 233 | |
235 | - /** |
|
236 | - * Draws a line from x1,y1 to x2,y2 |
|
237 | - * |
|
238 | - * See {@link Style::munge_color()} for the format of the color array. |
|
239 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
240 | - * $style parameter (aka dash). |
|
241 | - * |
|
242 | - * @param float $x1 |
|
243 | - * @param float $y1 |
|
244 | - * @param float $x2 |
|
245 | - * @param float $y2 |
|
246 | - * @param array $color |
|
247 | - * @param float $width |
|
248 | - * @param array $style |
|
249 | - */ |
|
250 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
234 | + /** |
|
235 | + * Draws a line from x1,y1 to x2,y2 |
|
236 | + * |
|
237 | + * See {@link Style::munge_color()} for the format of the color array. |
|
238 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
239 | + * $style parameter (aka dash). |
|
240 | + * |
|
241 | + * @param float $x1 |
|
242 | + * @param float $y1 |
|
243 | + * @param float $x2 |
|
244 | + * @param float $y2 |
|
245 | + * @param array $color |
|
246 | + * @param float $width |
|
247 | + * @param array $style |
|
248 | + */ |
|
249 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
251 | 250 | |
252 | 251 | // Scale by the AA factor |
253 | 252 | $x1 *= $this->_aa_factor; |
@@ -260,63 +259,63 @@ discard block |
||
260 | 259 | |
261 | 260 | // Convert the style array if required |
262 | 261 | if ( !is_null($style) ) { |
263 | - $gd_style = array(); |
|
262 | + $gd_style = array(); |
|
264 | 263 | |
265 | - if ( count($style) == 1 ) { |
|
264 | + if ( count($style) == 1 ) { |
|
266 | 265 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
267 | - $gd_style[] = $c; |
|
266 | + $gd_style[] = $c; |
|
268 | 267 | } |
269 | 268 | |
270 | 269 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
271 | - $gd_style[] = $this->_bg_color; |
|
270 | + $gd_style[] = $this->_bg_color; |
|
272 | 271 | } |
273 | 272 | |
274 | - } else { |
|
273 | + } else { |
|
275 | 274 | |
276 | 275 | $i = 0; |
277 | 276 | foreach ($style as $length) { |
278 | 277 | |
279 | - if ( $i % 2 == 0 ) { |
|
278 | + if ( $i % 2 == 0 ) { |
|
280 | 279 | // 'On' pattern |
281 | 280 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
282 | - $gd_style[] = $c; |
|
281 | + $gd_style[] = $c; |
|
283 | 282 | |
284 | - } else { |
|
283 | + } else { |
|
285 | 284 | // Off pattern |
286 | 285 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
287 | - $gd_style[] = $this->_bg_color; |
|
286 | + $gd_style[] = $this->_bg_color; |
|
288 | 287 | |
289 | - } |
|
290 | - $i++; |
|
288 | + } |
|
289 | + $i++; |
|
290 | + } |
|
291 | 291 | } |
292 | - } |
|
293 | 292 | |
294 | - imagesetstyle($this->_img, $gd_style); |
|
295 | - $c = IMG_COLOR_STYLED; |
|
293 | + imagesetstyle($this->_img, $gd_style); |
|
294 | + $c = IMG_COLOR_STYLED; |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | imagesetthickness($this->_img, $width); |
299 | 298 | |
300 | 299 | imageline($this->_img, $x1, $y1, $x2, $y2, $c); |
301 | 300 | |
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Draws a rectangle at x1,y1 with width w and height h |
|
306 | - * |
|
307 | - * See {@link Style::munge_color()} for the format of the color array. |
|
308 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
309 | - * parameter (aka dash) |
|
310 | - * |
|
311 | - * @param float $x1 |
|
312 | - * @param float $y1 |
|
313 | - * @param float $w |
|
314 | - * @param float $h |
|
315 | - * @param array $color |
|
316 | - * @param float $width |
|
317 | - * @param array $style |
|
318 | - */ |
|
319 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Draws a rectangle at x1,y1 with width w and height h |
|
305 | + * |
|
306 | + * See {@link Style::munge_color()} for the format of the color array. |
|
307 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
308 | + * parameter (aka dash) |
|
309 | + * |
|
310 | + * @param float $x1 |
|
311 | + * @param float $y1 |
|
312 | + * @param float $w |
|
313 | + * @param float $h |
|
314 | + * @param array $color |
|
315 | + * @param float $width |
|
316 | + * @param array $style |
|
317 | + */ |
|
318 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
320 | 319 | |
321 | 320 | // Scale by the AA factor |
322 | 321 | $x1 *= $this->_aa_factor; |
@@ -328,36 +327,36 @@ discard block |
||
328 | 327 | |
329 | 328 | // Convert the style array if required |
330 | 329 | if ( !is_null($style) ) { |
331 | - $gd_style = array(); |
|
330 | + $gd_style = array(); |
|
332 | 331 | |
333 | - foreach ($style as $length) { |
|
332 | + foreach ($style as $length) { |
|
334 | 333 | for ($i = 0; $i < $length; $i++) { |
335 | - $gd_style[] = $c; |
|
334 | + $gd_style[] = $c; |
|
335 | + } |
|
336 | 336 | } |
337 | - } |
|
338 | 337 | |
339 | - imagesetstyle($this->_img, $gd_style); |
|
340 | - $c = IMG_COLOR_STYLED; |
|
338 | + imagesetstyle($this->_img, $gd_style); |
|
339 | + $c = IMG_COLOR_STYLED; |
|
341 | 340 | } |
342 | 341 | |
343 | 342 | imagesetthickness($this->_img, $width); |
344 | 343 | |
345 | 344 | imagerectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
346 | 345 | |
347 | - } |
|
348 | - |
|
349 | - /** |
|
350 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
351 | - * |
|
352 | - * See {@link Style::munge_color()} for the format of the color array. |
|
353 | - * |
|
354 | - * @param float $x1 |
|
355 | - * @param float $y1 |
|
356 | - * @param float $w |
|
357 | - * @param float $h |
|
358 | - * @param array $color |
|
359 | - */ |
|
360 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
350 | + * |
|
351 | + * See {@link Style::munge_color()} for the format of the color array. |
|
352 | + * |
|
353 | + * @param float $x1 |
|
354 | + * @param float $y1 |
|
355 | + * @param float $w |
|
356 | + * @param float $h |
|
357 | + * @param array $color |
|
358 | + */ |
|
359 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
361 | 360 | |
362 | 361 | // Scale by the AA factor |
363 | 362 | $x1 *= $this->_aa_factor; |
@@ -369,79 +368,79 @@ discard block |
||
369 | 368 | |
370 | 369 | imagefilledrectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
371 | 370 | |
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Draws a polygon |
|
376 | - * |
|
377 | - * The polygon is formed by joining all the points stored in the $points |
|
378 | - * array. $points has the following structure: |
|
379 | - * <code> |
|
380 | - * array(0 => x1, |
|
381 | - * 1 => y1, |
|
382 | - * 2 => x2, |
|
383 | - * 3 => y2, |
|
384 | - * ... |
|
385 | - * ); |
|
386 | - * </code> |
|
387 | - * |
|
388 | - * See {@link Style::munge_color()} for the format of the color array. |
|
389 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
390 | - * parameter (aka dash) |
|
391 | - * |
|
392 | - * @param array $points |
|
393 | - * @param array $color |
|
394 | - * @param float $width |
|
395 | - * @param array $style |
|
396 | - * @param bool $fill Fills the polygon if true |
|
397 | - */ |
|
398 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Draws a polygon |
|
375 | + * |
|
376 | + * The polygon is formed by joining all the points stored in the $points |
|
377 | + * array. $points has the following structure: |
|
378 | + * <code> |
|
379 | + * array(0 => x1, |
|
380 | + * 1 => y1, |
|
381 | + * 2 => x2, |
|
382 | + * 3 => y2, |
|
383 | + * ... |
|
384 | + * ); |
|
385 | + * </code> |
|
386 | + * |
|
387 | + * See {@link Style::munge_color()} for the format of the color array. |
|
388 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
389 | + * parameter (aka dash) |
|
390 | + * |
|
391 | + * @param array $points |
|
392 | + * @param array $color |
|
393 | + * @param float $width |
|
394 | + * @param array $style |
|
395 | + * @param bool $fill Fills the polygon if true |
|
396 | + */ |
|
397 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
399 | 398 | |
400 | 399 | // Scale each point by the AA factor |
401 | 400 | foreach (array_keys($points) as $i) |
402 | - $points[$i] *= $this->_aa_factor; |
|
401 | + $points[$i] *= $this->_aa_factor; |
|
403 | 402 | |
404 | 403 | $c = $this->_allocate_color($color); |
405 | 404 | |
406 | 405 | // Convert the style array if required |
407 | 406 | if ( !is_null($style) && !$fill ) { |
408 | - $gd_style = array(); |
|
407 | + $gd_style = array(); |
|
409 | 408 | |
410 | - foreach ($style as $length) { |
|
409 | + foreach ($style as $length) { |
|
411 | 410 | for ($i = 0; $i < $length; $i++) { |
412 | - $gd_style[] = $c; |
|
411 | + $gd_style[] = $c; |
|
412 | + } |
|
413 | 413 | } |
414 | - } |
|
415 | 414 | |
416 | - imagesetstyle($this->_img, $gd_style); |
|
417 | - $c = IMG_COLOR_STYLED; |
|
415 | + imagesetstyle($this->_img, $gd_style); |
|
416 | + $c = IMG_COLOR_STYLED; |
|
418 | 417 | } |
419 | 418 | |
420 | 419 | imagesetthickness($this->_img, $width); |
421 | 420 | |
422 | 421 | if ( $fill ) |
423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
422 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | 423 | else |
425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
426 | 425 | |
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Draws a circle at $x,$y with radius $r |
|
431 | - * |
|
432 | - * See {@link Style::munge_color()} for the format of the color array. |
|
433 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
434 | - * parameter (aka dash) |
|
435 | - * |
|
436 | - * @param float $x |
|
437 | - * @param float $y |
|
438 | - * @param float $r |
|
439 | - * @param array $color |
|
440 | - * @param float $width |
|
441 | - * @param array $style |
|
442 | - * @param bool $fill Fills the circle if true |
|
443 | - */ |
|
444 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * Draws a circle at $x,$y with radius $r |
|
430 | + * |
|
431 | + * See {@link Style::munge_color()} for the format of the color array. |
|
432 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
433 | + * parameter (aka dash) |
|
434 | + * |
|
435 | + * @param float $x |
|
436 | + * @param float $y |
|
437 | + * @param float $r |
|
438 | + * @param array $color |
|
439 | + * @param float $width |
|
440 | + * @param array $style |
|
441 | + * @param bool $fill Fills the circle if true |
|
442 | + */ |
|
443 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
445 | 444 | |
446 | 445 | // Scale by the AA factor |
447 | 446 | $x *= $this->_aa_factor; |
@@ -452,55 +451,55 @@ discard block |
||
452 | 451 | |
453 | 452 | // Convert the style array if required |
454 | 453 | if ( !is_null($style) && !$fill ) { |
455 | - $gd_style = array(); |
|
454 | + $gd_style = array(); |
|
456 | 455 | |
457 | - foreach ($style as $length) { |
|
456 | + foreach ($style as $length) { |
|
458 | 457 | for ($i = 0; $i < $length; $i++) { |
459 | - $gd_style[] = $c; |
|
458 | + $gd_style[] = $c; |
|
459 | + } |
|
460 | 460 | } |
461 | - } |
|
462 | 461 | |
463 | - imagesetstyle($this->_img, $gd_style); |
|
464 | - $c = IMG_COLOR_STYLED; |
|
462 | + imagesetstyle($this->_img, $gd_style); |
|
463 | + $c = IMG_COLOR_STYLED; |
|
465 | 464 | } |
466 | 465 | |
467 | 466 | imagesetthickness($this->_img, $width); |
468 | 467 | |
469 | 468 | if ( $fill ) |
470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
469 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | 470 | else |
472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
473 | 472 | |
474 | - } |
|
475 | - |
|
476 | - /** |
|
477 | - * Add an image to the pdf. |
|
478 | - * |
|
479 | - * The image is placed at the specified x and y coordinates with the |
|
480 | - * given width and height. |
|
481 | - * |
|
482 | - * @param string $img_url the path to the image |
|
483 | - * @param string $img_type the type (e.g. extension) of the image |
|
484 | - * @param float $x x position |
|
485 | - * @param float $y y position |
|
486 | - * @param int $w width (in pixels) |
|
487 | - * @param int $h height (in pixels) |
|
488 | - */ |
|
489 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
473 | + } |
|
474 | + |
|
475 | + /** |
|
476 | + * Add an image to the pdf. |
|
477 | + * |
|
478 | + * The image is placed at the specified x and y coordinates with the |
|
479 | + * given width and height. |
|
480 | + * |
|
481 | + * @param string $img_url the path to the image |
|
482 | + * @param string $img_type the type (e.g. extension) of the image |
|
483 | + * @param float $x x position |
|
484 | + * @param float $y y position |
|
485 | + * @param int $w width (in pixels) |
|
486 | + * @param int $h height (in pixels) |
|
487 | + */ |
|
488 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
490 | 489 | |
491 | 490 | switch ($img_type) { |
492 | 491 | case "png": |
493 | 492 | $src = @imagecreatefrompng($img_url); |
494 | - break; |
|
493 | + break; |
|
495 | 494 | |
496 | 495 | case "gif": |
497 | 496 | $src = @imagecreatefromgif($img_url); |
498 | - break; |
|
497 | + break; |
|
499 | 498 | |
500 | 499 | case "jpg": |
501 | 500 | case "jpeg": |
502 | 501 | $src = @imagecreatefromjpeg($img_url); |
503 | - break; |
|
502 | + break; |
|
504 | 503 | |
505 | 504 | default: |
506 | 505 | break; |
@@ -508,7 +507,7 @@ discard block |
||
508 | 507 | } |
509 | 508 | |
510 | 509 | if ( !$src ) |
511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
510 | + return; // Probably should add to $_dompdf_errors or whatever here |
|
512 | 511 | |
513 | 512 | // Scale by the AA factor |
514 | 513 | $x *= $this->_aa_factor; |
@@ -523,23 +522,23 @@ discard block |
||
523 | 522 | |
524 | 523 | imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h); |
525 | 524 | |
526 | - } |
|
527 | - |
|
528 | - /** |
|
529 | - * Writes text at the specified x and y coordinates |
|
530 | - * |
|
531 | - * See {@link Style::munge_color()} for the format of the color array. |
|
532 | - * |
|
533 | - * @param float $x |
|
534 | - * @param float $y |
|
535 | - * @param string $text the text to write |
|
536 | - * @param string $font the font file to use |
|
537 | - * @param float $size the font size, in points |
|
538 | - * @param array $color |
|
539 | - * @param float $adjust word spacing adjustment |
|
540 | - * @param float $angle Text angle |
|
541 | - */ |
|
542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
525 | + } |
|
526 | + |
|
527 | + /** |
|
528 | + * Writes text at the specified x and y coordinates |
|
529 | + * |
|
530 | + * See {@link Style::munge_color()} for the format of the color array. |
|
531 | + * |
|
532 | + * @param float $x |
|
533 | + * @param float $y |
|
534 | + * @param string $text the text to write |
|
535 | + * @param string $font the font file to use |
|
536 | + * @param float $size the font size, in points |
|
537 | + * @param array $color |
|
538 | + * @param float $adjust word spacing adjustment |
|
539 | + * @param float $angle Text angle |
|
540 | + */ |
|
541 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
543 | 542 | |
544 | 543 | // Scale by the AA factor |
545 | 544 | $x *= $this->_aa_factor; |
@@ -551,106 +550,106 @@ discard block |
||
551 | 550 | $c = $this->_allocate_color($color); |
552 | 551 | |
553 | 552 | if ( strpos($font, '.ttf') === false ) |
554 | - $font .= ".ttf"; |
|
553 | + $font .= ".ttf"; |
|
555 | 554 | |
556 | 555 | // FIXME: word spacing |
557 | 556 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
558 | 557 | |
559 | - } |
|
558 | + } |
|
560 | 559 | |
561 | - function javascript($code) { |
|
560 | + function javascript($code) { |
|
562 | 561 | // Not implemented |
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
567 | - * |
|
568 | - * @param string $anchorname The name of the named destination |
|
569 | - */ |
|
570 | - function add_named_dest($anchorname) { |
|
562 | + } |
|
563 | + |
|
564 | + /** |
|
565 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
566 | + * |
|
567 | + * @param string $anchorname The name of the named destination |
|
568 | + */ |
|
569 | + function add_named_dest($anchorname) { |
|
571 | 570 | // Not implemented |
572 | - } |
|
573 | - |
|
574 | - /** |
|
575 | - * Add a link to the pdf |
|
576 | - * |
|
577 | - * @param string $url The url to link to |
|
578 | - * @param float $x The x position of the link |
|
579 | - * @param float $y The y position of the link |
|
580 | - * @param float $width The width of the link |
|
581 | - * @param float $height The height of the link |
|
582 | - */ |
|
583 | - function add_link($url, $x, $y, $width, $height) { |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * Add a link to the pdf |
|
575 | + * |
|
576 | + * @param string $url The url to link to |
|
577 | + * @param float $x The x position of the link |
|
578 | + * @param float $y The y position of the link |
|
579 | + * @param float $width The width of the link |
|
580 | + * @param float $height The height of the link |
|
581 | + */ |
|
582 | + function add_link($url, $x, $y, $width, $height) { |
|
584 | 583 | // Not implemented |
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * Calculates text size, in points |
|
589 | - * |
|
590 | - * @param string $text the text to be sized |
|
591 | - * @param string $font the desired font |
|
592 | - * @param float $size the desired font size |
|
593 | - * @param float $spacing word spacing, if any |
|
594 | - * @return float |
|
595 | - */ |
|
596 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
584 | + } |
|
585 | + |
|
586 | + /** |
|
587 | + * Calculates text size, in points |
|
588 | + * |
|
589 | + * @param string $text the text to be sized |
|
590 | + * @param string $font the desired font |
|
591 | + * @param float $size the desired font size |
|
592 | + * @param float $spacing word spacing, if any |
|
593 | + * @return float |
|
594 | + */ |
|
595 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
597 | 596 | |
598 | 597 | if ( strpos($font, '.ttf') === false ) |
599 | - $font .= ".ttf"; |
|
598 | + $font .= ".ttf"; |
|
600 | 599 | |
601 | 600 | // FIXME: word spacing |
602 | 601 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
603 | 602 | return $x2 - $x1; |
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * Calculates font height, in points |
|
608 | - * |
|
609 | - * @param string $font |
|
610 | - * @param float $size |
|
611 | - * @return float |
|
612 | - */ |
|
613 | - function get_font_height($font, $size) { |
|
603 | + } |
|
604 | + |
|
605 | + /** |
|
606 | + * Calculates font height, in points |
|
607 | + * |
|
608 | + * @param string $font |
|
609 | + * @param float $size |
|
610 | + * @return float |
|
611 | + */ |
|
612 | + function get_font_height($font, $size) { |
|
614 | 613 | if ( strpos($font, '.ttf') === false ) |
615 | - $font .= ".ttf"; |
|
614 | + $font .= ".ttf"; |
|
616 | 615 | |
617 | 616 | // FIXME: word spacing |
618 | 617 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
619 | 618 | return $y2 - $y1; |
620 | - } |
|
619 | + } |
|
621 | 620 | |
622 | 621 | |
623 | - /** |
|
624 | - * Starts a new page |
|
625 | - * |
|
626 | - * Subsequent drawing operations will appear on the new page. |
|
627 | - */ |
|
628 | - function new_page() { |
|
622 | + /** |
|
623 | + * Starts a new page |
|
624 | + * |
|
625 | + * Subsequent drawing operations will appear on the new page. |
|
626 | + */ |
|
627 | + function new_page() { |
|
629 | 628 | // FIXME |
630 | - } |
|
629 | + } |
|
631 | 630 | |
632 | - /** |
|
633 | - * Streams the image directly to the browser |
|
634 | - * |
|
635 | - * @param string $filename the name of the image file (ignored) |
|
636 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
637 | - */ |
|
638 | - function stream($filename, $options = null) { |
|
631 | + /** |
|
632 | + * Streams the image directly to the browser |
|
633 | + * |
|
634 | + * @param string $filename the name of the image file (ignored) |
|
635 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
636 | + */ |
|
637 | + function stream($filename, $options = null) { |
|
639 | 638 | |
640 | 639 | // Perform any antialiasing |
641 | 640 | if ( $this->_aa_factor != 1 ) { |
642 | - $dst_w = $this->_width / $this->_aa_factor; |
|
643 | - $dst_h = $this->_height / $this->_aa_factor; |
|
644 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
645 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
646 | - $dst_w, $dst_h, |
|
647 | - $this->_width, $this->_height); |
|
641 | + $dst_w = $this->_width / $this->_aa_factor; |
|
642 | + $dst_h = $this->_height / $this->_aa_factor; |
|
643 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
644 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
645 | + $dst_w, $dst_h, |
|
646 | + $this->_width, $this->_height); |
|
648 | 647 | } else { |
649 | - $dst = $this->_img; |
|
648 | + $dst = $this->_img; |
|
650 | 649 | } |
651 | 650 | |
652 | 651 | if ( !isset($options["type"]) ) |
653 | - $options["type"] = "png"; |
|
652 | + $options["type"] = "png"; |
|
654 | 653 | |
655 | 654 | $type = strtolower($options["type"]); |
656 | 655 | |
@@ -663,42 +662,42 @@ discard block |
||
663 | 662 | if ( !isset($options["quality"]) ) |
664 | 663 | $options["quality"] = 75; |
665 | 664 | |
666 | - header("Content-type: image/jpeg"); |
|
667 | - imagejpeg($dst, '', $options["quality"]); |
|
668 | - break; |
|
665 | + header("Content-type: image/jpeg"); |
|
666 | + imagejpeg($dst, '', $options["quality"]); |
|
667 | + break; |
|
669 | 668 | |
670 | 669 | case "png": |
671 | 670 | default: |
672 | 671 | header("Content-type: image/png"); |
673 | - imagepng($dst); |
|
674 | - break; |
|
672 | + imagepng($dst); |
|
673 | + break; |
|
675 | 674 | } |
676 | 675 | |
677 | 676 | if ( $this->_aa_factor != 1 ) |
678 | - imagedestroy($dst); |
|
679 | - } |
|
677 | + imagedestroy($dst); |
|
678 | + } |
|
680 | 679 | |
681 | - /** |
|
682 | - * Returns the PNG as a string |
|
683 | - * |
|
684 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
685 | - * @return string |
|
686 | - */ |
|
687 | - function output($options = null) { |
|
680 | + /** |
|
681 | + * Returns the PNG as a string |
|
682 | + * |
|
683 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
684 | + * @return string |
|
685 | + */ |
|
686 | + function output($options = null) { |
|
688 | 687 | |
689 | 688 | if ( $this->_aa_factor != 1 ) { |
690 | - $dst_w = $this->_width / $this->_aa_factor; |
|
691 | - $dst_h = $this->_height / $this->_aa_factor; |
|
692 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
693 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
694 | - $dst_w, $dst_h, |
|
695 | - $this->_width, $this->_height); |
|
689 | + $dst_w = $this->_width / $this->_aa_factor; |
|
690 | + $dst_h = $this->_height / $this->_aa_factor; |
|
691 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
692 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
693 | + $dst_w, $dst_h, |
|
694 | + $this->_width, $this->_height); |
|
696 | 695 | } else { |
697 | - $dst = $this->_img; |
|
696 | + $dst = $this->_img; |
|
698 | 697 | } |
699 | 698 | |
700 | 699 | if ( !isset($options["type"]) ) |
701 | - $options["type"] = "png"; |
|
700 | + $options["type"] = "png"; |
|
702 | 701 | |
703 | 702 | $type = $options["type"]; |
704 | 703 | |
@@ -711,23 +710,23 @@ discard block |
||
711 | 710 | if ( !isset($options["quality"]) ) |
712 | 711 | $options["quality"] = 75; |
713 | 712 | |
714 | - imagejpeg($dst, '', $options["quality"]); |
|
715 | - break; |
|
713 | + imagejpeg($dst, '', $options["quality"]); |
|
714 | + break; |
|
716 | 715 | |
717 | 716 | case "png": |
718 | 717 | default: |
719 | 718 | imagepng($dst); |
720 | - break; |
|
719 | + break; |
|
721 | 720 | } |
722 | 721 | |
723 | 722 | $image = ob_get_contents(); |
724 | 723 | ob_end_clean(); |
725 | 724 | |
726 | 725 | if ( $this->_aa_factor != 1 ) |
727 | - imagedestroy($dst); |
|
726 | + imagedestroy($dst); |
|
728 | 727 | |
729 | 728 | return $image; |
730 | - } |
|
729 | + } |
|
731 | 730 | |
732 | 731 | |
733 | 732 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_cell_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,15 +46,15 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Cell_Positioner extends Positioner { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function position() { |
|
53 | + function position() { |
|
55 | 54 | |
56 | 55 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
57 | 56 | $cellmap = $table->get_cellmap(); |
58 | 57 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
59 | 58 | |
60 | - } |
|
59 | + } |
|
61 | 60 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: image_renderer.cls.php,v $ |
|
6 | - * Created on: 2004-08-04 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: image_renderer.cls.php,v $ |
|
6 | + * Created on: 2004-08-04 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: image_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,7 +46,7 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Image_Renderer extends Abstract_Renderer { |
49 | 48 | |
50 | - function render(Frame $frame) { |
|
49 | + function render(Frame $frame) { |
|
51 | 50 | |
52 | 51 | // Render background & borders |
53 | 52 | //parent::render($frame); |
@@ -65,5 +64,5 @@ discard block |
||
65 | 64 | |
66 | 65 | $this->_canvas->image( $frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h); |
67 | 66 | |
68 | - } |
|
67 | + } |
|
69 | 68 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: generated_frame_reflower.cls.php,v $ |
|
6 | - * Created on: 2004-06-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: generated_frame_reflower.cls.php,v $ |
|
6 | + * Created on: 2004-06-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: generated_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,22 +46,22 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Generated_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - protected $_reflower; // Decoration target |
|
49 | + protected $_reflower; // Decoration target |
|
51 | 50 | |
52 | - function __construct(Frame $frame) { |
|
51 | + function __construct(Frame $frame) { |
|
53 | 52 | parent::__construct($frame); |
54 | - } |
|
53 | + } |
|
55 | 54 | |
56 | - function set_reflower(Frame_Reflower $reflow) { |
|
55 | + function set_reflower(Frame_Reflower $reflow) { |
|
57 | 56 | $this->_reflower = $reflow; |
58 | - } |
|
57 | + } |
|
59 | 58 | |
60 | - //........................................................................ |
|
59 | + //........................................................................ |
|
61 | 60 | |
62 | - protected function _parse_string($string) { |
|
61 | + protected function _parse_string($string) { |
|
63 | 62 | $string = trim($string, "'\""); |
64 | 63 | $string = str_replace(array("\\\n",'\\"',"\\'"), |
65 | - array("",'"',"'"), $string); |
|
64 | + array("",'"',"'"), $string); |
|
66 | 65 | |
67 | 66 | // Convert escaped hex characters into ascii characters (e.g. \A => newline) |
68 | 67 | $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})(\s)?(?(2)|(?=[^0-9a-fA-F]))/", |
@@ -70,40 +69,40 @@ discard block |
||
70 | 69 | 'return chr(hexdec($matches[1]));'), |
71 | 70 | $string); |
72 | 71 | return $string; |
73 | - } |
|
72 | + } |
|
74 | 73 | |
75 | - protected function _parse_content() { |
|
74 | + protected function _parse_content() { |
|
76 | 75 | $style = $this->_frame->get_style(); |
77 | 76 | |
78 | 77 | // Matches generated content |
79 | 78 | $re = "/\n". |
80 | - "\s(counters?\\([^)]*\\))|\n". |
|
81 | - "\A(counters?\\([^)]*\\))|\n". |
|
82 | - "\s([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\3|\n". |
|
83 | - "\A([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\5|\n" . |
|
84 | - "\s([^\s\"']+)|\n" . |
|
85 | - "\A([^\s\"']+)\n". |
|
86 | - "/xi"; |
|
79 | + "\s(counters?\\([^)]*\\))|\n". |
|
80 | + "\A(counters?\\([^)]*\\))|\n". |
|
81 | + "\s([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\3|\n". |
|
82 | + "\A([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\5|\n" . |
|
83 | + "\s([^\s\"']+)|\n" . |
|
84 | + "\A([^\s\"']+)\n". |
|
85 | + "/xi"; |
|
87 | 86 | |
88 | 87 | $content = $style->content; |
89 | 88 | |
90 | 89 | // split on spaces, except within quotes |
91 | 90 | if (!preg_match_all($re, $content, $matches, PREG_SET_ORDER)) |
92 | - return; |
|
91 | + return; |
|
93 | 92 | |
94 | 93 | $text = ""; |
95 | 94 | |
96 | 95 | foreach ($matches as $match) { |
97 | - if ( isset($match[2]) && $match[2] !== "" ) |
|
96 | + if ( isset($match[2]) && $match[2] !== "" ) |
|
98 | 97 | $match[1] = $match[1]; |
99 | 98 | |
100 | - if ( isset($match[6]) && $match[6] !== "" ) |
|
99 | + if ( isset($match[6]) && $match[6] !== "" ) |
|
101 | 100 | $match[4] = $match[6]; |
102 | 101 | |
103 | - if ( isset($match[8]) && $match[8] !== "" ) |
|
102 | + if ( isset($match[8]) && $match[8] !== "" ) |
|
104 | 103 | $match[7] = $match[8]; |
105 | 104 | |
106 | - if ( isset($match[1]) && $match[1] !== "" ) { |
|
105 | + if ( isset($match[1]) && $match[1] !== "" ) { |
|
107 | 106 | // counters?(...) |
108 | 107 | $match[1] = mb_strtolower(trim($match[1])); |
109 | 108 | |
@@ -112,85 +111,85 @@ discard block |
||
112 | 111 | |
113 | 112 | $i = mb_strpos($match[1], ")"); |
114 | 113 | if ( $i === false ) |
115 | - continue; |
|
114 | + continue; |
|
116 | 115 | |
117 | 116 | $args = explode(",", mb_substr($match[1], 7, $i - 7)); |
118 | 117 | $counter_id = $args[0]; |
119 | 118 | |
120 | 119 | if ( $match[1]{7} === "(" ) { |
121 | - // counter(name [,style]) |
|
120 | + // counter(name [,style]) |
|
122 | 121 | |
123 | - if ( isset($args[1]) ) |
|
122 | + if ( isset($args[1]) ) |
|
124 | 123 | $type = $args[1]; |
125 | - else |
|
124 | + else |
|
126 | 125 | $type = null; |
127 | 126 | |
128 | 127 | |
129 | - $p = $this->_frame->find_block_parent(); |
|
128 | + $p = $this->_frame->find_block_parent(); |
|
130 | 129 | |
131 | - $text .= $p->counter_value($counter_id, $type); |
|
130 | + $text .= $p->counter_value($counter_id, $type); |
|
132 | 131 | |
133 | 132 | } else if ( $match[1]{7} === "s" ) { |
134 | - // counters(name, string [,style]) |
|
135 | - if ( isset($args[1]) ) |
|
133 | + // counters(name, string [,style]) |
|
134 | + if ( isset($args[1]) ) |
|
136 | 135 | $string = $this->_parse_string(trim($args[1])); |
137 | - else |
|
136 | + else |
|
138 | 137 | $string = ""; |
139 | 138 | |
140 | - if ( isset($args[2]) ) |
|
139 | + if ( isset($args[2]) ) |
|
141 | 140 | $type = $args[2]; |
142 | - else |
|
141 | + else |
|
143 | 142 | $type = null; |
144 | 143 | |
145 | - $p = $this->_frame->find_block_parent(); |
|
146 | - $tmp = ""; |
|
147 | - while ($p) { |
|
144 | + $p = $this->_frame->find_block_parent(); |
|
145 | + $tmp = ""; |
|
146 | + while ($p) { |
|
148 | 147 | $tmp = $p->counter_value($counter_id, $type) . $string . $tmp; |
149 | 148 | $p = $p->find_block_parent(); |
150 | - } |
|
151 | - $text .= $tmp; |
|
149 | + } |
|
150 | + $text .= $tmp; |
|
152 | 151 | |
153 | 152 | } else |
154 | - // countertops? |
|
155 | - continue; |
|
153 | + // countertops? |
|
154 | + continue; |
|
156 | 155 | |
157 | - } else if ( isset($match[4]) && $match[4] !== "" ) { |
|
156 | + } else if ( isset($match[4]) && $match[4] !== "" ) { |
|
158 | 157 | // String match |
159 | 158 | $text .= $this->_parse_string($match[4]); |
160 | 159 | |
161 | - } else if ( isset($match[7]) && $match[7] !== "" ) { |
|
160 | + } else if ( isset($match[7]) && $match[7] !== "" ) { |
|
162 | 161 | // Directive match |
163 | 162 | |
164 | 163 | if ( $match[7] === "open-quote" ) { |
165 | - // FIXME: do something here |
|
164 | + // FIXME: do something here |
|
166 | 165 | } else if ( $match[7] === "close-quote" ) { |
167 | - // FIXME: do something else here |
|
166 | + // FIXME: do something else here |
|
168 | 167 | } else if ( $match[7] === "no-open-quote" ) { |
169 | - // FIXME: |
|
168 | + // FIXME: |
|
170 | 169 | } else if ( $match[7] === "no-close-quote" ) { |
171 | - // FIXME: |
|
170 | + // FIXME: |
|
172 | 171 | } else if ( mb_strpos($match[7],"attr(") === 0 ) { |
173 | 172 | |
174 | - $i = mb_strpos($match[7],")"); |
|
175 | - if ( $i === false ) |
|
173 | + $i = mb_strpos($match[7],")"); |
|
174 | + if ( $i === false ) |
|
176 | 175 | continue; |
177 | 176 | |
178 | - $attr = mb_substr($match[7], 6, $i - 6); |
|
179 | - if ( $attr == "" ) |
|
177 | + $attr = mb_substr($match[7], 6, $i - 6); |
|
178 | + if ( $attr == "" ) |
|
180 | 179 | continue; |
181 | 180 | |
182 | - $text .= $this->_frame->get_node()->getAttribute($attr); |
|
181 | + $text .= $this->_frame->get_node()->getAttribute($attr); |
|
183 | 182 | } else |
184 | - continue; |
|
183 | + continue; |
|
185 | 184 | |
186 | - } |
|
185 | + } |
|
187 | 186 | } |
188 | 187 | |
189 | 188 | return $text; |
190 | 189 | |
191 | - } |
|
190 | + } |
|
192 | 191 | |
193 | - function reflow() { |
|
192 | + function reflow() { |
|
194 | 193 | $style = $this->_frame->get_style(); |
195 | 194 | |
196 | 195 | $text = $this->_parse_content(); |
@@ -202,5 +201,5 @@ discard block |
||
202 | 201 | |
203 | 202 | $this->_frame->prepend_child(Frame_Factory::decorate_frame($t_frame)); |
204 | 203 | $this->_reflower->reflow(); |
205 | - } |
|
204 | + } |
|
206 | 205 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: table_row_frame_reflower.cls.php,v $ |
|
6 | - * Created on: 2004-06-17 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: table_row_frame_reflower.cls.php,v $ |
|
6 | + * Created on: 2004-06-17 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: table_row_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -48,17 +47,17 @@ discard block |
||
48 | 47 | class Table_Row_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | 49 | |
51 | - function __construct(Table_Row_Frame_Decorator $frame) { |
|
50 | + function __construct(Table_Row_Frame_Decorator $frame) { |
|
52 | 51 | parent::__construct($frame); |
53 | - } |
|
52 | + } |
|
54 | 53 | |
55 | - //........................................................................ |
|
54 | + //........................................................................ |
|
56 | 55 | |
57 | - function reflow() { |
|
56 | + function reflow() { |
|
58 | 57 | $page = $this->_frame->get_root(); |
59 | 58 | |
60 | 59 | if ( $page->is_full() ) |
61 | - return; |
|
60 | + return; |
|
62 | 61 | |
63 | 62 | $this->_frame->position(); |
64 | 63 | $style = $this->_frame->get_style(); |
@@ -66,16 +65,16 @@ discard block |
||
66 | 65 | |
67 | 66 | foreach ($this->_frame->get_children() as $child) { |
68 | 67 | |
69 | - if ( $page->is_full() ) |
|
68 | + if ( $page->is_full() ) |
|
70 | 69 | return; |
71 | 70 | |
72 | - $child->set_containing_block($cb); |
|
73 | - $child->reflow(); |
|
71 | + $child->set_containing_block($cb); |
|
72 | + $child->reflow(); |
|
74 | 73 | |
75 | 74 | } |
76 | 75 | |
77 | 76 | if ( $page->is_full() ) |
78 | - return; |
|
77 | + return; |
|
79 | 78 | |
80 | 79 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
81 | 80 | $cellmap = $table->get_cellmap(); |
@@ -84,11 +83,11 @@ discard block |
||
84 | 83 | |
85 | 84 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
86 | 85 | |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - //........................................................................ |
|
88 | + //........................................................................ |
|
90 | 89 | |
91 | - function get_min_max_width() { |
|
90 | + function get_min_max_width() { |
|
92 | 91 | throw new DOMPDF_Exception("Min/max width is undefined for table rows"); |
93 | - } |
|
92 | + } |
|
94 | 93 | } |
@@ -1,47 +1,46 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: list_bullet_frame_decorator.cls.php,v $ |
|
6 | - * Created on: 2004-06-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - |
|
39 | - * |
|
40 | - * Changes |
|
41 | - * @contributor Helmut Tischer <[email protected]> |
|
42 | - * @version 20090622 |
|
43 | - * - bullet size proportional to font size, center position |
|
44 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: list_bullet_frame_decorator.cls.php,v $ |
|
6 | + * Created on: 2004-06-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 20090622 |
|
42 | + * - bullet size proportional to font size, center position |
|
43 | + */ |
|
45 | 44 | |
46 | 45 | /* $Id: list_bullet_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
47 | 46 | |
@@ -53,42 +52,42 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class List_Bullet_Frame_Decorator extends Frame_Decorator { |
55 | 54 | |
56 | - const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
57 | - // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
58 | - const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
59 | - const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
60 | - const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
55 | + const BULLET_PADDING = 1; // Distance from bullet to text in pt |
|
56 | + // As fraction of font size (including descent). See also DECO_THICKNESS. |
|
57 | + const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | + const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
59 | + const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
61 | 60 | |
62 | - static $BULLET_TYPES = array("disc", "circle", "square"); |
|
61 | + static $BULLET_TYPES = array("disc", "circle", "square"); |
|
63 | 62 | |
64 | - //........................................................................ |
|
63 | + //........................................................................ |
|
65 | 64 | |
66 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
65 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
67 | 66 | parent::__construct($frame, $dompdf); |
68 | - } |
|
67 | + } |
|
69 | 68 | |
70 | - function get_margin_width() { |
|
69 | + function get_margin_width() { |
|
71 | 70 | $style = $this->_frame->get_style(); |
72 | 71 | // Small hack to prevent extra indenting of list text on list_style_position === "inside" |
73 | 72 | // and on suppressed bullet |
74 | 73 | if ( $style->list_style_position === "outside" || |
75 | 74 | $style->list_style_type === "none" ) |
76 | - return 0; |
|
75 | + return 0; |
|
77 | 76 | return $style->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
78 | - } |
|
77 | + } |
|
79 | 78 | |
80 | - //hits only on "inset" lists items, to increase height of box |
|
81 | - function get_margin_height() { |
|
79 | + //hits only on "inset" lists items, to increase height of box |
|
80 | + function get_margin_height() { |
|
82 | 81 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
83 | - } |
|
82 | + } |
|
84 | 83 | |
85 | - function get_width() { |
|
84 | + function get_width() { |
|
86 | 85 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - function get_height() { |
|
88 | + function get_height() { |
|
90 | 89 | return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
91 | - } |
|
90 | + } |
|
92 | 91 | |
93 | - //........................................................................ |
|
92 | + //........................................................................ |
|
94 | 93 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: dompdf_internal_exception.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -46,14 +45,14 @@ discard block |
||
46 | 45 | */ |
47 | 46 | class DOMPDF_Internal_Exception extends Exception { |
48 | 47 | |
49 | - /** |
|
50 | - * Class constructor |
|
51 | - * |
|
52 | - * @param string $message Error message |
|
53 | - * @param int $code Error code |
|
54 | - */ |
|
55 | - function __construct($message = NULL, $code = 0) { |
|
48 | + /** |
|
49 | + * Class constructor |
|
50 | + * |
|
51 | + * @param string $message Error message |
|
52 | + * @param int $code Error code |
|
53 | + */ |
|
54 | + function __construct($message = NULL, $code = 0) { |
|
56 | 55 | parent::__construct($message, $code); |
57 | - } |
|
56 | + } |
|
58 | 57 | |
59 | 58 | } |
@@ -35,7 +35,6 @@ discard block |
||
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @contributor Helmut Tischer <[email protected]> |
37 | 37 | * @package dompdf |
38 | - |
|
39 | 38 | * |
40 | 39 | * Changes |
41 | 40 | * @contributor Helmut Tischer <[email protected]> |
@@ -53,11 +52,11 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class List_Bullet_Positioner extends Positioner { |
55 | 54 | |
56 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
55 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
57 | 56 | |
58 | - //........................................................................ |
|
57 | + //........................................................................ |
|
59 | 58 | |
60 | - function position() { |
|
59 | + function position() { |
|
61 | 60 | |
62 | 61 | // Bullets & friends are positioned an absolute distance to the left of |
63 | 62 | // the content edge of their parent element |
@@ -75,19 +74,19 @@ discard block |
||
75 | 74 | // This is a bit of a hack... |
76 | 75 | $n = $this->_frame->get_next_sibling(); |
77 | 76 | if ( $n ) { |
78 | - $style = $n->get_style(); |
|
79 | - $y += $style->length_in_pt( array($style->margin_top, $style->padding_top), |
|
80 | - $n->get_containing_block("w") ); |
|
77 | + $style = $n->get_style(); |
|
78 | + $y += $style->length_in_pt( array($style->margin_top, $style->padding_top), |
|
79 | + $n->get_containing_block("w") ); |
|
81 | 80 | } |
82 | 81 | |
83 | - // Now the position is the left top of the block which should be marked with the bullet. |
|
84 | - // We tried to find out the y of the start of the first text character within the block. |
|
85 | - // But the top margin/padding does not fit, neither from this nor from the next sibling |
|
86 | - // The "bit of a hack" above does not work also. |
|
82 | + // Now the position is the left top of the block which should be marked with the bullet. |
|
83 | + // We tried to find out the y of the start of the first text character within the block. |
|
84 | + // But the top margin/padding does not fit, neither from this nor from the next sibling |
|
85 | + // The "bit of a hack" above does not work also. |
|
87 | 86 | |
88 | - // Instead let's position the bullet vertically centered to the block which should be marked. |
|
89 | - // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent() |
|
90 | - // the get_containing_block is paper width and the entire list as height. |
|
87 | + // Instead let's position the bullet vertically centered to the block which should be marked. |
|
88 | + // But for get_next_sibling() the get_containing_block is all zero, and for find_block_parent() |
|
89 | + // the get_containing_block is paper width and the entire list as height. |
|
91 | 90 | |
92 | 91 | // if ($p) { |
93 | 92 | // //$cb = $n->get_containing_block(); |
@@ -96,8 +95,8 @@ discard block |
||
96 | 95 | // print 'cb:'.$cb["x"].':'.$cb["y"].':'.$cb["w"].':'.$cb["h"].':'; |
97 | 96 | // } |
98 | 97 | |
99 | - // Todo: |
|
100 | - // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing |
|
98 | + // Todo: |
|
99 | + // For now give up on the above. Use Guesswork with font y-pos in the middle of the line spacing |
|
101 | 100 | |
102 | 101 | $style = $p->get_style(); |
103 | 102 | $font_size = $style->get_font_size(); |
@@ -107,5 +106,5 @@ discard block |
||
107 | 106 | //Position is x-end y-top of character position of the bullet. |
108 | 107 | $this->_frame->set_position($x, $y); |
109 | 108 | |
110 | - } |
|
109 | + } |
|
111 | 110 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: list_bullet_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,20 +46,20 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class List_Bullet_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function reflow() { |
|
53 | + function reflow() { |
|
55 | 54 | $style = $this->_frame->get_style(); |
56 | 55 | |
57 | 56 | $style->width = $this->_frame->get_width(); |
58 | 57 | $this->_frame->position(); |
59 | 58 | |
60 | 59 | if ( $style->list_style_position === "inside" ) { |
61 | - $p = $this->_frame->find_block_parent(); |
|
62 | - $p->add_frame_to_line($this->_frame); |
|
60 | + $p = $this->_frame->find_block_parent(); |
|
61 | + $p->add_frame_to_line($this->_frame); |
|
63 | 62 | } |
64 | 63 | |
65 | - } |
|
64 | + } |
|
66 | 65 | } |