Passed
Push — 1.10.x ( aae6b1...e5a590 )
by Yannick
131:05 queued 81:36
created
main/inc/lib/phpdocx/pdf/include/image_frame_reflower.cls.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
  */
55 55
 class Image_Frame_Reflower extends Frame_Reflower {
56 56
 
57
-  function __construct(Image_Frame_Decorator $frame) {
57
+    function __construct(Image_Frame_Decorator $frame) {
58 58
     parent::__construct($frame);
59
-  }
59
+    }
60 60
 
61
-  function reflow() {
61
+    function reflow() {
62 62
     
63 63
     // Set the frame's width
64 64
     $this->get_min_max_width();
65 65
     
66
-  }
66
+    }
67 67
 
68
-  function get_min_max_width() {
68
+    function get_min_max_width() {
69 69
 
70 70
     if (DEBUGPNG) {
71
-      // Determine the image's size. Time consuming. Only when really needed?
72
-      list($img_width, $img_height) = getimagesize($this->_frame->get_image_url());
73
-      print "get_min_max_width() ".
71
+        // Determine the image's size. Time consuming. Only when really needed?
72
+        list($img_width, $img_height) = getimagesize($this->_frame->get_image_url());
73
+        print "get_min_max_width() ".
74 74
         $this->_frame->get_style()->width.' '.
75 75
         $this->_frame->get_style()->height.';'.
76 76
         $this->_frame->get_parent()->get_style()->width." ".
@@ -93,55 +93,55 @@  discard block
 block discarded – undo
93 93
 
94 94
     $width = ($style->width > 0 ? $style->width : ($stylep->width > 0 ? $stylep->width : 0));
95 95
     if ( is_percent($width) ) {
96
-      $t = 0.0;
97
-      for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) {
96
+        $t = 0.0;
97
+        for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) {
98 98
         $t = (float)($f->get_style()->width); //always in pt
99 99
         if ((float)$t != 0) {
100
-        	break;
100
+            break;
101
+        }
101 102
         }
102
-      }
103
-      $width = ((float)rtrim($width,"%") * $t)/100; //maybe 0
103
+        $width = ((float)rtrim($width,"%") * $t)/100; //maybe 0
104 104
     } else {
105
-      // Don't set image original size if "%" branch was 0 or size not given.
106
-      // Otherwise aspect changed on %/auto combination for width/height
107
-      // Resample according to px per inch
108
-      // See also List_Bullet_Image_Frame_Decorator::__construct
109
-      $width = (float)($width * 72) / DOMPDF_DPI;
105
+        // Don't set image original size if "%" branch was 0 or size not given.
106
+        // Otherwise aspect changed on %/auto combination for width/height
107
+        // Resample according to px per inch
108
+        // See also List_Bullet_Image_Frame_Decorator::__construct
109
+        $width = (float)($width * 72) / DOMPDF_DPI;
110 110
     }
111 111
 
112 112
     $height = ($style->height > 0 ? $style->height : ($stylep->height > 0 ? $stylep->height : 0));
113 113
     if ( is_percent($height) ) {
114
-      $t = 0.0;
115
-      for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) {
114
+        $t = 0.0;
115
+        for ($f = $this->_frame->get_parent(); $f; $f = $f->get_parent()) {
116 116
         $t = (float)($f->get_style()->height); //always in pt
117 117
         if ((float)$t != 0) {
118
-        	break;
118
+            break;
119 119
         }
120
-      }
121
-      $height = ((float)rtrim($height,"%") * $t)/100; //maybe 0
120
+        }
121
+        $height = ((float)rtrim($height,"%") * $t)/100; //maybe 0
122 122
     } else {
123
-      // Don't set image original size if "%" branch was 0 or size not given.
124
-      // Otherwise aspect changed on %/auto combination for width/height
125
-      // Resample according to px per inch
126
-      // See also List_Bullet_Image_Frame_Decorator::__construct
127
-      $height = (float)($height * 72) / DOMPDF_DPI;
123
+        // Don't set image original size if "%" branch was 0 or size not given.
124
+        // Otherwise aspect changed on %/auto combination for width/height
125
+        // Resample according to px per inch
126
+        // See also List_Bullet_Image_Frame_Decorator::__construct
127
+        $height = (float)($height * 72) / DOMPDF_DPI;
128 128
     }
129 129
 
130 130
     if ($width == 0 || $height == 0) {
131
-      // Determine the image's size. Time consuming. Only when really needed!
132
-      list($img_width, $img_height) = getimagesize($this->_frame->get_image_url());
133
-      // don't treat 0 as error. Can be downscaled or can be catched elsewhere if image not readable.
134
-      // Resample according to px per inch
135
-      // See also List_Bullet_Image_Frame_Decorator::__construct
131
+        // Determine the image's size. Time consuming. Only when really needed!
132
+        list($img_width, $img_height) = getimagesize($this->_frame->get_image_url());
133
+        // don't treat 0 as error. Can be downscaled or can be catched elsewhere if image not readable.
134
+        // Resample according to px per inch
135
+        // See also List_Bullet_Image_Frame_Decorator::__construct
136 136
       
137
-      if ($width == 0 && $height == 0) {
137
+        if ($width == 0 && $height == 0) {
138 138
         $width = (float)($img_width * 72) / DOMPDF_DPI;
139 139
         $height = (float)($img_height * 72) / DOMPDF_DPI;
140
-      } elseif ($height == 0 && $width != 0) {
140
+        } elseif ($height == 0 && $width != 0) {
141 141
         $height = ($width / $img_width) * $img_height; //keep aspect ratio
142
-      } elseif ($width == 0 && $height != 0) {
142
+        } elseif ($width == 0 && $height != 0) {
143 143
         $width = ($height / $img_height) * $img_width; //keep aspect ratio
144
-      }
144
+        }
145 145
     }
146 146
 
147 147
     if (DEBUGPNG) print $width.' '.$height.';';
@@ -173,5 +173,5 @@  discard block
 block discarded – undo
173 173
 
174 174
     return array( $width, $width, "min" => $width, "max" => $width);
175 175
     
176
-  }
176
+    }
177 177
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/canvas_factory.cls.php 1 patch
Indentation   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: canvas_factory.cls.php,v $
6
- * Created on: 2004-06-02
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: canvas_factory.cls.php,v $
6
+     * Created on: 2004-06-02
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: canvas_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -49,35 +48,35 @@  discard block
 block discarded – undo
49 48
  */
50 49
 class Canvas_Factory {
51 50
 
52
-  /**
53
-   * Constructor is private: this is a static class
54
-   */
55
-  private function __construct() { }
51
+    /**
52
+     * Constructor is private: this is a static class
53
+     */
54
+    private function __construct() { }
56 55
 
57
-  static function get_instance($paper = null, $orientation = null,  $class = null) {
56
+    static function get_instance($paper = null, $orientation = null,  $class = null) {
58 57
 
59 58
     $backend = strtolower(DOMPDF_PDF_BACKEND);
60 59
     
61 60
     if ( isset($class) && class_exists($class, false) )
62
-      $class .= "_Adapter";
61
+        $class .= "_Adapter";
63 62
     
64 63
     else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
65 64
               class_exists("PDFLib", false) )
66
-      $class = "PDFLib_Adapter";
65
+        $class = "PDFLib_Adapter";
67 66
 
68 67
     else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") )
69
-      $class = "CPDF_Adapter";
68
+        $class = "CPDF_Adapter";
70 69
 
71 70
     else if ( ( $backend === "tcpdf") )
72
-      $class = "TCPDF_Adapter";
71
+        $class = "TCPDF_Adapter";
73 72
       
74 73
     else if ( $backend === "gd" )
75
-      $class = "GD_Adapter";
74
+        $class = "GD_Adapter";
76 75
     
77 76
     else
78
-      $class = "CPDF_Adapter";
77
+        $class = "CPDF_Adapter";
79 78
 
80 79
     return new $class($paper, $orientation);
81 80
         
82
-  }
81
+    }
83 82
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/page_frame_reflower.cls.php 1 patch
Indentation   +93 added lines, -94 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: page_frame_reflower.cls.php,v $
6
- * Created on: 2004-06-16
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: page_frame_reflower.cls.php,v $
6
+     * Created on: 2004-06-16
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: page_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -47,25 +46,25 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Page_Frame_Reflower extends Frame_Reflower {
49 48
 
50
-  /**
51
-   * Cache of the callbacks array
52
-   * 
53
-   * @var array
54
-   */
55
-  private $_callbacks;
49
+    /**
50
+     * Cache of the callbacks array
51
+     * 
52
+     * @var array
53
+     */
54
+    private $_callbacks;
56 55
   
57
-  /**
58
-   * Cache of the canvas
59
-   *
60
-   * @var Canvas
61
-   */
62
-  private $_canvas;
56
+    /**
57
+     * Cache of the canvas
58
+     *
59
+     * @var Canvas
60
+     */
61
+    private $_canvas;
63 62
 
64
-  function __construct(Page_Frame_Decorator $frame) { parent::__construct($frame); }
63
+    function __construct(Page_Frame_Decorator $frame) { parent::__construct($frame); }
65 64
   
66
-  //........................................................................
65
+    //........................................................................
67 66
 
68
-  function reflow() {
67
+    function reflow() {
69 68
     $style = $this->_frame->get_style();
70 69
     
71 70
     // Paged layout:
@@ -88,74 +87,74 @@  discard block
 block discarded – undo
88 87
 
89 88
     while ($child) {
90 89
 
91
-      $child->set_containing_block($content_x, $content_y, $content_width, $content_height);
90
+        $child->set_containing_block($content_x, $content_y, $content_width, $content_height);
92 91
       
93
-      // Check for begin reflow callback
94
-      $this->_check_callbacks("begin_page_reflow", $child);
92
+        // Check for begin reflow callback
93
+        $this->_check_callbacks("begin_page_reflow", $child);
95 94
       
96
-      $child->reflow();
97
-      $next_child = $child->get_next_sibling();
95
+        $child->reflow();
96
+        $next_child = $child->get_next_sibling();
98 97
       
99
-      // Check for begin render callback
100
-      $this->_check_callbacks("begin_page_render", $child);
98
+        // Check for begin render callback
99
+        $this->_check_callbacks("begin_page_render", $child);
101 100
       
102
-      // Render the page
103
-      $this->_frame->get_renderer()->render($child);
101
+        // Render the page
102
+        $this->_frame->get_renderer()->render($child);
104 103
       
105
-      // Check for end render callback
106
-      $this->_check_callbacks("end_page_render", $child);
104
+        // Check for end render callback
105
+        $this->_check_callbacks("end_page_render", $child);
107 106
       
108
-      if ( $next_child )
109
-      {
107
+        if ( $next_child )
108
+        {
110 109
         $this->_frame->next_page();
111
-      }
110
+        }
112 111
 
113
-      // Wait to dispose of all frames on the previous page
114
-      // so callback will have access to them
115
-      if ( $prev_child )
116
-      {
112
+        // Wait to dispose of all frames on the previous page
113
+        // so callback will have access to them
114
+        if ( $prev_child )
115
+        {
117 116
         $prev_child->dispose(true);
118
-      }
119
-      $prev_child = $child;
120
-      $child = $next_child;
117
+        }
118
+        $prev_child = $child;
119
+        $child = $next_child;
121 120
     }
122 121
 
123 122
     // Dispose of previous page if it still exists
124 123
     if ( $prev_child )
125 124
     {
126
-      $prev_child->dispose(true);
125
+        $prev_child->dispose(true);
127 126
     }
128
-  }  
127
+    }  
129 128
   
130
-  //........................................................................
129
+    //........................................................................
131 130
   
132
-  /**
133
-   * Check for callbacks that need to be performed when a given event
134
-   * gets triggered on a page
135
-   *
136
-   * @param string $event the type of event
137
-   * @param Frame $frame the frame that event is triggered on
138
-   */
139
-  protected function _check_callbacks($event, $frame) {
131
+    /**
132
+     * Check for callbacks that need to be performed when a given event
133
+     * gets triggered on a page
134
+     *
135
+     * @param string $event the type of event
136
+     * @param Frame $frame the frame that event is triggered on
137
+     */
138
+    protected function _check_callbacks($event, $frame) {
140 139
     if (!isset($this->_callbacks)) {
141
-      $dompdf = $this->_frame->get_dompdf();
142
-      $this->_callbacks = $dompdf->get_callbacks();
143
-      $this->_canvas = $dompdf->get_canvas();
140
+        $dompdf = $this->_frame->get_dompdf();
141
+        $this->_callbacks = $dompdf->get_callbacks();
142
+        $this->_canvas = $dompdf->get_canvas();
144 143
     }
145 144
     
146 145
     if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) {
147
-      $info = array(0 => $this->_canvas, "canvas" => $this->_canvas,
146
+        $info = array(0 => $this->_canvas, "canvas" => $this->_canvas,
148 147
                     1 => $frame, "frame" => $frame);
149
-      $fs = $this->_callbacks[$event];
150
-      foreach ($fs as $f) {
148
+        $fs = $this->_callbacks[$event];
149
+        foreach ($fs as $f) {
151 150
         if (is_callable($f)) {
152
-          if (is_array($f)) {
151
+            if (is_array($f)) {
153 152
             $f[0]->$f[1]($info);
154
-          } else {
153
+            } else {
155 154
             $f($info);
156
-          }
155
+            }
156
+        }
157 157
         }
158
-      }
159 158
     }
160
-  }  
159
+    }  
161 160
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/javascript_embedder.cls.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@
 block discarded – undo
47 47
  */
48 48
 class Javascript_Embedder {
49 49
   
50
-  /**
51
-   * @var DOMPDF
52
-   */
53
-  protected $_dompdf;
50
+    /**
51
+     * @var DOMPDF
52
+     */
53
+    protected $_dompdf;
54 54
 
55
-  function __construct(DOMPDF $dompdf) {
55
+    function __construct(DOMPDF $dompdf) {
56 56
     $this->_dompdf = $dompdf;
57
-  }
57
+    }
58 58
 
59
-  function insert($code) {
59
+    function insert($code) {
60 60
     $this->_dompdf->get_canvas()->javascript($code);
61
-  }
61
+    }
62 62
 
63
-  function render($frame) {
63
+    function render($frame) {
64 64
     $this->insert($frame->get_node()->nodeValue);
65
-  }
65
+    }
66 66
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/inline_renderer.cls.php 1 patch
Indentation   +68 added lines, -69 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: inline_renderer.cls.php,v $
6
- * Created on: 2004-06-30
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: inline_renderer.cls.php,v $
6
+     * Created on: 2004-06-30
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: inline_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -47,13 +46,13 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Inline_Renderer extends Abstract_Renderer {
49 48
   
50
-  //........................................................................
49
+    //........................................................................
51 50
 
52
-  function render(Frame $frame) {
51
+    function render(Frame $frame) {
53 52
     $style = $frame->get_style();
54 53
 
55 54
     if ( !$frame->get_first_child() )
56
-      return; // No children, no service
55
+        return; // No children, no service
57 56
     
58 57
     // Draw the left border if applicable
59 58
     $bp = $style->get_border_properties();
@@ -73,10 +72,10 @@  discard block
 block discarded – undo
73 72
     $first_row = true;
74 73
 
75 74
     foreach ($frame->get_children() as $child) {
76
-      list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box();
77
-      $child_h += $widths[2];
75
+        list($child_x, $child_y, $child_w, $child_h) = $child->get_padding_box();
76
+        $child_h += $widths[2];
78 77
       
79
-      if ( !is_null($w) && $child_x < $x + $w ) {
78
+        if ( !is_null($w) && $child_x < $x + $w ) {
80 79
         //This branch seems to be supposed to being called on the first part
81 80
         //of an inline html element, and the part after the if clause for the
82 81
         //parts after a line break.
@@ -88,37 +87,37 @@  discard block
 block discarded – undo
88 87
 
89 88
         // Background:
90 89
         if ( ($bg = $style->background_color) !== "transparent" )
91
-          $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color);
90
+            $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color);
92 91
 
93 92
         if ( ($url = $style->background_image) && $url !== "none" ) {
94
-          $this->_background_image($url, $x, $y, $w, $h, $style);
93
+            $this->_background_image($url, $x, $y, $w, $h, $style);
95 94
         }
96 95
 
97 96
         // If this is the first row, draw the left border
98 97
         if ( $first_row ) {
99 98
 
100
-          if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) {
99
+            if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) {
101 100
             $method = "_border_" . $bp["left"]["style"];            
102 101
             $this->$method($x, $y, $h + $widths[0] + $widths[2], $bp["left"]["color"], $widths, "left");
103
-          }
104
-          $first_row = false;
102
+            }
103
+            $first_row = false;
105 104
         }
106 105
 
107 106
         // Draw the top & bottom borders
108 107
         if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) {
109
-          $method = "_border_" . $bp["top"]["style"];
110
-          $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top");
108
+            $method = "_border_" . $bp["top"]["style"];
109
+            $this->$method($x, $y, $w + $widths[1] + $widths[3], $bp["top"]["color"], $widths, "top");
111 110
         }
112 111
         
113 112
         if ( $bp["bottom"]["style"] !== "none" && $bp["bottom"]["width"] > 0 ) {
114
-          $method = "_border_" . $bp["bottom"]["style"];
115
-          $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom");
113
+            $method = "_border_" . $bp["bottom"]["style"];
114
+            $this->$method($x, $y + $h + $widths[0] + $widths[2], $w + $widths[1] + $widths[3], $bp["bottom"]["color"], $widths, "bottom");
116 115
         }
117 116
 
118 117
         // Handle anchors & links
119 118
         if ( $frame->get_node()->nodeName === "a" ) {
120 119
                     
121
-          if ( $href = $frame->get_node()->getAttribute("href") )
120
+            if ( $href = $frame->get_node()->getAttribute("href") )
122 121
             $this->_canvas->add_link($href, $x, $y, $w, $h);
123 122
 
124 123
         }
@@ -128,20 +127,20 @@  discard block
 block discarded – undo
128 127
         $w = $child_w;
129 128
         $h = $child_h;
130 129
         continue;
131
-      }
130
+        }
132 131
 
133
-      if ( is_null($w) )
132
+        if ( is_null($w) )
134 133
         $w = $child_w;
135
-      else
134
+        else
136 135
         $w += $child_w;
137 136
       
138
-      $h = max($h, $child_h);
137
+        $h = max($h, $child_h);
139 138
     }
