Fix #8052 - fixing pdf
[pear] / XML / SvgToPdfAlt / Rect.php
1 <?php
2
3 /* output a rectangle
4
5 */
6
7 class XML_SvgToPDFAlt_Rect  extends XML_SvgToPDFAlt_Base {
8     function writePDF($pdf,$data) {
9         $x =  $this->x   + @$this->xx;
10         $y =  $this->y  + @$this->yy;
11         
12         
13         
14         $pdf->setLineWidth($this->style['stroke-width']); 
15         $f = $this->toColor($this->style['fill']);
16         if ($f) {
17             $pdf->setFillColor($f[0],$f[1],$f[2]);
18         }
19         
20         $l = $this->toColor(@$this->style['stroke']);
21         if ($l) {
22             $pdf->setDrawColor($l[0],$l[1],$l[2]);
23         }
24         // no fill, no line = dont draw...
25         if (!$l && !$f) {
26             return;
27         }
28         XML_SvgToPDFAlt::debug("RECT:" .($x/ 3.543307).',' .($y/ 3.543307). ','
29              .($this->width/ 3.543307).',' . ($this->height/ 3.543307));
30         $pdf->rect($x/ 3.543307,$y/ 3.543307,
31             $this->width/ 3.543307,$this->height/ 3.543307,($l ? 'D' : ''). ($f ? 'F' : ''));
32     
33     
34     
35     }
36
37
38     function toColor($color) {
39         if (!$color || ($color == 'none')) {
40             return false;
41         }
42         return array(
43             hexdec(substr($color,1,2)),
44             hexdec(substr($color,3,2)),
45             hexdec(substr($color,5,2)));
46         
47     }
48
49
50 }