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