140 139
 
141 140
     
142 141
     // Handle the last child
143 142
     if ( ($bg = $style->background_color) !== "transparent" ) 
144
-      $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color);
143
+        $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color);
145 144
 
146 145
     //On continuation lines (after line break) of inline elements, the style got copied.
147 146
     //But a non repeatable background image should not be repeated on the next line.
@@ -152,7 +151,7 @@  discard block
 block discarded – undo
152 151
     // ... && (!($repeat = $style->background_repeat) || $repeat === "repeat" ...
153 152
     //different position? $this->_background_image($url, $x, $y, $w, $h, $style);
154 153
     if ( ($url = $style->background_image) && $url !== "none" )           
155
-      $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style);
154
+        $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style);
156 155
         
157 156
     // Add the border widths
158 157
     $w += $widths[1] + $widths[3];
@@ -164,37 +163,37 @@  discard block
 block discarded – undo
164 163
 
165 164
     // If this is the first row, draw the left border too
166 165
     if ( $first_row && $bp["left"]["style"] !== "none" && $widths[3] > 0 ) {
167
-      $method = "_border_" . $bp["left"]["style"];
168
-      $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left");
166
+        $method = "_border_" . $bp["left"]["style"];
167
+        $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left");
169 168
     }
170 169
     
171 170
     // Draw the top & bottom borders
172 171
     if ( $bp["top"]["style"] !== "none" && $widths[0] > 0 ) {
173
-      $method = "_border_" . $bp["top"]["style"];
174
-      $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top");
172
+        $method = "_border_" . $bp["top"]["style"];
173
+        $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top");
175 174
     }
176 175
     
177 176
     if ( $bp["bottom"]["style"] !== "none" && $widths[2] > 0 ) {
178
-      $method = "_border_" . $bp["bottom"]["style"];
179
-      $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom");
177
+        $method = "_border_" . $bp["bottom"]["style"];
178
+        $this->$method($x, $y + $h, $w, $bp["bottom"]["color"], $widths, "bottom");
180 179
     }
181 180
 
182 181
     //    pre_var_dump(get_class($frame->get_next_sibling()));
183 182
     //    $last_row = get_class($frame->get_next_sibling()) !== 'Inline_Frame_Decorator';
184 183
     // Draw the right border if this is the last row
185 184
     if ( $bp["right"]["style"] !== "none" && $widths[1] > 0 ) {
186
-      $method = "_border_" . $bp["right"]["style"];
187
-      $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right");
185
+        $method = "_border_" . $bp["right"]["style"];
186
+        $this->$method($x + $w, $y, $h, $bp["right"]["color"], $widths, "right");
188 187
     }
189 188
 
190 189
     // Handle anchors & links
191 190
     if ( $frame->get_node()->nodeName === "a" ) {
192 191
 
193
-      if ( $name = $frame->get_node()->getAttribute("name") )
192
+        if ( $name = $frame->get_node()->getAttribute("name") )
194 193
         $this->_canvas->add_named_dest($name);
195 194
 
196
-      if ( $href = $frame->get_node()->getAttribute("href") )
195
+        if ( $href = $frame->get_node()->getAttribute("href") )
197 196
         $this->_canvas->add_link($href, $x, $y, $w, $h);
198 197
     }
199
-  }
198
+    }
200 199
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/list_bullet_image_frame_decorator.cls.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -52,34 +52,34 @@  discard block
 block discarded – undo
52 52
  */
53 53
 class List_Bullet_Image_Frame_Decorator extends Frame_Decorator {
54 54
 
55
-  /**
56
-   * The underlying image frame
57
-   * 
58
-   * @var Image_Frame_Decorator
59
-   */
60
-  protected $_img;
55
+    /**
56
+     * The underlying image frame
57
+     * 
58
+     * @var Image_Frame_Decorator
59
+     */
60
+    protected $_img;
61 61
 
62
-  /**
63
-   * The image's width in pixels
64
-   *
65
-   * @var int
66
-   */
67
-  protected $_width;
62
+    /**
63
+     * The image's width in pixels
64
+     *
65
+     * @var int
66
+     */
67
+    protected $_width;
68 68
   
69
-  /**
70
-   * The image's height in pixels
71
-   *
72
-   * @var int
73
-   */
74
-  protected $_height;
69
+    /**
70
+     * The image's height in pixels
71
+     *
72
+     * @var int
73
+     */
74
+    protected $_height;
75 75
 
76
-  /**
77
-   * Class constructor
78
-   *
79
-   * @param Frame $frame the bullet frame to decorate
80
-   * @param DOMPDF $dompdf the document's dompdf object
81
-   */
82
-  function __construct(Frame $frame, DOMPDF $dompdf) {
76
+    /**
77
+     * Class constructor
78
+     *
79
+     * @param Frame $frame the bullet frame to decorate
80
+     * @param DOMPDF $dompdf the document's dompdf object
81
+     */
82
+    function __construct(Frame $frame, DOMPDF $dompdf) {
83 83
     $style = $frame->get_style();
84 84
     $url = $style->list_style_image;
85 85
     $frame->get_node()->setAttribute("src", $url);
@@ -104,38 +104,38 @@  discard block
 block discarded – undo
104 104
     //  $style->min_height = $this->_height;
105 105
     //}
106 106
     //$style->height = "auto";   
107
-  }
107
+    }
108 108
 
109
-  /**
110
-   * Return the bullet's width
111
-   *
112
-   * @return int
113
-   */
114
-  function get_width() {
109
+    /**
110
+     * Return the bullet's width
111
+     *
112
+     * @return int
113
+     */
114
+    function get_width() {
115 115
     //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator
116 116
     //for proper alignment of bullet image and text. Allow image to not fitting on left border.
117 117
     //This controls the distance between bullet image and text 
118 118
     //return $this->_width;
119 119
     return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + 
120 120
       2 * List_Bullet_Frame_Decorator::BULLET_PADDING;
121
-  }
121
+    }
122 122
 
123
-  /**
124
-   * Return the bullet's height
125
-   *
126
-   * @return int
127
-   */
128
-  function get_height() {
123
+    /**
124
+     * Return the bullet's height
125
+     *
126
+     * @return int
127
+     */
128
+    function get_height() {
129 129
     //based on image height
130 130
     return $this->_height;
131
-  }
131
+    }
132 132
   
133
-  /**
134
-   * Override get_margin_width
135
-   *
136
-   * @return int
137
-   */
138
-  function get_margin_width() {
133
+    /**
134
+     * Override get_margin_width
135
+     *
136
+     * @return int
137
+     */
138
+    function get_margin_width() {
139 139
     //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator
140 140
     //for proper alignment of bullet image and text. Allow image to not fitting on left border.
141 141
     //This controls the extra indentation of text to make room for the bullet image.
@@ -147,42 +147,42 @@  discard block
 block discarded – undo
147 147
     // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. 
148 148
     if ( $this->_frame->get_style()->list_style_position === "outside" ||
149 149
          $this->_width == 0) 
150
-      return 0;
150
+        return 0;
151 151
     //This aligns the "inside" image position with the text.
152 152
     //The text starts to the right of the image.
153 153
     //Between the image and the text there is an added margin of image width.
154 154
     //Where this comes from is unknown.
155 155
     //The corresponding List_Bullet_Frame_Decorator sets a smaller margin. bullet size?
156 156
     return $this->_width + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING;
157
-  }
157
+    }
158 158
 
159
-  /**
160
-   * Override get_margin_height()
161
-   *
162
-   * @return int
163
-   */
164
-  function get_margin_height() {
159
+    /**
160
+     * Override get_margin_height()
161
+     *
162
+     * @return int
163
+     */
164
+    function get_margin_height() {
165 165
     //Hits only on "inset" lists items, to increase height of box
166 166
     //based on image height
167 167
     return $this->_height + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING;
168
-  }
168
+    }
169 169
 
170
-  /**
171
-   * Return image url
172
-   *
173
-   * @return string
174
-   */
175
-  function get_image_url() {
170
+    /**
171
+     * Return image url
172
+     *
173
+     * @return string
174
+     */
175
+    function get_image_url() {
176 176
     return $this->_img->get_image_url();
177
-  }
177
+    }
178 178
 
179
-  /**
180
-   * Return the image extension
181
-   *
182
-   * @return string
183
-   */
184
-  function get_image_ext() {
179
+    /**
180
+     * Return the image extension
181
+     *
182
+     * @return string
183
+     */
184
+    function get_image_ext() {
185 185
     return $this->_img->get_image_ext();
186
-  }
186
+    }
187 187
   
188 188
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/cpdf_adapter.cls.php 1 patch
Indentation   +524 added lines, -524 removed lines patch added patch discarded remove patch
@@ -74,144 +74,144 @@  discard block
 block discarded – undo
74 74
  */
75 75
 class CPDF_Adapter implements Canvas {
76 76
 
77
-  /**
78
-   * Dimensions of paper sizes in points
79
-   *
80
-   * @var array;
81
-   */
82
-  static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79),
83
-                              "2a0" => array(0,0,3370.39,4767.87),
84
-                              "a0" => array(0,0,2383.94,3370.39),
85
-                              "a1" => array(0,0,1683.78,2383.94),
86
-                              "a2" => array(0,0,1190.55,1683.78),
87
-                              "a3" => array(0,0,841.89,1190.55),
88
-                              "a4" => array(0,0,595.28,841.89),
89
-                              "a5" => array(0,0,419.53,595.28),
90
-                              "a6" => array(0,0,297.64,419.53),
91
-                              "a7" => array(0,0,209.76,297.64),
92
-                              "a8" => array(0,0,147.40,209.76),
93
-                              "a9" => array(0,0,104.88,147.40),
94
-                              "a10" => array(0,0,73.70,104.88),
95
-                              "b0" => array(0,0,2834.65,4008.19),
96
-                              "b1" => array(0,0,2004.09,2834.65),
97
-                              "b2" => array(0,0,1417.32,2004.09),
98
-                              "b3" => array(0,0,1000.63,1417.32),
99
-                              "b4" => array(0,0,708.66,1000.63),
100
-                              "b5" => array(0,0,498.90,708.66),
101
-                              "b6" => array(0,0,354.33,498.90),
102
-                              "b7" => array(0,0,249.45,354.33),
103
-                              "b8" => array(0,0,175.75,249.45),
104
-                              "b9" => array(0,0,124.72,175.75),
105
-                              "b10" => array(0,0,87.87,124.72),
106
-                              "c0" => array(0,0,2599.37,3676.54),
107
-                              "c1" => array(0,0,1836.85,2599.37),
108
-                              "c2" => array(0,0,1298.27,1836.85),
109
-                              "c3" => array(0,0,918.43,1298.27),
110
-                              "c4" => array(0,0,649.13,918.43),
111
-                              "c5" => array(0,0,459.21,649.13),
112
-                              "c6" => array(0,0,323.15,459.21),
113
-                              "c7" => array(0,0,229.61,323.15),
114
-                              "c8" => array(0,0,161.57,229.61),
115
-                              "c9" => array(0,0,113.39,161.57),
116
-                              "c10" => array(0,0,79.37,113.39),
117
-                              "ra0" => array(0,0,2437.80,3458.27),
118
-                              "ra1" => array(0,0,1729.13,2437.80),
119
-                              "ra2" => array(0,0,1218.90,1729.13),
120
-                              "ra3" => array(0,0,864.57,1218.90),
121
-                              "ra4" => array(0,0,609.45,864.57),
122
-                              "sra0" => array(0,0,2551.18,3628.35),
123
-                              "sra1" => array(0,0,1814.17,2551.18),
124
-                              "sra2" => array(0,0,1275.59,1814.17),
125
-                              "sra3" => array(0,0,907.09,1275.59),
126
-                              "sra4" => array(0,0,637.80,907.09),
127
-                              "letter" => array(0,0,612.00,792.00),
128
-                              "legal" => array(0,0,612.00,1008.00),
129
-                              "ledger" => array(0,0,1224.00, 792.00),
130
-                              "tabloid" => array(0,0,792.00, 1224.00),
131
-                              "executive" => array(0,0,521.86,756.00),
132
-                              "folio" => array(0,0,612.00,936.00),
133
-                              "commerical #10 envelope" => array(0,0,684,297),
134
-                              "catalog #10 1/2 envelope" => array(0,0,648,864),
135
-                              "8.5x11" => array(0,0,612.00,792.00),
136
-                              "8.5x14" => array(0,0,612.00,1008.0),
137
-                              "11x17"  => array(0,0,792.00, 1224.00));
138
-
139
-
140
-  /**
141
-   * Instance of Cpdf class
142
-   *
143
-   * @var Cpdf
144
-   */
145
-  private $_pdf;
146
-
147
-  /**
148
-   * PDF width, in points
149
-   *
150
-   * @var float
151
-   */
152
-  private $_width;
153
-
154
-  /**
155
-   * PDF height, in points
156
-   *
157
-   * @var float;
158
-   */
159
-  private $_height;
160
-
161
-  /**
162
-   * Current page number
163
-   *
164
-   * @var int
165
-   */
166
-  private $_page_number;
167
-
168
-  /**
169
-   * Total number of pages
170
-   *
171
-   * @var int
172
-   */
173
-  private $_page_count;
174
-
175
-  /**
176
-   * Text to display on every page
177
-   *
178
-   * @var array
179
-   */
180
-  private $_page_text;
181
-
182
-  /**
183
-   * Array of pages for accesing after rendering is initially complete
184
-   *
185
-   * @var array
186
-   */
187
-  private $_pages;
188
-
189
-  /**
190
-   * Array of temporary cached images to be deleted when processing is complete
191
-   *
192
-   * @var array
193
-   */
194
-  private $_image_cache;
77
+    /**
78
+     * Dimensions of paper sizes in points
79
+     *
80
+     * @var array;
81
+     */
82
+    static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79),
83
+                                "2a0" => array(0,0,3370.39,4767.87),
84
+                                "a0" => array(0,0,2383.94,3370.39),
85
+                                "a1" => array(0,0,1683.78,2383.94),
86
+                                "a2" => array(0,0,1190.55,1683.78),
87
+                                "a3" => array(0,0,841.89,1190.55),
88
+                                "a4" => array(0,0,595.28,841.89),
89
+                                "a5" => array(0,0,419.53,595.28),
90
+                                "a6" => array(0,0,297.64,419.53),
91
+                                "a7" => array(0,0,209.76,297.64),
92
+                                "a8" => array(0,0,147.40,209.76),
93
+                                "a9" => array(0,0,104.88,147.40),
94
+                                "a10" => array(0,0,73.70,104.88),
95
+                                "b0" => array(0,0,2834.65,4008.19),
96
+                                "b1" => array(0,0,2004.09,2834.65),
97
+                                "b2" => array(0,0,1417.32,2004.09),
98
+                                "b3" => array(0,0,1000.63,1417.32),
99
+                                "b4" => array(0,0,708.66,1000.63),
100
+                                "b5" => array(0,0,498.90,708.66),
101
+                                "b6" => array(0,0,354.33,498.90),
102
+                                "b7" => array(0,0,249.45,354.33),
103
+                                "b8" => array(0,0,175.75,249.45),
104
+                                "b9" => array(0,0,124.72,175.75),
105
+                                "b10" => array(0,0,87.87,124.72),
106
+                                "c0" => array(0,0,2599.37,3676.54),
107
+                                "c1" => array(0,0,1836.85,2599.37),
108
+                                "c2" => array(0,0,1298.27,1836.85),
109
+                                "c3" => array(0,0,918.43,1298.27),
110
+                                "c4" => array(0,0,649.13,918.43),
111
+                                "c5" => array(0,0,459.21,649.13),
112
+                                "c6" => array(0,0,323.15,459.21),
113
+                                "c7" => array(0,0,229.61,323.15),
114
+                                "c8" => array(0,0,161.57,229.61),
115
+                                "c9" => array(0,0,113.39,161.57),
116
+                                "c10" => array(0,0,79.37,113.39),
117
+                                "ra0" => array(0,0,2437.80,3458.27),
118
+                                "ra1" => array(0,0,1729.13,2437.80),
119
+                                "ra2" => array(0,0,1218.90,1729.13),
120
+                                "ra3" => array(0,0,864.57,1218.90),
121
+                                "ra4" => array(0,0,609.45,864.57),
122
+                                "sra0" => array(0,0,2551.18,3628.35),
123
+                                "sra1" => array(0,0,1814.17,2551.18),
124
+                                "sra2" => array(0,0,1275.59,1814.17),
125
+                                "sra3" => array(0,0,907.09,1275.59),
126
+                                "sra4" => array(0,0,637.80,907.09),
127
+                                "letter" => array(0,0,612.00,792.00),
128
+                                "legal" => array(0,0,612.00,1008.00),
129
+                                "ledger" => array(0,0,1224.00, 792.00),
130
+                                "tabloid" => array(0,0,792.00, 1224.00),
131
+                                "executive" => array(0,0,521.86,756.00),
132
+                                "folio" => array(0,0,612.00,936.00),
133
+                                "commerical #10 envelope" => array(0,0,684,297),
134
+                                "catalog #10 1/2 envelope" => array(0,0,648,864),
135
+                                "8.5x11" => array(0,0,612.00,792.00),
136
+                                "8.5x14" => array(0,0,612.00,1008.0),
137
+                                "11x17"  => array(0,0,792.00, 1224.00));
138
+
139
+
140
+    /**
141
+     * Instance of Cpdf class
142
+     *
143
+     * @var Cpdf
144
+     */
145
+    private $_pdf;
146
+
147
+    /**
148
+     * PDF width, in points
149
+     *
150
+     * @var float
151
+     */
152
+    private $_width;
153
+
154
+    /**
155
+     * PDF height, in points
156
+     *
157
+     * @var float;
158
+     */
159
+    private $_height;
160
+
161
+    /**
162
+     * Current page number
163
+     *
164
+     * @var int
165
+     */
166
+    private $_page_number;
167
+
168
+    /**
169
+     * Total number of pages
170
+     *
171
+     * @var int
172
+     */
173
+    private $_page_count;
174
+
175
+    /**
176
+     * Text to display on every page
177
+     *
178
+     * @var array
179
+     */
180
+    private $_page_text;
181
+
182
+    /**
183
+     * Array of pages for accesing after rendering is initially complete
184
+     *
185
+     * @var array
186
+     */
187
+    private $_pages;
188
+
189
+    /**
190
+     * Array of temporary cached images to be deleted when processing is complete
191
+     *
192
+     * @var array
193
+     */
194
+    private $_image_cache;
195 195
   
196
-  /**
197
-   * Class constructor
198
-   *
199
-   * @param mixed  $paper  The size of paper to use in this PDF ({@link CPDF_Adapter::$PAPER_SIZES})
200
-   * @param string $orientation The orienation of the document (either 'landscape' or 'portrait')
201
-   */
202
-  function __construct($paper = "letter", $orientation = "portrait") {
196
+    /**
197
+     * Class constructor
198
+     *
199
+     * @param mixed  $paper  The size of paper to use in this PDF ({@link CPDF_Adapter::$PAPER_SIZES})
200
+     * @param string $orientation The orienation of the document (either 'landscape' or 'portrait')
201
+     */
202
+    function __construct($paper = "letter", $orientation = "portrait") {
203 203
 
204 204
     if ( is_array($paper) )
205
-      $size = $paper;
205
+        $size = $paper;
206 206
     else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
207
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
207
+        $size = self::$PAPER_SIZES[mb_strtolower($paper)];
208 208
     else
209
-      $size = self::$PAPER_SIZES["letter"];
209
+        $size = self::$PAPER_SIZES["letter"];
210 210
 
211 211
     if ( mb_strtolower($orientation) === "landscape" ) {
212
-      $a = $size[3];
213
-      $size[3] = $size[2];
214
-      $size[2] = $a;
212
+        $a = $size[3];
213
+        $size[3] = $size[2];
214
+        $size[2] = $a;
215 215
     }
216 216
     
217 217
     $this->_pdf = new Cpdf($size, DOMPDF_UNICODE_ENABLED, DOMPDF_FONT_CACHE, DOMPDF_TEMP_DIR);
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 
220 220
     // Silence pedantic warnings about missing TZ settings
221 221
     $time = substr_replace(date('YmdHisO'), '\'', (0 - 2), 0).'\'';
222
-	$this->_pdf->addInfo("CreationDate", "D:".$time);
223
-	$this->_pdf->addInfo("ModDate", "D:".$time);
222
+    $this->_pdf->addInfo("CreationDate", "D:".$time);
223
+    $this->_pdf->addInfo("ModDate", "D:".$time);
224 224
     
225 225
 
226 226
     $this->_width = $size[2] - $size[0];
@@ -233,253 +233,253 @@  discard block
 block discarded – undo
233 233
     $this->_pages = array($this->_pdf->getFirstPageId());
234 234
 
235 235
     $this->_image_cache = array();
236
-  }
237
-
238
-  /**
239
-   * Class destructor
240
-   *
241
-   * Deletes all temporary image files
242
-   */
243
-  function __destruct() {
236
+    }
237
+
238
+    /**
239
+     * Class destructor
240
+     *
241
+     * Deletes all temporary image files
242
+     */
243
+    function __destruct() {
244 244
     foreach ($this->_image_cache as $img) {
245
-      //debugpng
246
-      if (DEBUGPNG) print '[__destruct unlink '.$img.']';
247
-      if (!DEBUGKEEPTEMP)
245
+        //debugpng
246
+        if (DEBUGPNG) print '[__destruct unlink '.$img.']';
247
+        if (!DEBUGKEEPTEMP)
248 248
         unlink($img);
249 249
     }
250
-  }
250
+    }
251 251
   
252
-  /**
253
-   * Returns the Cpdf instance
254
-   *
255
-   * @return Cpdf
256
-   */
257
-  function get_cpdf() { return $this->_pdf; }
258
-
259
-  /**
260
-   * Add meta information to the PDF
261
-   *
262
-   * @param string $label  label of the value (Creator, Producter, etc.)
263
-   * @param string $value  the text to set
264
-   */
265
-  function add_info($label, $value) {
252
+    /**
253
+     * Returns the Cpdf instance
254
+     *
255
+     * @return Cpdf
256
+     */
257
+    function get_cpdf() { return $this->_pdf; }
258
+
259
+    /**
260
+     * Add meta information to the PDF
261
+     *
262
+     * @param string $label  label of the value (Creator, Producter, etc.)
263
+     * @param string $value  the text to set
264
+     */
265
+    function add_info($label, $value) {
266 266
     $this->_pdf->addInfo($label, $value);
267
-  }
268
-
269
-  /**
270
-   * Opens a new 'object'
271
-   *
272
-   * While an object is open, all drawing actions are recored in the object,
273
-   * as opposed to being drawn on the current page.  Objects can be added
274
-   * later to a specific page or to several pages.
275
-   *
276
-   * The return value is an integer ID for the new object.
277
-   *
278
-   * @see CPDF_Adapter::close_object()
279
-   * @see CPDF_Adapter::add_object()
280
-   *
281
-   * @return int
282
-   */
283
-  function open_object() {
267
+    }
268
+
269
+    /**
270
+     * Opens a new 'object'
271
+     *
272
+     * While an object is open, all drawing actions are recored in the object,
273
+     * as opposed to being drawn on the current page.  Objects can be added
274
+     * later to a specific page or to several pages.
275
+     *
276
+     * The return value is an integer ID for the new object.
277
+     *
278
+     * @see CPDF_Adapter::close_object()
279
+     * @see CPDF_Adapter::add_object()
280
+     *
281
+     * @return int
282
+     */
283
+    function open_object() {
284 284
     $ret = $this->_pdf->openObject();
285 285
     $this->_pdf->saveState();
286 286
     return $ret;
287
-  }
288
-
289
-  /**
290
-   * Reopens an existing 'object'
291
-   *
292
-   * @see CPDF_Adapter::open_object()
293
-   * @param int $object  the ID of a previously opened object
294
-   */
295
-  function reopen_object($object) {
287
+    }
288
+
289
+    /**
290
+     * Reopens an existing 'object'
291
+     *
292
+     * @see CPDF_Adapter::open_object()
293
+     * @param int $object  the ID of a previously opened object
294
+     */
295
+    function reopen_object($object) {
296 296
     $this->_pdf->reopenObject($object);
297 297
     $this->_pdf->saveState();
298
-  }
299
-
300
-  /**
301
-   * Closes the current 'object'
302
-   *
303
-   * @see CPDF_Adapter::open_object()
304
-   */
305
-  function close_object() {
298
+    }
299
+
300
+    /**
301
+     * Closes the current 'object'
302
+     *
303
+     * @see CPDF_Adapter::open_object()
304
+     */
305
+    function close_object() {
306 306
     $this->_pdf->restoreState();
307 307
     $this->_pdf->closeObject();
308
-  }
309
-
310
-  /**
311
-   * Adds a specified 'object' to the document
312
-   *
313
-   * $object int specifying an object created with {@link
314
-   * CPDF_Adapter::open_object()}.  $where can be one of:
315
-   * - 'add' add to current page only
316
-   * - 'all' add to every page from the current one onwards
317
-   * - 'odd' add to all odd numbered pages from now on
318
-   * - 'even' add to all even numbered pages from now on
319
-   * - 'next' add the object to the next page only
320
-   * - 'nextodd' add to all odd numbered pages from the next one
321
-   * - 'nexteven' add to all even numbered pages from the next one
322
-   *
323
-   * @see Cpdf::addObject()
324
-   *
325
-   * @param int $object
326
-   * @param string $where
327
-   */
328
-  function add_object($object, $where = 'all') {
308
+    }
309
+
310
+    /**
311
+     * Adds a specified 'object' to the document
312
+     *
313
+     * $object int specifying an object created with {@link
314
+     * CPDF_Adapter::open_object()}.  $where can be one of:
315
+     * - 'add' add to current page only
316
+     * - 'all' add to every page from the current one onwards
317
+     * - 'odd' add to all odd numbered pages from now on
318
+     * - 'even' add to all even numbered pages from now on
319
+     * - 'next' add the object to the next page only
320
+     * - 'nextodd' add to all odd numbered pages from the next one
321
+     * - 'nexteven' add to all even numbered pages from the next one
322
+     *
323
+     * @see Cpdf::addObject()
324
+     *
325
+     * @param int $object
326
+     * @param string $where
327
+     */
328
+    function add_object($object, $where = 'all') {
329 329
     $this->_pdf->addObject($object, $where);
330
-  }
331
-
332
-  /**
333
-   * Stops the specified 'object' from appearing in the document.
334
-   *
335
-   * The object will stop being displayed on the page following the current
336
-   * one.
337
-   *
338
-   * @param int $object
339
-   */
340
-  function stop_object($object) {
330
+    }
331
+
332
+    /**
333
+     * Stops the specified 'object' from appearing in the document.
334
+     *
335
+     * The object will stop being displayed on the page following the current
336
+     * one.
337
+     *
338
+     * @param int $object
339
+     */
340
+    function stop_object($object) {
341 341
     $this->_pdf->stopObject($object);
342
-  }
342
+    }
343 343
 
344
-  /**
345
-   * @access private
346
-   */
347
-  function serialize_object($id) {
344
+    /**
345
+     * @access private
346
+     */
347
+    function serialize_object($id) {
348 348
     // Serialize the pdf object's current state for retrieval later
349 349
     return $this->_pdf->serializeObject($id);
350
-  }
350
+    }
351 351
 
352
-  /**
353
-   * @access private
354
-   */
355
-  function reopen_serialized_object($obj) {
352
+    /**
353
+     * @access private
354
+     */
355
+    function reopen_serialized_object($obj) {
356 356
     return $this->_pdf->restoreSerializedObject($obj);
357
-  }
357
+    }
358 358
     
359
-  //........................................................................
360
-
361
-  /**
362
-   * Returns the PDF's width in points
363
-   * @return float
364
-   */
365
-  function get_width() { return $this->_width; }
366
-
367
-  /**
368
-   * Returns the PDF's height in points
369
-   * @return float
370
-   */
371
-  function get_height() { return $this->_height; }
372
-
373
-  /**
374
-   * Returns the current page number
375
-   * @return int
376
-   */
377
-  function get_page_number() { return $this->_page_number; }
378
-
379
-  /**
380
-   * Returns the total number of pages in the document
381
-   * @return int
382
-   */
383
-  function get_page_count() { return $this->_page_count; }
384
-
385
-  /**
386
-   * Sets the current page number
387
-   *
388
-   * @param int $num
389
-   */
390
-  function set_page_number($num) { $this->_page_number = $num; }
391
-
392
-  /**
393
-   * Sets the page count
394
-   *
395
-   * @param int $count
396
-   */
397
-  function set_page_count($count) {  $this->_page_count = $count; }
359
+    //........................................................................
360
+
361
+    /**
362
+     * Returns the PDF's width in points
363
+     * @return float
364
+     */
365
+    function get_width() { return $this->_width; }
366
+
367
+    /**
368
+     * Returns the PDF's height in points
369
+     * @return float
370
+     */
371
+    function get_height() { return $this->_height; }
372
+
373
+    /**
374
+     * Returns the current page number
375
+     * @return int
376
+     */
377
+    function get_page_number() { return $this->_page_number; }
378
+
379
+    /**
380
+     * Returns the total number of pages in the document
381
+     * @return int
382
+     */
383
+    function get_page_count() { return $this->_page_count; }
384
+
385
+    /**
386
+     * Sets the current page number
387
+     *
388
+     * @param int $num
389
+     */
390
+    function set_page_number($num) { $this->_page_number = $num; }
391
+
392
+    /**
393
+     * Sets the page count
394
+     *
395
+     * @param int $count
396
+     */
397
+    function set_page_count($count) {  $this->_page_count = $count; }
398 398
     
399
-  /**
400
-   * Sets the stroke colour
401
-   *
402
-   * See {@link Style::set_colour()} for the format of the color array.
403
-   * @param array $color
404
-   */
405
-  protected function _set_stroke_color($color) {
399
+    /**
400
+     * Sets the stroke colour
401
+     *
402
+     * See {@link Style::set_colour()} for the format of the color array.
403
+     * @param array $color
404
+     */
405
+    protected function _set_stroke_color($color) {
406 406
     list($r, $g, $b) = $color;
407 407
     $this->_pdf->setStrokeColor($r, $g, $b);
408
-  }
408
+    }
409 409
   
410
-  /**
411
-   * Sets the fill colour
412
-   *
413
-   * See {@link Style::set_colour()} for the format of the colour array.
414
-   * @param array $color
415
-   */
416
-  protected function _set_fill_color($color) {
410
+    /**
411
+     * Sets the fill colour
412
+     *
413
+     * See {@link Style::set_colour()} for the format of the colour array.
414
+     * @param array $color
415
+     */
416
+    protected function _set_fill_color($color) {
417 417
     list($r, $g, $b) = $color;
418 418
     $this->_pdf->setColor($r, $g, $b);
419
-  }
420
-
421
-  /**
422
-   * Sets line transparency
423
-   * @see Cpdf::setLineTransparency()
424
-   *
425
-   * Valid blend modes are (case-sensitive):
426
-   *
427
-   * Normal, Multiply, Screen, Overlay, Darken, Lighten,
428
-   * ColorDodge, ColorBurn, HardLight, SoftLight, Difference,
429
-   * Exclusion
430
-   *
431
-   * @param string $mode the blending mode to use
432
-   * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
433
-   */
434
-  protected function _set_line_transparency($mode, $opacity) {
419
+    }
420
+
421
+    /**
422
+     * Sets line transparency
423
+     * @see Cpdf::setLineTransparency()
424
+     *
425
+     * Valid blend modes are (case-sensitive):
426
+     *
427
+     * Normal, Multiply, Screen, Overlay, Darken, Lighten,
428
+     * ColorDodge, ColorBurn, HardLight, SoftLight, Difference,
429
+     * Exclusion
430
+     *
431
+     * @param string $mode the blending mode to use
432
+     * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
433
+     */
434
+    protected function _set_line_transparency($mode, $opacity) {
435 435
     $this->_pdf->setLineTransparency($mode, $opacity);
436
-  }
436
+    }
437 437
   
438
-  /**
439
-   * Sets fill transparency
440
-   * @see Cpdf::setFillTransparency()
441
-   *
442
-   * Valid blend modes are (case-sensitive):
443
-   *
444
-   * Normal, Multiply, Screen, Overlay, Darken, Lighten,
445
-   * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
446
-   * Exclusion
447
-   *
448
-   * @param string $mode the blending mode to use
449
-   * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
450
-   */
451
-  protected function _set_fill_transparency($mode, $opacity) {
438
+    /**
439
+     * Sets fill transparency
440
+     * @see Cpdf::setFillTransparency()
441
+     *
442
+     * Valid blend modes are (case-sensitive):
443
+     *
444
+     * Normal, Multiply, Screen, Overlay, Darken, Lighten,
445
+     * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
446
+     * Exclusion
447
+     *
448
+     * @param string $mode the blending mode to use
449
+     * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
450
+     */
451
+    protected function _set_fill_transparency($mode, $opacity) {
452 452
     $this->_pdf->setFillTransparency($mode, $opacity);
453
-  }
454
-
455
-  /**
456
-   * Sets the line style
457
-   *
458
-   * @see Cpdf::setLineStyle()
459
-   *
460
-   * @param float width
461
-   * @param string cap
462
-   * @param string join
463
-   * @param array dash
464
-   */
465
-  protected function _set_line_style($width, $cap, $join, $dash) {
453
+    }
454
+
455
+    /**
456
+     * Sets the line style
457
+     *
458
+     * @see Cpdf::setLineStyle()
459
+     *
460
+     * @param float width
461
+     * @param string cap
462
+     * @param string join
463
+     * @param array dash
464
+     */
465
+    protected function _set_line_style($width, $cap, $join, $dash) {
466 466
     $this->_pdf->setLineStyle($width, $cap, $join, $dash);
467
-  }
467
+    }
468 468
   
469
-  //........................................................................
469
+    //........................................................................
470 470
 
471 471
   
472
-  /**
473
-   * Remaps y coords from 4th to 1st quadrant
474
-   *
475
-   * @param float $y
476
-   * @return float
477
-   */
478
-  protected function y($y) { return $this->_height - $y; }
472
+    /**
473
+     * Remaps y coords from 4th to 1st quadrant
474
+     *
475
+     * @param float $y
476
+     * @return float
477
+     */
478
+    protected function y($y) { return $this->_height - $y; }
479 479
 
480
-  // Canvas implementation
480
+    // Canvas implementation
481 481
 
482
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = array(),
482
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = array(),
483 483
                 $blend = "Normal", $opacity = 1.0) {
484 484
     //pre_r(compact("x1", "y1", "x2", "y2", "color", "width", "style"));
485 485
 
@@ -488,35 +488,35 @@  discard block
 block discarded – undo
488 488
     $this->_set_line_transparency($blend, $opacity);
489 489
     
490 490
     $this->_pdf->line($x1, $this->y($y1),
491
-                      $x2, $this->y($y2));
492
-  }
491
+                        $x2, $this->y($y2));
492
+    }
493 493
                               
494
-  //........................................................................
495
-
496
-  /**
497
-   * Convert a GIF image to a PNG image
498
-   *
499
-   * @return string The url of the newly converted image
500
-   */
501
-  protected function _convert_gif_to_png($image_url) {
494
+    //........................................................................
495
+
496
+    /**
497
+     * Convert a GIF image to a PNG image
498
+     *
499
+     * @return string The url of the newly converted image
500
+     */
501
+    protected function _convert_gif_to_png($image_url) {
502 502
     
503 503
     if ( !function_exists("imagecreatefromgif") ) {
504
-      throw new DOMPDF_Exception("Function imagecreatefromgif() not found.  Cannot convert gif image: $image_url.  Please install the image PHP extension.");
504
+        throw new DOMPDF_Exception("Function imagecreatefromgif() not found.  Cannot convert gif image: $image_url.  Please install the image PHP extension.");
505 505
     }
506 506
 
507 507
     $old_err = set_error_handler("record_warnings");
508 508
     $im = imagecreatefromgif($image_url);
509 509
 
510 510
     if ( $im ) {
511
-      imageinterlace($im, 0);
511
+        imageinterlace($im, 0);
512 512
 
513
-      $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png';
514
-      $this->_image_cache[] = $filename;
513
+        $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png';
514
+        $this->_image_cache[] = $filename;
515 515
 
516
-      imagepng($im, $filename);
516
+        imagepng($im, $filename);
517 517
 
518 518
     } else {
519
-      $filename = DOMPDF_LIB_DIR . "/res/broken_image.png";
519
+        $filename = DOMPDF_LIB_DIR . "/res/broken_image.png";
520 520
 
521 521
     }
522 522
 
@@ -524,21 +524,21 @@  discard block
 block discarded – undo
524 524
 
525 525
     return $filename;
526 526
     
527
-  }
527
+    }
528 528
 
529
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = array(),
530
-                     $blend = "Normal", $opacity = 1.0) {
529
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = array(),
530
+                        $blend = "Normal", $opacity = 1.0) {
531 531
 
532 532
     $this->_set_stroke_color($color);
533 533
     $this->_set_line_style($width, "square", "miter", $style);
534 534
     $this->_set_line_transparency($blend, $opacity);
535 535
     
536 536
     $this->_pdf->rectangle($x1, $this->y($y1) - $h, $w, $h);
537
-  }
537
+    }
538 538
 
539
-  //........................................................................
539
+    //........................................................................
540 540
   
541
-  function filled_rectangle($x1, $y1, $w, $h, $color, $blend = "Normal", $opacity = 1.0) {
541
+    function filled_rectangle($x1, $y1, $w, $h, $color, $blend = "Normal", $opacity = 1.0) {
542 542
 
543 543
     $this->_set_fill_color($color);
544 544
     $this->_set_line_style(1, "square", "miter", array());
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
     $this->_set_fill_transparency($blend, $opacity);
547 547
     
548 548
     $this->_pdf->filledRectangle($x1, $this->y($y1) - $h, $w, $h);
549
-  }
549
+    }
550 550
 
551
-  //........................................................................
551
+    //........................................................................
552 552
 
553
-  function polygon($points, $color, $width = null, $style = array(),
554
-                   $fill = false, $blend = "Normal", $opacity = 1.0) {
553
+    function polygon($points, $color, $width = null, $style = array(),
554
+                    $fill = false, $blend = "Normal", $opacity = 1.0) {
555 555
 
556 556
     $this->_set_fill_color($color);
557 557
     $this->_set_stroke_color($color);
@@ -560,19 +560,19 @@  discard block
 block discarded – undo
560 560
     $this->_set_fill_transparency($blend, $opacity);
561 561
     
562 562
     if ( !$fill && isset($width) )
563
-      $this->_set_line_style($width, "square", "miter", $style);
563
+        $this->_set_line_style($width, "square", "miter", $style);
564 564
     
565 565
     // Adjust y values
566 566
     for ( $i = 1; $i < count($points); $i += 2)
567
-      $points[$i] = $this->y($points[$i]);
567
+        $points[$i] = $this->y($points[$i]);
568 568
     
569 569
     $this->_pdf->polygon($points, count($points) / 2, $fill);
570
-  }
570
+    }
571 571
 
572
-  //........................................................................
572
+    //........................................................................
573 573
 
574
-  function circle($x, $y, $r1, $color, $width = null, $style = null,
575
-                  $fill = false, $blend = "Normal", $opacity = 1.0) {
574
+    function circle($x, $y, $r1, $color, $width = null, $style = null,
575
+                    $fill = false, $blend = "Normal", $opacity = 1.0) {
576 576
 
577 577
     $this->_set_fill_color($color);
578 578
     $this->_set_stroke_color($color);
@@ -581,14 +581,14 @@  discard block
 block discarded – undo
581 581
     $this->_set_fill_transparency($blend, $opacity);
582 582
 
583 583
     if ( !$fill && isset($width) )
584
-      $this->_set_line_style($width, "round", "round", $style);
584
+        $this->_set_line_style($width, "round", "round", $style);
585 585
 
586 586
     $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill);
587
-  }
587
+    }
588 588
   
589
-  //........................................................................
589
+    //........................................................................
590 590
 
591
-  function image($img_url, $img_type, $x, $y, $w, $h) {
591
+    function image($img_url, $img_type, $x, $y, $w, $h) {
592 592
     //debugpng
593 593
     if (DEBUGPNG) print '[image:'.$img_url.'|'.$img_type.']';
594 594
 
@@ -600,15 +600,15 @@  discard block
 block discarded – undo
600 600
       //debugpng
601 601
       if (DEBUGPNG)  print '!!!jpg!!!';
602 602
 
603
-      $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604
-      break;
603
+        $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604
+        break;
605 605
 
606 606
     case "png":
607 607
       //debugpng
608 608
       if (DEBUGPNG)  print '!!!png!!!';
609 609
 
610
-      $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611
-      break;
610
+        $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611
+        break;
612 612
 
613 613
     case "gif":
614 614
       // Convert gifs to pngs
@@ -618,41 +618,41 @@  discard block
 block discarded – undo
618 618
         //debugpng
619 619
         if (DEBUGPNG)  print '!!!gif addImagePng!!!';
620 620
 
621
-      	//If optimization to direct png creation from gd object is available,
621
+            //If optimization to direct png creation from gd object is available,
622 622
         //don't create temp file, but place gd object directly into the pdf
623
-	    if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
-	         $this->_pdf->image_iscached($img_url) ) {
625
-	      //If same image has occured already before, no need to load because
626
-	      //duplicate will anyway be eliminated.
627
-	      $img = null;
628
-	    } else {
629
-    	  $img = @imagecreatefromgif($img_url);
630
-    	  if (!$img) {
631
-      	    return;
632
-    	  }
633
-    	  imageinterlace($img, 0);
634
-    	}
635
-    	$this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636
-      } else {
623
+        if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
+             $this->_pdf->image_iscached($img_url) ) {
625
+            //If same image has occured already before, no need to load because
626
+            //duplicate will anyway be eliminated.
627
+            $img = null;
628
+        } else {
629
+            $img = @imagecreatefromgif($img_url);
630
+            if (!$img) {
631
+                return;
632
+            }
633
+            imageinterlace($img, 0);
634
+        }
635
+        $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636
+        } else {
637 637
         //debugpng
638 638
         if (DEBUGPNG)  print '!!!gif addPngFromFile!!!';
639 639
         $img_url = $this->_convert_gif_to_png($img_url);
640 640
         $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
641
-      }
642
-      break;
641
+        }
642
+        break;
643 643
 
644 644
     default:
645 645
       //debugpng
646 646
       if (DEBUGPNG) print '!!!unknown!!!';
647
-      break;
647
+        break;
648 648
     }
649 649
     
650 650
     return;
651
-  }
651
+    }
652 652
 
653
-  //........................................................................
653
+    //........................................................................
654 654
 
655
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0),
655
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0),
656 656
                 $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) {
657 657
 
658 658
     list($r, $g, $b) = $color;
@@ -693,142 +693,142 @@  discard block
 block discarded – undo
693 693
     //print '<pre>['.$font.','.$size.','.$this->_pdf->getFontHeight($size).','.$this->_pdf->getFontDescender($size).','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][1].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontHeightOffset'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Ascender'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Descender'].']</pre>';
694 694
     //
695 695
     //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust);
696
-	//$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust);
697
-	//$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust);
698
-	$this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust);
699
-  }
696
+    //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust);
697
+    //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust);
698
+    $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust);
699
+    }
700 700
 
701
-  //........................................................................
701
+    //........................................................................
702 702
 
703
-  function javascript($code) {
703
+    function javascript($code) {
704 704
     $this->_pdf->addJavascript($code);
705
-  }
705
+    }
706 706
 
707
-  //........................................................................
707
+    //........................................................................
708 708
 
709
-  /**
710
-   * Add a named destination (similar to <a name="foo">...</a> in html)
711
-   *
712
-   * @param string $anchorname The name of the named destination
713
-   */
714
-  function add_named_dest($anchorname) {
709
+    /**
710
+     * Add a named destination (similar to <a name="foo">...</a> in html)
711
+     *
712
+     * @param string $anchorname The name of the named destination
713
+     */
714
+    function add_named_dest($anchorname) {
715 715
     $this->_pdf->addDestination($anchorname,"Fit");
716
-  }
716
+    }
717 717
 
718
-  //........................................................................
718
+    //........................................................................
719 719
 
720
-  /**
721
-   * Add a link to the pdf
722
-   *
723
-   * @param string $url The url to link to
724
-   * @param float  $x   The x position of the link
725
-   * @param float  $y   The y position of the link
726
-   * @param float  $width   The width of the link
727
-   * @param float  $height   The height of the link
728
-   */
729
-  function add_link($url, $x, $y, $width, $height) {
720
+    /**
721
+     * Add a link to the pdf
722
+     *
723
+     * @param string $url The url to link to
724
+     * @param float  $x   The x position of the link
725
+     * @param float  $y   The y position of the link
726
+     * @param float  $width   The width of the link
727
+     * @param float  $height   The height of the link
728
+     */
729
+    function add_link($url, $x, $y, $width, $height) {
730 730
 
731 731
     $y = $this->y($y) - $height;
732 732
 
733 733
     if ( strpos($url, '#') === 0 ) {
734
-      // Local link
735
-      $name = substr($url,1);
736
-      if ( $name )
734
+        // Local link
735
+        $name = substr($url,1);
736
+        if ( $name )
737 737
         $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height);
738 738
 
739 739
     } else {
740
-      $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height);
740
+        $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height);
741 741
     }
742 742
     
743
-  }
743
+    }
744 744
 
745
-  //........................................................................
745
+    //........................................................................
746 746
 
747
-  function get_text_width($text, $font, $size, $spacing = 0) {
747
+    function get_text_width($text, $font, $size, $spacing = 0) {
748 748
     $this->_pdf->selectFont($font);
749 749
     if (!DOMPDF_UNICODE_ENABLED) {
750
-    	$text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
750
+        $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
751 751
     }
752 752
     return $this->_pdf->getTextWidth($size, $text, $spacing);
753
-  }
753
+    }
754 754
 
755
-  //........................................................................
755
+    //........................................................................
756 756
 
757
-  function get_font_height($font, $size) {
757
+    function get_font_height($font, $size) {
758 758
     $this->_pdf->selectFont($font);
759 759
     return $this->_pdf->getFontHeight($size);
760
-  }
760
+    }
761 761
 
762
-  //........................................................................
762
+    //........................................................................
763 763
   
764
-  /**
765
-   * Writes text at the specified x and y coordinates on every page
766
-   *
767
-   * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
768
-   * with their current values.
769
-   *
770
-   * See {@link Style::munge_colour()} for the format of the colour array.
771
-   *
772
-   * @param float $x
773
-   * @param float $y
774
-   * @param string $text the text to write
775
-   * @param string $font the font file to use
776
-   * @param float $size the font size, in points
777
-   * @param array $color
778
-   * @param float $adjust word spacing adjustment
779
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
780
-   */
781
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
782
-                     $adjust = 0, $angle = 0) {
764
+    /**
765
+     * Writes text at the specified x and y coordinates on every page
766
+     *
767
+     * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
768
+     * with their current values.
769
+     *
770
+     * See {@link Style::munge_colour()} for the format of the colour array.
771
+     *
772
+     * @param float $x
773
+     * @param float $y
774
+     * @param string $text the text to write
775
+     * @param string $font the font file to use
776
+     * @param float $size the font size, in points
777
+     * @param array $color
778
+     * @param float $adjust word spacing adjustment
779
+     * @param float $angle angle to write the text at, measured CW starting from the x-axis
780
+     */
781
+    function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
782
+                        $adjust = 0, $angle = 0) {
783 783
     $_t = "text";
784 784
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
785
-  }
785
+    }
786 786
 
787
-  //........................................................................
787
+    //........................................................................
788 788
     
789
-  /**
790
-   * Processes a script on every page
791
-   *
792
-   * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
793
-   *
794
-   * This function can be used to add page numbers to all pages
795
-   * after the first one, for example.
796
-   *
797
-   * @param string $code the script code
798
-   * @param string $type the language type for script
799
-   */
800
-  function page_script($code, $type = "text/php") {
789
+    /**
790
+     * Processes a script on every page
791
+     *
792
+     * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
793
+     *
794
+     * This function can be used to add page numbers to all pages
795
+     * after the first one, for example.
796
+     *
797
+     * @param string $code the script code
798
+     * @param string $type the language type for script
799
+     */
800
+    function page_script($code, $type = "text/php") {
801 801
     $_t = "script";
802 802
     $this->_page_text[] = compact("_t", "code", "type");
803
-  }
803
+    }
804 804
   
805
-  //........................................................................
805
+    //........................................................................
806 806
 
807
-  function new_page() {
807
+    function new_page() {
808 808
     $this->_page_count++;
809 809
 
810 810
     $ret = $this->_pdf->newPage();
811 811
     $this->_pages[] = $ret;
812 812
     return $ret;
813
-  }
813
+    }
814 814
   
815
-  //........................................................................
815
+    //........................................................................
816 816
 
817
-  /**
818
-   * Add text to each page after rendering is complete
819
-   */
820
-  protected function _add_page_text() {
817
+    /**
818
+     * Add text to each page after rendering is complete
819
+     */
820
+    protected function _add_page_text() {
821 821
     
822 822
     if ( !count($this->_page_text) )
823
-      return;
823
+        return;
824 824
 
825 825
     $page_number = 1;
826 826
     $eval = null;
827 827
 
828 828
     foreach ($this->_pages as $pid) {
829
-      $this->reopen_object($pid);
829
+        $this->reopen_object($pid);
830 830
 
831
-      foreach ($this->_page_text as $pt) {
831
+        foreach ($this->_page_text as $pt) {
832 832
         extract($pt);
833 833
 
834 834
         switch ($_t) {
@@ -837,63 +837,63 @@  discard block
 block discarded – undo
837 837
         $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
838 838
                             array($page_number, $this->_page_count), $text);
839 839
         $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
840
-          break;
840
+            break;
841 841
           
842 842
         case "script":
843 843
           if (!$eval) {
844 844
             $eval = new PHP_Evaluator($this);
845
-          }
846
-          $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
847
-          break;
845
+            }
846
+            $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
847
+            break;
848
+        }
848 849
         }
849
-      }
850 850
 
851
-      $this->close_object();
852
-      $page_number++;
851
+        $this->close_object();
852
+        $page_number++;
853
+    }
853 854
     }
854
-  }
855 855
   
856
-  /**
857
-   * Streams the PDF directly to the browser
858
-   *
859
-   * @param string $filename the name of the PDF file
860
-   * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
861
-   */
862
-  function stream($filename, $options = null) {
856
+    /**
857
+     * Streams the PDF directly to the browser
858
+     *
859
+     * @param string $filename the name of the PDF file
860
+     * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
861
+     */
862
+    function stream($filename, $options = null) {
863 863
     // Add page text
864 864
     $this->_add_page_text();
865 865
     
866 866
     $options["Content-Disposition"] = $filename;
867 867
     $this->_pdf->stream($options);
868
-  }
868
+    }
869 869
 
870
-  //........................................................................
870
+    //........................................................................
871 871
 
872
-  /**
873
-   * Returns the PDF as a string
874
-   *
875
-   * @return string
876
-   */
877
-  function output($options = null) {
872
+    /**
873
+     * Returns the PDF as a string
874
+     *
875
+     * @return string
876
+     */
877
+    function output($options = null) {
878 878
     // Add page text
879 879
     $this->_add_page_text();
880 880
 
881 881
     if ( isset($options["compress"]) && $options["compress"] != 1 )
882
-      $debug = 1;
882
+        $debug = 1;
883 883
     else
884
-      $debug = 0;
884
+        $debug = 0;
885 885
     
886 886
     return $this->_pdf->output($debug);
887 887
     
888
-  }
888
+    }
889 889
   
890
-  //........................................................................
891
-
892
-  /**
893
-   * Returns logging messages generated by the Cpdf class
894
-   *
895
-   * @return string
896
-   */
897
-  function get_messages() { return $this->_pdf->messages; }
890
+    //........................................................................
891
+
892
+    /**
893
+     * Returns logging messages generated by the Cpdf class
894
+     *
895
+     * @return string
896
+     */
897
+    function get_messages() { return $this->_pdf->messages; }
898 898
   
899 899
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/pdflib_adapter.cls.php 1 patch
Indentation   +527 added lines, -527 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: pdflib_adapter.cls.php,v $
6
- * Created on: 2005-02-28
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 0.5.1.htischer.20090507
42
- * - Clarify temp file name, optional debug output for temp file tracking
43
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: pdflib_adapter.cls.php,v $
6
+     * Created on: 2005-02-28
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 0.5.1.htischer.20090507
42
+     * - Clarify temp file name, optional debug output for temp file tracking
43
+     */
44 44
 
45 45
 /* $Id: pdflib_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
46 46
 
@@ -61,170 +61,170 @@  discard block
 block discarded – undo
61 61
  */
62 62
 class PDFLib_Adapter implements Canvas {
63 63
 
64
-  /**
65
-   * Dimensions of paper sizes in points
66
-   *
67
-   * @var array;
68
-   */
69
-  static public $PAPER_SIZES = array(); // Set to
64
+    /**
65
+     * Dimensions of paper sizes in points
66
+     *
67
+     * @var array;
68
+     */
69
+    static public $PAPER_SIZES = array(); // Set to
70 70
                                         // CPDF_Adapter::$PAPER_SIZES below.
71 71
 
72
-  /**
73
-   * Fudge factor to adjust reported font heights
74
-   *
75
-   * CPDF reports larger font heights than PDFLib.  This factor
76
-   * adjusts the height reported by get_font_height().
77
-   *
78
-   * @var float
79
-   */
80
-  const FONT_HEIGHT_SCALE = 1.2;
81
-
82
-  /**
83
-   * Whether to create PDFs in memory or on disk
84
-   *
85
-   * @var bool
86
-   */
87
-  static $IN_MEMORY = true;
88
-
89
-  /**
90
-   * Instance of PDFLib class
91
-   *
92
-   * @var PDFlib
93
-   */
94
-  private $_pdf;
95
-
96
-  /**
97
-   * Name of temporary file used for PDFs created on disk
98
-   *
99
-   * @var string
100
-   */
101
-  private $_file;
102
-
103
-  /**
104
-   * PDF width, in points
105
-   *
106
-   * @var float
107
-   */
108
-  private $_width;
109
-
110
-  /**
111
-   * PDF height, in points
112
-   *
113
-   * @var height
114
-   */
115
-  private $_height;
116
-
117
-  /**
118
-   * Last fill colour used
119
-   *
120
-   * @var array
121
-   */
122
-  private $_last_fill_color;
123
-
124
-  /**
125
-   * Last stroke colour used
126
-   *
127
-   * @var array
128
-   */
129
-  private $_last_stroke_color;
130
-
131
-  /**
132
-   * Cache of image handles
133
-   *
134
-   * @var array
135
-   */
136
-  private $_imgs;
137
-
138
-  /**
139
-   * Cache of font handles
140
-   *
141
-   * @var array
142
-   */
143
-  private $_fonts;
144
-
145
-  /**
146
-   * List of objects (templates) to add to multiple pages
147
-   *
148
-   * @var array
149
-   */
150
-  private $_objs;
151
-
152
-  /**
153
-   * Current page number
154
-   *
155
-   * @var int
156
-   */
157
-  private $_page_number;
158
-
159
-  /**
160
-   * Total number of pages
161
-   *
162
-   * @var int
163
-   */
164
-  private $_page_count;
165
-
166
-  /**
167
-   * Text to display on every page
168
-   *
169
-   * @var array
170
-   */
171
-  private $_page_text;
172
-
173
-  /**
174
-   * Array of pages for accesing after rendering is initially complete
175
-   *
176
-   * @var array
177
-   */
178
-  private $_pages;
179
-
180
-  /**
181
-   * Class constructor
182
-   *
183
-   * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
184
-   *                     an array(xmin,ymin,xmax,ymax)
185
-   * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186
-   */
187
-  function __construct($paper = "letter", $orientation = "portrait") {
72
+    /**
73
+     * Fudge factor to adjust reported font heights
74
+     *
75
+     * CPDF reports larger font heights than PDFLib.  This factor
76
+     * adjusts the height reported by get_font_height().
77
+     *
78
+     * @var float
79
+     */
80
+    const FONT_HEIGHT_SCALE = 1.2;
81
+
82
+    /**
83
+     * Whether to create PDFs in memory or on disk
84
+     *
85
+     * @var bool
86
+     */
87
+    static $IN_MEMORY = true;
88
+
89
+    /**
90
+     * Instance of PDFLib class
91
+     *
92
+     * @var PDFlib
93
+     */
94
+    private $_pdf;
95
+
96
+    /**
97
+     * Name of temporary file used for PDFs created on disk
98
+     *
99
+     * @var string
100
+     */
101
+    private $_file;
102
+
103
+    /**
104
+     * PDF width, in points
105
+     *
106
+     * @var float
107
+     */
108
+    private $_width;
109
+
110
+    /**
111
+     * PDF height, in points
112
+     *
113
+     * @var height
114
+     */
115
+    private $_height;
116
+
117
+    /**
118
+     * Last fill colour used
119
+     *
120
+     * @var array
121
+     */
122
+    private $_last_fill_color;
123
+
124
+    /**
125
+     * Last stroke colour used
126
+     *
127
+     * @var array
128
+     */
129
+    private $_last_stroke_color;
130
+
131
+    /**
132
+     * Cache of image handles
133
+     *
134
+     * @var array
135
+     */
136
+    private $_imgs;
137
+
138
+    /**
139
+     * Cache of font handles
140
+     *
141
+     * @var array
142
+     */
143
+    private $_fonts;
144
+
145
+    /**
146
+     * List of objects (templates) to add to multiple pages
147
+     *
148
+     * @var array
149
+     */
150
+    private $_objs;
151
+
152
+    /**
153
+     * Current page number
154
+     *
155
+     * @var int
156
+     */
157
+    private $_page_number;
158
+
159
+    /**
160
+     * Total number of pages
161
+     *
162
+     * @var int
163
+     */
164
+    private $_page_count;
165
+
166
+    /**
167
+     * Text to display on every page
168
+     *
169
+     * @var array
170
+     */
171
+    private $_page_text;
172
+
173
+    /**
174
+     * Array of pages for accesing after rendering is initially complete
175
+     *
176
+     * @var array
177
+     */
178
+    private $_pages;
179
+
180
+    /**
181
+     * Class constructor
182
+     *
183
+     * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
184
+     *                     an array(xmin,ymin,xmax,ymax)
185
+     * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186
+     */
187
+    function __construct($paper = "letter", $orientation = "portrait") {
188 188
     if ( is_array($paper) )
189
-      $size = $paper;
189
+        $size = $paper;
190 190
     else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
191
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
191
+        $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192 192
     else
193
-      $size = self::$PAPER_SIZES["letter"];
193
+        $size = self::$PAPER_SIZES["letter"];
194 194
 
195 195
     if ( mb_strtolower($orientation) === "landscape" ) {
196
-      $a = $size[3];
197
-      $size[3] = $size[2];
198
-      $size[2] = $a;
196
+        $a = $size[3];
197
+        $size[3] = $size[2];
198
+        $size[2] = $a;
199 199
     }
200 200
     $this->_width = $size[2] - $size[0];
201 201
     $this->_height= $size[3] - $size[1];
202 202
 
203 203
     $this->_pdf = new PDFLib();
204 204
 
205
-	if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
-      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
205
+    if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
+        $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
207 207
 
208
-	$this->_pdf->set_parameter("textformat", "utf8");
208
+    $this->_pdf->set_parameter("textformat", "utf8");
209 209
     $this->_pdf->set_parameter("fontwarning", "false");
210 210
 
211 211
     $this->_pdf->set_info("Creator", "DOMPDF Converter");
212 212
 
213 213
     // Silence pedantic warnings about missing TZ settings
214 214
     if ( function_exists("date_default_timezone_get") ) {
215
-      $tz = @date_default_timezone_get();
216
-      date_default_timezone_set("UTC");
217
-      $this->_pdf->set_info("Date", date("Y-m-d"));
218
-      date_default_timezone_set($tz);
215
+        $tz = @date_default_timezone_get();
216
+        date_default_timezone_set("UTC");
217
+        $this->_pdf->set_info("Date", date("Y-m-d"));
218
+        date_default_timezone_set($tz);
219 219
     } else {
220
-      $this->_pdf->set_info("Date", date("Y-m-d"));
220
+        $this->_pdf->set_info("Date", date("Y-m-d"));
221 221
     }
222 222
 
223 223
     if ( self::$IN_MEMORY )
224
-      $this->_pdf->begin_document("","");
224
+        $this->_pdf->begin_document("","");
225 225
     else {
226
-      $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
-      $this->_pdf->begin_document($this->_file,"");
226
+        $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
+        $this->_pdf->begin_document($this->_file,"");
228 228
     }
229 229
 
230 230
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
@@ -239,155 +239,155 @@  discard block
 block discarded – undo
239 239
     // Set up font paths
240 240
     $families = Font_Metrics::get_font_families();
241 241
     foreach ($families as $family => $files) {
242
-      foreach ($files as $style => $file) {
242
+        foreach ($files as $style => $file) {
243 243
         $face = basename($file);
244 244
 
245 245
         // Prefer ttfs to afms
246 246
         if ( file_exists($file.".ttf") ) {
247
-          $outline = "$file.ttf";
248
-          $afm = null;
247
+            $outline = "$file.ttf";
248
+            $afm = null;
249 249
 
250 250
         } else if ( file_exists($file .".TTF") ) {
251
-          $outline = "$file.TTF";
252
-          $afm = null;
251
+            $outline = "$file.TTF";
252
+            $afm = null;
253 253
 
254 254
         } else if ( file_exists($file . ".pfb") ) {
255
-          $outline = "$file.pfb";
255
+            $outline = "$file.pfb";
256 256
 
257
-          if ( file_exists($file . ".afm") )
257
+            if ( file_exists($file . ".afm") )
258 258
             $afm = "$file.afm";
259 259
 
260 260
         } else if ( file_exists($file . ".PFB") ) {
261
-          $outline = "$file.PFB";
262
-          if ( file_exists($file . ".AFM") )
261
+            $outline = "$file.PFB";
262
+            if ( file_exists($file . ".AFM") )
263 263
             $afm = "$file.AFM";
264 264
         } else
265
-          continue;
265
+            continue;
266 266
 
267 267
         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");
268 268
         if ( !is_null($afm) )
269
-          $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270
-      }
269
+            $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270
+        }
271
+    }
271 272
     }
272
-  }
273 273
 
274
-  /**
275
-   * Close the pdf
276
-   */
277
-  protected function _close() {
274
+    /**
275
+     * Close the pdf
276
+     */
277
+    protected function _close() {
278 278
     $this->_place_objects();
279 279
 
280 280
     // Close all pages
281 281
     $this->_pdf->suspend_page("");
282 282
     for ($p = 1; $p <= $this->_page_count; $p++) {
283
-      $this->_pdf->resume_page("pagenumber=$p");
284
-      $this->_pdf->end_page_ext("");
283
+        $this->_pdf->resume_page("pagenumber=$p");
284
+        $this->_pdf->end_page_ext("");
285 285
     }
286 286
 
287 287
     $this->_pdf->end_document("");
288
-  }
289
-
290
-
291
-  /**
292
-   * Returns the PDFLib instance
293
-   *
294
-   * @return PDFLib
295
-   */
296
-  function get_pdflib() { return $this->_pdf; }
297
-
298
-  /**
299
-   * Add meta information to the PDF
300
-   *
301
-   * @param string $label  label of the value (Creator, Producter, etc.)
302
-   * @param string $value  the text to set
303
-   */
304
-  function add_info($label, $value) {
288
+    }
289
+
290
+
291
+    /**
292
+     * Returns the PDFLib instance
293
+     *
294
+     * @return PDFLib
295
+     */
296
+    function get_pdflib() { return $this->_pdf; }
297
+
298
+    /**
299
+     * Add meta information to the PDF
300
+     *
301
+     * @param string $label  label of the value (Creator, Producter, etc.)
302
+     * @param string $value  the text to set
303
+     */
304
+    function add_info($label, $value) {
305 305
     $this->_pdf->set_info($label, $value);
306
-  }
306
+    }
307 307
   
308
-  /**
309
-   * Opens a new 'object' (template in PDFLib-speak)
310
-   *
311
-   * While an object is open, all drawing actions are recorded to the
312
-   * object instead of being drawn on the current page.  Objects can
313
-   * be added later to a specific page or to several pages.
314
-   *
315
-   * The return value is an integer ID for the new object.
316
-   *
317
-   * @see PDFLib_Adapter::close_object()
318
-   * @see PDFLib_Adapter::add_object()
319
-   *
320
-   * @return int
321
-   */
322
-  function open_object() {
308
+    /**
309
+     * Opens a new 'object' (template in PDFLib-speak)
310
+     *
311
+     * While an object is open, all drawing actions are recorded to the
312
+     * object instead of being drawn on the current page.  Objects can
313
+     * be added later to a specific page or to several pages.
314
+     *
315
+     * The return value is an integer ID for the new object.
316
+     *
317
+     * @see PDFLib_Adapter::close_object()
318
+     * @see PDFLib_Adapter::add_object()
319
+     *
320
+     * @return int
321
+     */
322
+    function open_object() {
323 323
     $this->_pdf->suspend_page("");
324 324
     $ret = $this->_pdf->begin_template($this->_width, $this->_height);
325 325
     $this->_pdf->save();
326 326
     $this->_objs[$ret] = array("start_page" => $this->_page_number);
327 327
     return $ret;
328
-  }
329
-
330
-  /**
331
-   * Reopen an existing object (NOT IMPLEMENTED)
332
-   *
333
-   * PDFLib does not seem to support reopening templates.
334
-   *
335
-   * @param int $object the ID of a previously opened object
336
-   */
337
-  function reopen_object($object) {
328
+    }
329
+
330
+    /**
331
+     * Reopen an existing object (NOT IMPLEMENTED)
332
+     *
333
+     * PDFLib does not seem to support reopening templates.
334
+     *
335
+     * @param int $object the ID of a previously opened object
336
+     */
337
+    function reopen_object($object) {
338 338
     throw new DOMPDF_Exception("PDFLib does not support reopening objects.");
339
-  }
340
-
341
-  /**
342
-   * Close the current template
343
-   *
344
-   * @see PDFLib_Adapter::open_object()
345
-   */
346
-  function close_object() {
339
+    }
340
+
341
+    /**
342
+     * Close the current template
343
+     *
344
+     * @see PDFLib_Adapter::open_object()
345
+     */
346
+    function close_object() {
347 347
     $this->_pdf->restore();
348 348
     $this->_pdf->end_template();
349 349
     $this->_pdf->resume_page("pagenumber=".$this->_page_number);
350
-  }
351
-
352
-  /**
353
-   * Adds the specified object to the document
354
-   *
355
-   * $where can be one of:
356
-   * - 'add' add to current page only
357
-   * - 'all' add to every page from the current one onwards
358
-   * - 'odd' add to all odd numbered pages from now on
359
-   * - 'even' add to all even numbered pages from now on
360
-   * - 'next' add the object to the next page only
361
-   * - 'nextodd' add to all odd numbered pages from the next one
362
-   * - 'nexteven' add to all even numbered pages from the next one
363
-   *
364
-   * @param int $object the object handle returned by open_object()
365
-   * @param string $where
366
-   */
367
-  function add_object($object, $where = 'all') {
350
+    }
351
+
352
+    /**
353
+     * Adds the specified object to the document
354
+     *
355
+     * $where can be one of:
356
+     * - 'add' add to current page only
357
+     * - 'all' add to every page from the current one onwards
358
+     * - 'odd' add to all odd numbered pages from now on
359
+     * - 'even' add to all even numbered pages from now on
360
+     * - 'next' add the object to the next page only
361
+     * - 'nextodd' add to all odd numbered pages from the next one
362
+     * - 'nexteven' add to all even numbered pages from the next one
363
+     *
364
+     * @param int $object the object handle returned by open_object()
365
+     * @param string $where
366
+     */
367
+    function add_object($object, $where = 'all') {
368 368
 
369 369
     if ( mb_strpos($where, "next") !== false ) {
370
-      $this->_objs[$object]["start_page"]++;
371
-      $where = str_replace("next", "", $where);
372
-      if ( $where == "" )
370
+        $this->_objs[$object]["start_page"]++;
371
+        $where = str_replace("next", "", $where);
372
+        if ( $where == "" )
373 373
         $where = "add";
374 374
     }
375 375
 
376 376
     $this->_objs[$object]["where"] = $where;
377
-  }
378
-
379
-  /**
380
-   * Stops the specified template from appearing in the document.
381
-   *
382
-   * The object will stop being displayed on the page following the
383
-   * current one.
384
-   *
385
-   * @param int $object
386
-   */
387
-  function stop_object($object) {
377
+    }
378
+
379
+    /**
380
+     * Stops the specified template from appearing in the document.
381
+     *
382
+     * The object will stop being displayed on the page following the
383
+     * current one.
384
+     *
385
+     * @param int $object
386
+     */
387
+    function stop_object($object) {
388 388
 
389 389
     if ( !isset($this->_objs[$object]) )
390
-      return;
390
+        return;
391 391
 
392 392
     $start = $this->_objs[$object]["start_page"];
393 393
     $where = $this->_objs[$object]["where"];
@@ -397,74 +397,74 @@  discard block
 block discarded – undo
397 397
          (($this->_page_number % 2 == 0 && $where === "even") ||
398 398
           ($this->_page_number % 2 == 1 && $where === "odd") ||
399 399
           ($where === "all")) )
400
-      $this->_pdf->fit_image($object,0,0,"");
400
+        $this->_pdf->fit_image($object,0,0,"");
401 401
 
402 402
     unset($this->_objs[$object]);
403
-  }
403
+    }
404 404
 
405
-  /**
406
-   * Add all active objects to the current page
407
-   */
408
-  protected function _place_objects() {
405
+    /**
406
+     * Add all active objects to the current page
407
+     */
408
+    protected function _place_objects() {
409 409
 
410 410
     foreach ( $this->_objs as $obj => $props ) {
411
-      $start = $props["start_page"];
412
-      $where = $props["where"];
411
+        $start = $props["start_page"];
412
+        $where = $props["where"];
413 413
 
414
-      // Place the object on this page if required
415
-      if ( $this->_page_number >= $start &&
414
+        // Place the object on this page if required
415
+        if ( $this->_page_number >= $start &&
416 416
            (($this->_page_number % 2 == 0 && $where === "even") ||
417 417
             ($this->_page_number % 2 == 1 && $where === "odd") ||
418 418
             ($where === "all")) ) {
419 419
         $this->_pdf->fit_image($obj,0,0,"");
420
-      }
420
+        }
421 421
     }
422 422
 
423
-  }
423
+    }
424 424
 
425
-  function get_width() { return $this->_width; }
425
+    function get_width() { return $this->_width; }
426 426
 
427
-  function get_height() { return $this->_height; }
427
+    function get_height() { return $this->_height; }
428 428
 
429
-  function get_page_number() { return $this->_page_number; }
429
+    function get_page_number() { return $this->_page_number; }
430 430
 
431
-  function get_page_count() { return $this->_page_count; }
431
+    function get_page_count() { return $this->_page_count; }
432 432
 
433
-  function set_page_number($num) { $this->_page_number = (int)$num; }
433
+    function set_page_number($num) { $this->_page_number = (int)$num; }
434 434
 
435
-  function set_page_count($count) { $this->_page_count = (int)$count; }
435
+    function set_page_count($count) { $this->_page_count = (int)$count; }
436 436
 
437 437
 
438
-  /**
439
-   * Sets the line style
440
-   *
441
-   * @param float width
442
-   * @param string corner
443
-   * @param string join
444
-   * @param array dash
445
-   */
446
-  protected function _set_line_style($width, $cap, $join, $dash) {
438
+    /**
439
+     * Sets the line style
440
+     *
441
+     * @param float width
442
+     * @param string corner
443
+     * @param string join
444
+     * @param array dash
445
+     */
446
+    protected function _set_line_style($width, $cap, $join, $dash) {
447 447
 
448 448
     if ( count($dash) == 1 )
449
-      $dash[] = $dash[0];
449
+        $dash[] = $dash[0];
450 450
 
451 451
     if ( count($dash) > 1 )
452
-      $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
452
+        $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
453 453
     else
454
-      $this->_pdf->setdash(0,0);
454
+        $this->_pdf->setdash(0,0);
455 455
 
456 456
     switch ( $join ) {
457 457
     case "miter":
458 458
       $this->_pdf->setlinejoin(0);
459
-      break;
459
+        break;
460 460
 
461 461
     case "round":
462 462
       $this->_pdf->setlinejoin(1);
463
-      break;
463
+        break;
464 464
 
465 465
     case "bevel":
466 466
       $this->_pdf->setlinejoin(2);
467
-      break;
467
+        break;
468 468
 
469 469
     default:
470 470
       break;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
     switch ( $cap ) {
474 474
     case "butt":
475 475
       $this->_pdf->setlinecap(0);
476
-      break;
476
+        break;
477 477
 
478 478
     case "round":
479 479
       $this->_pdf->setlinecap(1);
480
-      break;
480
+        break;
481 481
 
482 482
     case "square":
483 483
       $this->_pdf->setlinecap(2);
484
-      break;
484
+        break;
485 485
 
486 486
     default:
487 487
       break;
@@ -489,69 +489,69 @@  discard block
 block discarded – undo
489 489
 
490 490
     $this->_pdf->setlinewidth($width);
491 491
 
492
-  }
492
+    }
493 493
 
494
-  /**
495
-   * Sets the line color
496
-   *
497
-   * @param array $color array(r,g,b)
498
-   */
499
-  protected function _set_stroke_color($color) {
494
+    /**
495
+     * Sets the line color
496
+     *
497
+     * @param array $color array(r,g,b)
498
+     */
499
+    protected function _set_stroke_color($color) {
500 500
     if($this->_last_stroke_color == $color)
501
-    	return;
501
+        return;
502 502
 
503 503
     $this->_last_stroke_color = $color;
504 504
 
505 505
     list($r,$g,$b) = $color;
506 506
     $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0);
507
-  }
508
-
509
-  /**
510
-   * Sets the fill color
511
-   *
512
-   * @param array $color array(r,g,b)
513
-   */
514
-  protected function _set_fill_color($color) {
507
+    }
508
+
509
+    /**
510
+     * Sets the fill color
511
+     *
512
+     * @param array $color array(r,g,b)
513
+     */
514
+    protected function _set_fill_color($color) {
515 515
     if($this->_last_fill_color == $color)
516
-    	return;
516
+        return;
517 517
 
518 518
     $this->_last_fill_color = $color;
519 519
 
520 520
     list($r,$g,$b) = $color;
521 521
     $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0);
522
-  }
522
+    }
523 523
 
524
-  /**
525
-   * Loads a specific font and stores the corresponding descriptor.
526
-   *
527
-   * @param string $font
528
-   * @return int the font descriptor for the font
529
-   */
530
-  protected function _load_font($font, $encoding = null, $options = "") {
524
+    /**
525
+     * Loads a specific font and stores the corresponding descriptor.
526
+     *
527
+     * @param string $font
528
+     * @return int the font descriptor for the font
529
+     */
530
+    protected function _load_font($font, $encoding = null, $options = "") {
531 531
 
532 532
     // Check if the font is a native PDF font
533 533
     // Embed non-native fonts
534 534
     $native_fonts = array("courier", "courier-bold", "courier-oblique", "courier-boldoblique",
535
-                          "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique",
536
-                          "times-roman", "times-bold", "times-italic", "times-bolditalic",
537
-                          "symbol", "zapfdinbats");
535
+                            "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique",
536
+                            "times-roman", "times-bold", "times-italic", "times-bolditalic",
537
+                            "symbol", "zapfdinbats");
538 538
 
539 539
     $test = strtolower(basename($font));
540 540
     if ( in_array($test, $native_fonts) ) {
541
-      $font = basename($font);
541
+        $font = basename($font);
542 542
 
543 543
     } else {
544
-      // Embed non-native fonts
545
-      $options .= " embedding=true";
544
+        // Embed non-native fonts
545
+        $options .= " embedding=true";
546 546
     }
547 547
 
548 548
     if ( is_null($encoding) ) {
549 549
 
550
-      // Unicode encoding is only available for the commerical
551
-      // version of PDFlib and not PDFlib-Lite
552
-      if ( defined("DOMPDF_PDFLIB_LICENSE") )
550
+        // Unicode encoding is only available for the commerical
551
+        // version of PDFlib and not PDFlib-Lite
552
+        if ( defined("DOMPDF_PDFLIB_LICENSE") )
553 553
         $encoding = "unicode";
554
-      else
554
+        else
555 555
         $encoding = "auto";
556 556
 
557 557
     }
@@ -559,28 +559,28 @@  discard block
 block discarded – undo
559 559
     $key = $font .":". $encoding .":". $options;
560 560
 
561 561
     if ( isset($this->_fonts[$key]) )
562
-      return $this->_fonts[$key];
562
+        return $this->_fonts[$key];
563 563
 
564 564
     else {
565 565
 
566
-      $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567
-      return $this->_fonts[$key];
566
+        $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567
+        return $this->_fonts[$key];
568 568
 
569 569
     }
570 570
 
571
-  }
571
+    }
572 572
 
573
-  /**
574
-   * Remaps y coords from 4th to 1st quadrant
575
-   *
576
-   * @param float $y
577
-   * @return float
578
-   */
579
-  protected function y($y) { return $this->_height - $y; }
573
+    /**
574
+     * Remaps y coords from 4th to 1st quadrant
575
+     *
576
+     * @param float $y
577
+     * @return float
578
+     */
579
+    protected function y($y) { return $this->_height - $y; }
580 580
 
581
-  //........................................................................
581
+    //........................................................................
582 582
 
583
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
583
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
584 584
     $this->_set_line_style($width, "butt", "", $style);
585 585
     $this->_set_stroke_color($color);
586 586
 
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
     $this->_pdf->moveto($x1,$y1);
591 591
     $this->_pdf->lineto($x2, $y2);
592 592
     $this->_pdf->stroke();
593
-  }
593
+    }
594 594
 
595
-  //........................................................................
595
+    //........................................................................
596 596
 
597
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
597
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
598 598
     $this->_set_stroke_color($color);
599 599
     $this->_set_line_style($width, "square", "miter", $style);
600 600
 
@@ -602,93 +602,93 @@  discard block
 block discarded – undo
602 602
 
603 603
     $this->_pdf->rect($x1, $y1, $w, $h);
604 604
     $this->_pdf->stroke();
605
-  }
605
+    }
606 606
 
607
-  //........................................................................
607
+    //........................................................................
608 608
 
609
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
609
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
610 610
     $this->_set_fill_color($color);
611 611
 
612 612
     $y1 = $this->y($y1) - $h;
613 613
 
614 614
     $this->_pdf->rect($x1, $y1, $w, $h);
615 615
     $this->_pdf->fill();
616
-  }
616
+    }
617 617
 
618
-  //........................................................................
618
+    //........................................................................
619 619
 
620
-  function polygon($points, $color, $width = null, $style = null, $fill = false) {
620
+    function polygon($points, $color, $width = null, $style = null, $fill = false) {
621 621
 
622 622
     $this->_set_fill_color($color);
623 623
     $this->_set_stroke_color($color);
624 624
 
625 625
     if ( !$fill && isset($width) )
626
-      $this->_set_line_style($width, "square", "miter", $style);
626
+        $this->_set_line_style($width, "square", "miter", $style);
627 627
 
628 628
     $y = $this->y(array_pop($points));
629 629
     $x = array_pop($points);
630 630
     $this->_pdf->moveto($x,$y);
631 631
 
632 632
     while (count($points) > 1) {
633
-      $y = $this->y(array_pop($points));
634
-      $x = array_pop($points);
635
-      $this->_pdf->lineto($x,$y);
633
+        $y = $this->y(array_pop($points));
634
+        $x = array_pop($points);
635
+        $this->_pdf->lineto($x,$y);
636 636
     }
637 637
 
638 638
     if ( $fill )
639
-      $this->_pdf->fill();
639
+        $this->_pdf->fill();
640 640
     else
641
-      $this->_pdf->closepath_stroke();
642
-  }
641
+        $this->_pdf->closepath_stroke();
642
+    }
643 643
 
644
-  //........................................................................
644
+    //........................................................................
645 645
 
646
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
646
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
647 647
 
648 648
     $this->_set_fill_color($color);
649 649
     $this->_set_stroke_color($color);
650 650
 
651 651
     if ( !$fill && isset($width) )
652
-      $this->_set_line_style($width, "round", "round", $style);
652
+        $this->_set_line_style($width, "round", "round", $style);
653 653
 
654 654
     $y = $this->y($y);
655 655
 
656 656
     $this->_pdf->circle($x, $y, $r);
657 657
 
658 658
     if ( $fill )
659
-      $this->_pdf->fill();
659
+        $this->_pdf->fill();
660 660
     else
661
-      $this->_pdf->stroke();
661
+        $this->_pdf->stroke();
662 662
 
663
-  }
663
+    }
664 664
 
665
-  //........................................................................
665
+    //........................................................................
666 666
 
667
-  function image($img_url, $img_type, $x, $y, $w, $h) {
667
+    function image($img_url, $img_type, $x, $y, $w, $h) {
668 668
     $w = (int)$w;
669 669
     $h = (int)$h;
670 670
 
671 671
     $img_type = strtolower($img_type);
672 672
 
673 673
     if ( $img_type === "jpg" )
674
-      $img_type = "jpeg";
674
+        $img_type = "jpeg";
675 675
 
676 676
     if ( isset($this->_imgs[$img_url]) )
677
-      $img = $this->_imgs[$img_url];
677
+        $img = $this->_imgs[$img_url];
678 678
 
679 679
     else {
680 680
 
681
-      $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
681
+        $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
682 682
     }
683 683
 
684 684
     $y = $this->y($y) - $h;
685 685
     $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire');
686 686
 
687
-  }
687
+    }
688 688
 
689
-  //........................................................................
689
+    //........................................................................
690 690
 
691
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
691
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
692 692
     $fh = $this->_load_font($font);
693 693
 
694 694
     $this->_pdf->setfont($fh, $size);
@@ -701,72 +701,72 @@  discard block
 block discarded – undo
701 701
 
702 702
     $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust");
703 703
 
704
-  }
704
+    }
705 705
 
706
-  //........................................................................
706
+    //........................................................................
707 707
   
708
-  function javascript($code) {
708
+    function javascript($code) {
709 709
     // Not implemented
710
-  }
710
+    }
711 711
 
712
-  //........................................................................
712
+    //........................................................................
713 713
 
714
-  /**
715
-   * Add a named destination (similar to <a name="foo">...</a> in html)
716
-   *
717
-   * @param string $anchorname The name of the named destination
718
-   */
719
-  function add_named_dest($anchorname) {
714
+    /**
715
+     * Add a named destination (similar to <a name="foo">...</a> in html)
716
+     *
717
+     * @param string $anchorname The name of the named destination
718
+     */
719
+    function add_named_dest($anchorname) {
720 720
     $this->_pdf->add_nameddest($anchorname,"");
721
-  }
721
+    }
722 722
 
723
-  //........................................................................
723
+    //........................................................................
724 724
 
725
-  /**
726
-   * Add a link to the pdf
727
-   *
728
-   * @param string $url The url to link to
729
-   * @param float  $x   The x position of the link
730
-   * @param float  $y   The y position of the link
731
-   * @param float  $width   The width of the link
732
-   * @param float  $height   The height of the link
733
-   */
734
-  function add_link($url, $x, $y, $width, $height) {
725
+    /**
726
+     * Add a link to the pdf
727
+     *
728
+     * @param string $url The url to link to
729
+     * @param float  $x   The x position of the link
730
+     * @param float  $y   The y position of the link
731
+     * @param float  $width   The width of the link
732
+     * @param float  $height   The height of the link
733
+     */
734
+    function add_link($url, $x, $y, $width, $height) {
735 735
 
736 736
     $y = $this->y($y) - $height;
737 737
     if ( strpos($url, '#') === 0 ) {
738
-      // Local link
739
-      $name = substr($url,1);
740
-      if ( $name )
738
+        // Local link
739
+        $name = substr($url,1);
740
+        if ( $name )
741 741
         $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
742 742
     } else {
743 743
 
744
-      list($proto, $host, $path, $file) = explode_url($url);
744
+        list($proto, $host, $path, $file) = explode_url($url);
745 745
 
746
-      if ( $proto == "" || $proto === "file://" )
746
+        if ( $proto == "" || $proto === "file://" )
747 747
         return; // Local links are not allowed
748
-      $url = build_url($proto, $host, $path, $file);
749
-      $url = '{' . rawurldecode($url) . '}';
748
+        $url = build_url($proto, $host, $path, $file);
749
+        $url = '{' . rawurldecode($url) . '}';
750 750
       
751
-      $action = $this->_pdf->create_action("URI", "url=" . $url);
752
-      $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
751
+        $action = $this->_pdf->create_action("URI", "url=" . $url);
752
+        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
753
+    }
753 754
     }
754
-  }
755 755
 
756
-  //........................................................................
756
+    //........................................................................
757 757
 
758
-  function get_text_width($text, $font, $size, $spacing = 0) {
758
+    function get_text_width($text, $font, $size, $spacing = 0) {
759 759
     $fh = $this->_load_font($font);
760 760
 
761 761
     // Determine the additional width due to extra spacing
762 762
     $num_spaces = mb_substr_count($text," ");
763 763
     $delta = $spacing * $num_spaces;
764 764
     return $this->_pdf->stringwidth($text, $fh, $size) + $delta;
765
-  }
765
+    }
766 766
 
767
-  //........................................................................
767
+    //........................................................................
768 768
 
769
-  function get_font_height($font, $size) {
769
+    function get_font_height($font, $size) {
770 770
 
771 771
     $fh = $this->_load_font($font);
772 772
 
@@ -777,54 +777,54 @@  discard block
 block discarded – undo
777 777
 
778 778
     // $desc is usually < 0,
779 779
     return self::FONT_HEIGHT_SCALE * $size * ($asc - $desc);
780
-  }
781
-
782
-  //........................................................................
783
-
784
-  /**
785
-   * Writes text at the specified x and y coordinates on every page
786
-   *
787
-   * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
788
-   * with their current values.
789
-   *
790
-   * See {@link Style::munge_colour()} for the format of the colour array.
791
-   *
792
-   * @param float $x
793
-   * @param float $y
794
-   * @param string $text the text to write
795
-   * @param string $font the font file to use
796
-   * @param float $size the font size, in points
797
-   * @param array $color
798
-   * @param float $adjust word spacing adjustment
799
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
800
-   */
801
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
-                     $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
780
+    }
781
+
782
+    //........................................................................
783
+
784
+    /**
785
+     * Writes text at the specified x and y coordinates on every page
786
+     *
787
+     * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
788
+     * with their current values.
789
+     *
790
+     * See {@link Style::munge_colour()} for the format of the colour array.
791
+     *
792
+     * @param float $x
793
+     * @param float $y
794
+     * @param string $text the text to write
795
+     * @param string $font the font file to use
796
+     * @param float $size the font size, in points
797
+     * @param array $color
798
+     * @param float $adjust word spacing adjustment
799
+     * @param float $angle angle to write the text at, measured CW starting from the x-axis
800
+     */
801
+    function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
+                        $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
803 803
     $_t = "text";
804 804
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
805
-  }
806
-
807
-  //........................................................................
808
-
809
-  /**
810
-   * Processes a script on every page
811
-   *
812
-   * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
813
-   *
814
-   * This function can be used to add page numbers to all pages
815
-   * after the first one, for example.
816
-   *
817
-   * @param string $code the script code
818
-   * @param string $type the language type for script
819
-   */
820
-  function page_script($code, $type = "text/php") {
805
+    }
806
+
807
+    //........................................................................
808
+
809
+    /**
810
+     * Processes a script on every page
811
+     *
812
+     * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
813
+     *
814
+     * This function can be used to add page numbers to all pages
815
+     * after the first one, for example.
816
+     *
817
+     * @param string $code the script code
818
+     * @param string $type the language type for script
819
+     */
820
+    function page_script($code, $type = "text/php") {
821 821
     $_t = "script";
822 822
     $this->_page_text[] = compact("_t", "code", "type");
823
-  }
823
+    }
824 824
 
825
-  //........................................................................
825
+    //........................................................................
826 826
 
827
-  function new_page() {
827
+    function new_page() {
828 828
 
829 829
     // Add objects to the current page
830 830
     $this->_place_objects();
@@ -833,69 +833,69 @@  discard block
 block discarded – undo
833 833
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
834 834
     $this->_page_number = ++$this->_page_count;
835 835
 
836
-  }
836
+    }
837 837
 
838
-  //........................................................................
838
+    //........................................................................
839 839
 
840
-  /**
841
-   * Add text to each page after rendering is complete
842
-   */
843
-  protected function _add_page_text() {
840
+    /**
841
+     * Add text to each page after rendering is complete
842
+     */
843
+    protected function _add_page_text() {
844 844
 
845 845
     if ( !count($this->_page_text) )
846
-      return;
846
+        return;
847 847
 
848 848
     $this->_pdf->suspend_page("");
849 849
 
850 850
     for ($p = 1; $p <= $this->_page_count; $p++) {
851
-      $this->_pdf->resume_page("pagenumber=$p");
851
+        $this->_pdf->resume_page("pagenumber=$p");
852 852
 
853
-      foreach ($this->_page_text as $pt) {
853
+        foreach ($this->_page_text as $pt) {
854 854
         extract($pt);
855 855
 
856 856
         switch ($_t) {
857 857
 
858 858
         case "text":
859 859
           $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
860
-                              array($p, $this->_page_count), $text);
861
-          $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
-          break;
860
+                                array($p, $this->_page_count), $text);
861
+            $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
+            break;
863 863
 
864 864
         case "script":
865 865
           if (!$eval) {
866 866
             $eval = new PHP_Evaluator($this);
867
-          }
868
-          $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
-          break;
867
+            }
868
+            $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
+            break;
870
+        }
870 871
         }
871
-      }
872 872
 
873
-      $this->_pdf->suspend_page("");
873
+        $this->_pdf->suspend_page("");
874 874
     }
875 875
 
876 876
     $this->_pdf->resume_page("pagenumber=".$this->_page_number);
877
-  }
877
+    }
878 878
 
879
-  //........................................................................
879
+    //........................................................................
880 880
 
881
-  function stream($filename, $options = null) {
881
+    function stream($filename, $options = null) {
882 882
 
883 883
     // Add page text
884 884
     $this->_add_page_text();
885 885
 
886 886
     if ( isset($options["compress"]) && $options["compress"] != 1 )
887
-      $this->_pdf->set_value("compress", 0);
887
+        $this->_pdf->set_value("compress", 0);
888 888
     else
889
-      $this->_pdf->set_value("compress", 6);
889
+        $this->_pdf->set_value("compress", 6);
890 890
 
891 891
     $this->_close();
892 892
 
893 893
     if ( self::$IN_MEMORY ) {
894
-      $data = $this->_pdf->get_buffer();
895
-      $size = strlen($data);
894
+        $data = $this->_pdf->get_buffer();
895
+        $size = strlen($data);
896 896
 
897 897
     } else
898
-      $size = filesize($this->_file);
898
+        $size = filesize($this->_file);
899 899
 
900 900
 
901 901
     $filename = str_replace(array("\n","'"),"", $filename);
@@ -908,63 +908,63 @@  discard block
 block discarded – undo
908 908
     //header("Content-length: " . $size);
909 909
 
910 910
     if ( self::$IN_MEMORY )
911
-      echo $data;
911
+        echo $data;
912 912
 
913 913
     else {
914 914
 
915
-      // Chunked readfile()
916
-      $chunk = (1 << 21); // 2 MB
917
-      $fh = fopen($this->_file, "rb");
918
-      if ( !$fh )
915
+        // Chunked readfile()
916
+        $chunk = (1 << 21); // 2 MB
917
+        $fh = fopen($this->_file, "rb");
918
+        if ( !$fh )
919 919
         throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
920 920
 
921
-      while ( !feof($fh) )
921
+        while ( !feof($fh) )
922 922
         echo fread($fh,$chunk);
923
-      fclose($fh);
923
+        fclose($fh);
924 924
 
925
-      //debugpng
926
-      if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
-      if (!DEBUGKEEPTEMP)
925
+        //debugpng
926
+        if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
+        if (!DEBUGKEEPTEMP)
928 928
 
929
-      unlink($this->_file);
930
-      $this->_file = null;
929
+        unlink($this->_file);
930
+        $this->_file = null;
931 931
     }
932 932
 
933 933
     flush();
934 934
 
935 935
 
936
-  }
936
+    }
937 937
 
938
-  //........................................................................
938
+    //........................................................................
939 939
 
940
-  function output($options = null) {
940
+    function output($options = null) {
941 941
 
942 942
     // Add page text
943 943
     $this->_add_page_text();
944 944
 
945 945
     if ( isset($options["compress"]) && $options["compress"] != 1 )
946
-      $this->_pdf->set_value("compress", 0);
946
+        $this->_pdf->set_value("compress", 0);
947 947
     else
948
-      $this->_pdf->set_value("compress", 6);
948
+        $this->_pdf->set_value("compress", 6);
949 949
 
950 950
     $this->_close();
951 951
 
952 952
     if ( self::$IN_MEMORY )
953
-      $data = $this->_pdf->get_buffer();
953
+        $data = $this->_pdf->get_buffer();
954 954
 
955 955
     else {
956
-      $data = file_get_contents($this->_file);
956
+        $data = file_get_contents($this->_file);
957 957
 
958
-      //debugpng
959
-      if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
-      if (!DEBUGKEEPTEMP)
958
+        //debugpng
959
+        if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
+        if (!DEBUGKEEPTEMP)
961 961
 
962
-      unlink($this->_file);
963
-      $this->_file = null;
962
+        unlink($this->_file);
963
+        $this->_file = null;
964 964
     }
965 965
 
966 966
     return $data;
967
-  }
967
+    }
968 968
 }
969 969
 
970 970
 // Workaround for idiotic limitation on statics...
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_frame_reflower.cls.php 1 patch
Indentation   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
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_frame_reflower.cls.php 219 2010-03-11 23:18:31Z ryan.masten $ */
@@ -47,29 +46,29 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Table_Frame_Reflower extends Frame_Reflower {
49 48
 
50
-  /**
51
-   * Cache of results between call to get_min_max_width and assign_widths
52
-   *
53
-   * @var array
54
-   */
55
-  protected $_state;
49
+    /**
50
+     * Cache of results between call to get_min_max_width and assign_widths
51
+     *
52
+     * @var array
53
+     */
54
+    protected $_state;
56 55
 
57
-  function __construct(Table_Frame_Decorator $frame) {
56
+    function __construct(Table_Frame_Decorator $frame) {
58 57
     $this->_state = null;
59 58
     parent::__construct($frame);
60
-  }
59
+    }
61 60
 
62
-  /**
63
-   * State is held here so it needs to be reset along with the decorator
64
-   */
65
-  function reset() {
61
+    /**
62
+     * State is held here so it needs to be reset along with the decorator
63
+     */
64
+    function reset() {
66 65
     $this->_state = null;
67 66
     $this->_min_max_cache = null;
68
-  }
67
+    }
69 68
 
70
-  //........................................................................
69
+    //........................................................................
71 70
 
72
-  protected function _assign_widths() {
71
+    protected function _assign_widths() {
73 72
     $style = $this->_frame->get_style();
74 73
 
75 74
     // Find the min/max width of the table and sort the columns into
@@ -98,9 +97,9 @@  discard block
 block discarded – undo
98 97
     $right = $right === "auto" ? 0 : $style->length_in_pt($right, $cb["w"]);
99 98
 
100 99
     $delta = $left + $right + $style->length_in_pt(array($style->padding_left,
101
-                                                         $style->border_left_width,
102
-                                                         $style->border_right_width,
103
-                                                         $style->padding_right), $cb["w"]);
100
+                                                            $style->border_left_width,
101
+                                                            $style->border_right_width,
102
+                                                            $style->padding_right), $cb["w"]);
104 103
 
105 104
     $min_table_width = $style->length_in_pt( $style->min_width, $cb["w"] - $delta );
106 105
 
@@ -110,26 +109,26 @@  discard block
 block discarded – undo
110 109
     
111 110
     if ( $width !== "auto" ) {
112 111
 
113
-      $preferred_width = $style->length_in_pt($width, $cb["w"]) - $delta;
112
+        $preferred_width = $style->length_in_pt($width, $cb["w"]) - $delta;
114 113
 
115
-      if ( $preferred_width < $min_table_width )
114
+        if ( $preferred_width < $min_table_width )
116 115
         $preferred_width = $min_table_width;
117 116
 
118
-      if ( $preferred_width > $min_width )
117
+        if ( $preferred_width > $min_width )
119 118
         $width = $preferred_width;
120
-      else
119
+        else
121 120
         $width = $min_width;
122 121
 
123 122
     } else {
124 123
 
125
-      if ( $max_width + $delta < $cb["w"] )
124
+        if ( $max_width + $delta < $cb["w"] )
126 125
         $width = $max_width;
127
-      else if ( $cb["w"] - $delta > $min_width )
126
+        else if ( $cb["w"] - $delta > $min_width )
128 127
         $width = $cb["w"] - $delta;
129
-      else
128
+        else
130 129
         $width = $min_width;
131 130
 
132
-      if ( $width < $min_table_width )
131
+        if ( $width < $min_table_width )
133 132
         $width = $min_table_width;
134 133
 
135 134
     }
@@ -142,68 +141,68 @@  discard block
 block discarded – undo
142 141
     // If the whole table fits on the page, then assign each column it's max width
143 142
     if ( $width == $max_width ) {
144 143
 
145
-      foreach (array_keys($columns) as $i)
144
+        foreach (array_keys($columns) as $i)
146 145
         $cellmap->set_column_width($i, $columns[$i]["max-width"]);
147 146
 
148
-      return;
147
+        return;
149 148
     }
150 149
 
151 150
     // Determine leftover and assign it evenly to all columns
152 151
     if ( $width > $min_width ) {
153 152
 
154
-      // We have four cases to deal with:
155
-      //
156
-      // 1. All columns are auto--no widths have been specified.  In this
157
-      // case we distribute extra space across all columns weighted by max-width.
158
-      //
159
-      // 2. Only absolute widths have been specified.  In this case we
160
-      // distribute any extra space equally among 'width: auto' columns, or all
161
-      // columns if no auto columns have been specified.
162
-      //
163
-      // 3. Only percentage widths have been specified.  In this case we
164
-      // normalize the percentage values and distribute any remaining % to
165
-      // width: auto columns.  We then proceed to assign widths as fractions
166
-      // of the table width.
167
-      //
168
-      // 4. Both absolute and percentage widths have been specified.
169
-
170
-      // Case 1:
171
-      if ( $absolute_used == 0 && $percent_used == 0 ) {
153
+        // We have four cases to deal with:
154
+        //
155
+        // 1. All columns are auto--no widths have been specified.  In this
156
+        // case we distribute extra space across all columns weighted by max-width.
157
+        //
158
+        // 2. Only absolute widths have been specified.  In this case we
159
+        // distribute any extra space equally among 'width: auto' columns, or all
160
+        // columns if no auto columns have been specified.
161
+        //
162
+        // 3. Only percentage widths have been specified.  In this case we
163
+        // normalize the percentage values and distribute any remaining % to
164
+        // width: auto columns.  We then proceed to assign widths as fractions
165
+        // of the table width.
166
+        //
167
+        // 4. Both absolute and percentage widths have been specified.
168
+
169
+        // Case 1:
170
+        if ( $absolute_used == 0 && $percent_used == 0 ) {
172 171
         $increment = $width - $min_width;
173 172
 
174 173
         foreach (array_keys($columns) as $i)
175
-          $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment * ($columns[$i]["max-width"] / $max_width));
174
+            $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment * ($columns[$i]["max-width"] / $max_width));
176 175
         return;
177
-      }
176
+        }
178 177
 
179 178
 
180
-      // Case 2
181
-      if ( $absolute_used > 0 && $percent_used == 0 ) {
179
+        // Case 2
180
+        if ( $absolute_used > 0 && $percent_used == 0 ) {
182 181
 
183 182
         if ( count($auto) > 0 )
184
-          $increment = ($width - $auto_min - $absolute_used) / count($auto);
183
+            $increment = ($width - $auto_min - $absolute_used) / count($auto);
185 184
 
186 185
         // Use the absolutely specified width or the increment
187 186
         foreach (array_keys($columns) as $i) {
188 187
 
189
-          if ( $columns[$i]["absolute"] > 0 && count($auto) )
188
+            if ( $columns[$i]["absolute"] > 0 && count($auto) )
190 189
             $cellmap->set_column_width($i, $columns[$i]["min-width"]);
191
-          else if ( count($auto) ) 
190
+            else if ( count($auto) ) 
192 191
             $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
193
-          else {
192
+            else {
194 193
             // All absolute columns
195 194
             $increment = ($width - $absolute_used) * $columns[$i]["absolute"] / $absolute_used;
196 195
 
197 196
             $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
198
-          }
197
+            }
199 198
 
200 199
         }
201 200
         return;
202
-      }
201
+        }
203 202
 
204 203
 
205
-      // Case 3:
206
-      if ( $absolute_used == 0 && $percent_used > 0 ) {
204
+        // Case 3:
205
+        if ( $absolute_used == 0 && $percent_used > 0 ) {
207 206
 
208 207
         $scale = null;
209 208
         $remaining = null;
@@ -211,99 +210,99 @@  discard block
 block discarded – undo
211 210
         // Scale percent values if the total percentage is > 100, or if all
212 211
         // values are specified as percentages.
213 212
         if ( $percent_used > 100 || count($auto) == 0)
214
-          $scale = 100 / $percent_used;
213
+            $scale = 100 / $percent_used;
215 214
         else
216
-          $scale = 1;
215
+            $scale = 1;
217 216
 
218 217
         // Account for the minimum space used by the unassigned auto columns
219 218
         $used_width = $auto_min;
220 219
 
221 220
         foreach ($percent as $i) {
222
-          $columns[$i]["percent"] *= $scale;
221
+            $columns[$i]["percent"] *= $scale;
223 222
 
224
-          $slack = $width - $used_width;
223
+            $slack = $width - $used_width;
225 224
 
226
-          $w = min($columns[$i]["percent"] * $width/100, $slack);
225
+            $w = min($columns[$i]["percent"] * $width/100, $slack);
227 226
 
228
-          if ( $w < $columns[$i]["min-width"] )
227
+            if ( $w < $columns[$i]["min-width"] )
229 228
             $w = $columns[$i]["min-width"];
230 229
 
231
-          $cellmap->set_column_width($i, $w);
232
-          $used_width += $w;
230
+            $cellmap->set_column_width($i, $w);
231
+            $used_width += $w;
233 232
 
234 233
         }
235 234
 
236 235
         // This works because $used_width includes the min-width of each
237 236
         // unassigned column
238 237
         if ( count($auto) > 0 ) {
239
-          $increment = ($width - $used_width) / count($auto);
238
+            $increment = ($width - $used_width) / count($auto);
240 239
 
241
-          foreach ($auto as $i)
240
+            foreach ($auto as $i)
242 241
             $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
243 242
 
244 243
         }
245 244
         return;
246
-      }
245
+        }
247 246
 
248
-      // Case 4:
247
+        // Case 4:
249 248
 
250
-      // First-come, first served
251
-      if ( $absolute_used > 0 && $percent_used > 0 ) {
249
+        // First-come, first served
250
+        if ( $absolute_used > 0 && $percent_used > 0 ) {
252 251
 
253 252
         $used_width = $auto_min;
254 253
 
255 254
         foreach ($absolute as $i) {
256
-          $cellmap->set_column_width($i, $columns[$i]["min-width"]);
257
-          $used_width +=  $columns[$i]["min-width"];
255
+            $cellmap->set_column_width($i, $columns[$i]["min-width"]);
256
+            $used_width +=  $columns[$i]["min-width"];
258 257
         }
259 258
 
260 259
         // Scale percent values if the total percentage is > 100 or there
261 260
         // are no auto values to take up slack
262 261
         if ( $percent_used > 100 || count($auto) == 0 )
263
-          $scale = 100 / $percent_used;
262
+            $scale = 100 / $percent_used;
264 263
         else
265
-          $scale = 1;
264
+            $scale = 1;
266 265
 
267 266
         $remaining_width = $width - $used_width;
268 267
 
269 268
         foreach ($percent as $i) {
270
-          $slack = $remaining_width - $used_width;
269
+            $slack = $remaining_width - $used_width;
271 270
 
272
-          $columns[$i]["percent"] *= $scale;
273
-          $w = min($columns[$i]["percent"] * $remaining_width / 100, $slack);
271
+            $columns[$i]["percent"] *= $scale;
272
+            $w = min($columns[$i]["percent"] * $remaining_width / 100, $slack);
274 273
 
275
-          if ( $w < $columns[$i]["min-width"] )
274
+            if ( $w < $columns[$i]["min-width"] )
276 275
             $w = $columns[$i]["min-width"];
277 276
 
278
-          $columns[$i]["used-width"] = $w;
279
-          $used_width += $w;
277
+            $columns[$i]["used-width"] = $w;
278
+            $used_width += $w;
280 279
         }
281 280
 
282 281
         if ( count($auto) > 0 ) {
283
-          $increment = ($width - $used_width) / count($auto);
282
+            $increment = ($width - $used_width) / count($auto);
284 283
 
285
-          foreach ($auto as $i)
284
+            foreach ($auto as $i)
286 285
             $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
287 286
 
288 287
         }
289 288
 
290 289
         return;
291
-      }
290
+        }
292 291
 
293 292
 
294 293
     } else { // we are over constrained
295 294
 
296
-      // Each column gets its minimum width
297
-      foreach (array_keys($columns) as $i)
295
+        // Each column gets its minimum width
296
+        foreach (array_keys($columns) as $i)
298 297
         $cellmap->set_column_width($i, $columns[$i]["min-width"]);
299 298
 
300 299
     }
301
-  }
300
+    }
302 301
 
303
-  //........................................................................
302
+    //........................................................................
304 303
 
305
-  // Determine the frame's height based on min/max height
306
-  protected function _calculate_height() {
304
+    // Determine the frame's height based on min/max height
305
+    protected function _calculate_height() {
307 306
 
308 307
     $style = $this->_frame->get_style();
309 308
     $height = $style->height;
@@ -315,67 +314,67 @@  discard block
 block discarded – undo
315 314
     // Determine our content height
316 315
     $content_height = 0;
317 316
     foreach ( $rows as $r )
318
-      $content_height += $r["height"];
317
+        $content_height += $r["height"];
319 318
 
320 319
     $cb = $this->_frame->get_containing_block();
321 320
 
322 321
     if ( !($style->overflow === "visible" ||
323 322
            ($style->overflow === "hidden" && $height === "auto")) ) {
324 323
 
325
-      // Only handle min/max height if the height is independent of the frame's content
324
+        // Only handle min/max height if the height is independent of the frame's content
326 325
 
327
-      $min_height = $style->min_height;
328
-      $max_height = $style->max_height;
326
+        $min_height = $style->min_height;
327
+        $max_height = $style->max_height;
329 328
 
330
-      if ( isset($cb["h"]) ) {
329
+        if ( isset($cb["h"]) ) {
331 330
         $min_height = $style->length_in_pt($min_height, $cb["h"]);
332 331
         $max_height = $style->length_in_pt($max_height, $cb["h"]);
333 332
 
334
-      } else if ( isset($cb["w"]) ) {
333
+        } else if ( isset($cb["w"]) ) {
335 334
 
336 335
         if ( mb_strpos($min_height, "%") !== false )
337
-          $min_height = 0;
336
+            $min_height = 0;
338 337
         else
339
-          $min_height = $style->length_in_pt($min_height, $cb["w"]);
338
+            $min_height = $style->length_in_pt($min_height, $cb["w"]);
340 339
 
341 340
         if ( mb_strpos($max_height, "%") !== false )
342
-          $max_height = "none";
341
+            $max_height = "none";
343 342
         else
344
-          $max_height = $style->length_in_pt($max_height, $cb["w"]);
345
-      }
343
+            $max_height = $style->length_in_pt($max_height, $cb["w"]);
344
+        }
346 345
 
347
-      if ( $max_height !== "none" && $min_height > $max_height )
346
+        if ( $max_height !== "none" && $min_height > $max_height )
348 347
         // Swap 'em
349 348
         list($max_height, $min_height) = array($min_height, $max_height);
350 349
 
351
-      if ( $max_height !== "none" && $height > $max_height )
350
+        if ( $max_height !== "none" && $height > $max_height )
352 351
         $height = $max_height;
353 352
 
354
-      if ( $height < $min_height )
353
+        if ( $height < $min_height )
355 354
         $height = $min_height;
356 355
 
357 356
     } else {
358 357
 
359
-      // Use the content height or the height value, whichever is greater
360
-      if ( $height !== "auto" ) {
358
+        // Use the content height or the height value, whichever is greater
359
+        if ( $height !== "auto" ) {
361 360
         $height = $style->length_in_pt($height, $cb["h"]);
362 361
 
363 362
         if ( $height <= $content_height )
364
-          $height = $content_height;
363
+            $height = $content_height;
365 364
         else
366
-          $cellmap->set_frame_heights($height,$content_height);
365
+            $cellmap->set_frame_heights($height,$content_height);
367 366
 
368
-      } else
367
+        } else
369 368
         $height = $content_height;
370 369
 
371 370
     }
372 371
 
373 372
     return $height;
374 373
 
375
-  }
376
-  //........................................................................
374
+    }
375
+    //........................................................................
377 376
 
378
-  function reflow() {
377
+    function reflow() {
379 378
 
380 379
     // Check if a page break is forced
381 380
     $page = $this->_frame->get_root();
@@ -383,7 +382,7 @@  discard block
 block discarded – undo
383 382
 
384 383
     // Bail if the page is full
385 384
     if ( $page->is_full() )
386
-      return;
385
+        return;
387 386
     
388 387
     // Let the page know that we're reflowing a table so that splits
389 388
     // are suppressed (simply setting page-break-inside: avoid won't
@@ -401,7 +400,7 @@  discard block
 block discarded – undo
401 400
     // http://www.w3.org/TR/CSS21/tables.html#auto-table-layout
402 401
 
403 402
     if ( is_null($this->_state) )
404
-      $this->get_min_max_width();
403
+        $this->get_min_max_width();
405 404
 
406 405
     $cb = $this->_frame->get_containing_block();
407 406
     $style = $this->_frame->get_style();
@@ -410,15 +409,15 @@  discard block
 block discarded – undo
410 409
     // border-spacing to the table as padding.  The other half is added to
411 410
     // the cells themselves.
412 411
     if ( $style->border_collapse === "separate" ) {
413
-      list($h, $v) = $style->border_spacing;
412
+        list($h, $v) = $style->border_spacing;
414 413
 
415
-      $v = $style->length_in_pt($v) / 2;
416
-      $h = $style->length_in_pt($h) / 2;
414
+        $v = $style->length_in_pt($v) / 2;
415
+        $h = $style->length_in_pt($h) / 2;
417 416
 
418
-      $style->padding_left = $style->length_in_pt($style->padding_left, $cb["w"]) + $h;
419
-      $style->padding_right = $style->length_in_pt($style->padding_right, $cb["w"]) + $h;
420
-      $style->padding_top = $style->length_in_pt($style->padding_top, $cb["w"]) + $v;
421
-      $style->padding_bottom = $style->length_in_pt($style->padding_bottom, $cb["w"]) + $v;
417
+        $style->padding_left = $style->length_in_pt($style->padding_left, $cb["w"]) + $h;
418
+        $style->padding_right = $style->length_in_pt($style->padding_right, $cb["w"]) + $h;
419
+        $style->padding_top = $style->length_in_pt($style->padding_top, $cb["w"]) + $v;
420
+        $style->padding_bottom = $style->length_in_pt($style->padding_bottom, $cb["w"]) + $v;
422 421
 
423 422
     }
424 423
 
@@ -432,16 +431,16 @@  discard block
 block discarded – undo
432 431
     $diff = $cb["w"] - $width;
433 432
 
434 433
     if ( $left === "auto" && $right === "auto" && $diff > 0 ) {
435
-      $left = $right = $diff / 2;
436
-      $style->margin_left = "$left pt";
437
-      $style->margin_right = "$right pt";
434
+        $left = $right = $diff / 2;
435
+        $style->margin_left = "$left pt";
436
+        $style->margin_right = "$right pt";
438 437
 
439 438
     } else {
440 439
         if($left === "auto") {
441
-          $left = $style->length_in_pt($cb["w"] - $right - $width, $cb["w"]);
440
+            $left = $style->length_in_pt($cb["w"] - $right - $width, $cb["w"]);
442 441
         }
443 442
         if($right === "auto") {
444
-          $left = $style->length_in_pt($left, $cb["w"]);
443
+            $left = $style->length_in_pt($left, $cb["w"]);
445 444
         }
446 445
     }
447 446
 
@@ -450,15 +449,15 @@  discard block
 block discarded – undo
450 449
 
451 450
     // Determine the content edge
452 451
     $content_x = $x + $left + $style->length_in_pt(array($style->padding_left,
453
-                                                         $style->border_left_width), $cb["w"]);
452
+                                                            $style->border_left_width), $cb["w"]);
454 453
     $content_y = $y + $style->length_in_pt(array($style->margin_top,
455
-                                                 $style->border_top_width,
456
-                                                 $style->padding_top), $cb["w"]);
454
+                                                    $style->border_top_width,
455
+                                                    $style->padding_top), $cb["w"]);
457 456
 
458 457
     if ( isset($cb["h"]) )
459
-      $h = $cb["h"];
458
+        $h = $cb["h"];
460 459
     else
461
-      $h = null;
460
+        $h = null;
462 461
 
463 462
 
464 463
     $cellmap = $this->_frame->get_cellmap();
@@ -473,14 +472,14 @@  discard block
 block discarded – undo
473 472
     // Set the containing block of each child & reflow
474 473
     foreach ( $this->_frame->get_children() as $child ) {
475 474
 
476
-      // Bail if the page is full
477
-      if ( !$page->in_nested_table() && $page->is_full() )
475
+        // Bail if the page is full
476
+        if ( !$page->in_nested_table() && $page->is_full() )
478 477
         break;
479 478
 
480
-      $child->set_containing_block($content_x, $content_y, $width, $h);
481
-      $child->reflow();
479
+        $child->set_containing_block($content_x, $content_y, $width, $h);
480
+        $child->reflow();
482 481
 
483
-      if ( !$page->in_nested_table() )
482
+        if ( !$page->in_nested_table() )
484 483
         // Check if a split has occured
485 484
         $page->check_page_break($child);
486 485
 
@@ -490,22 +489,22 @@  discard block
 block discarded – undo
490 489
     $style->height = $this->_calculate_height();
491 490
 
492 491
     if ( $style->border_collapse === "collapse" ) {
493
-      // Unset our borders because our cells are now using them
494
-      $style->border_style = "none";
492
+        // Unset our borders because our cells are now using them
493
+        $style->border_style = "none";
495 494
     }
496 495
 
497 496
     $page->table_reflow_end();
498 497
 
499 498
     // Debugging:
500 499
     //echo ($this->_frame->get_cellmap());
501
-  }
500
+    }
502 501
 
503
-  //........................................................................
502
+    //........................................................................
504 503
 
505
-  function get_min_max_width() {
504
+    function get_min_max_width() {
506 505
 
507 506
     if ( !is_null($this->_min_max_cache)  )
508
-      return $this->_min_max_cache;
507
+        return $this->_min_max_cache;
509 508
 
510 509
     $style = $this->_frame->get_style();
511 510
 
@@ -531,33 +530,33 @@  discard block
 block discarded – undo
531 530
 
532 531
     $columns =& $this->_frame->get_cellmap()->get_columns();
533 532
     foreach (array_keys($columns) as $i) {
534
-      $this->_state["min_width"] += $columns[$i]["min-width"];
535
-      $this->_state["max_width"] += $columns[$i]["max-width"];
533
+        $this->_state["min_width"] += $columns[$i]["min-width"];
534
+        $this->_state["max_width"] += $columns[$i]["max-width"];
536 535
 
537
-      if ( $columns[$i]["absolute"] > 0 ) {
536
+        if ( $columns[$i]["absolute"] > 0 ) {
538 537
         $this->_state["absolute"][] = $i;
539 538
         $this->_state["absolute_used"] += $columns[$i]["absolute"];
540 539
 
541
-      } else if ( $columns[$i]["percent"] > 0 ) {
540
+        } else if ( $columns[$i]["percent"] > 0 ) {
542 541
         $this->_state["percent"][] = $i;
543 542
         $this->_state["percent_used"] += $columns[$i]["percent"];
544 543
 
545
-      } else {
544
+        } else {
546 545
         $this->_state["auto"][] = $i;
547 546
         $this->_state["auto_min"] += $columns[$i]["min-width"];
548
-      }
547
+        }
549 548
     }
550 549
 
551 550
     // Account for margins & padding
552 551
     $dims = array($style->border_left_width,
553
-                  $style->border_right_width,
554
-                  $style->padding_left,
555
-                  $style->padding_right,
556
-                  $style->margin_left,
557
-                  $style->margin_right);
552
+                    $style->border_right_width,
553
+                    $style->padding_left,
554
+                    $style->padding_right,
555
+                    $style->margin_left,
556
+                    $style->margin_right);
558 557
 
559 558
     if ( $style->border_collapse !== "collapse" ) 
560
-      list($dims[]) = $style->border_spacing;
559
+        list($dims[]) = $style->border_spacing;
561 560
 
562 561
     $delta = $style->length_in_pt($dims, $this->_frame->get_containing_block("w"));
563 562
 
@@ -565,6 +564,6 @@  discard block
 block discarded – undo
565 564
     $this->_state["max_width"] += $delta;
566 565
 
567 566
     return $this->_min_max_cache = array($this->_state["min_width"], $this->_state["max_width"],
568
-                 "min" => $this->_state["min_width"], "max" => $this->_state["max_width"]);
569
-  }
567
+                    "min" => $this->_state["min_width"], "max" => $this->_state["max_width"]);
568
+    }
570 569
 }
Please login to merge, or discard this patch.