@@ -47,20 +47,20 @@ |
||
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 | } |
@@ -52,34 +52,34 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -52,119 +51,119 @@ discard block |
||
52 | 51 | */ |
53 | 52 | class Frame_Factory { |
54 | 53 | |
55 | - static function decorate_root(Frame $root, DOMPDF $dompdf) { |
|
54 | + static function decorate_root(Frame $root, DOMPDF $dompdf) { |
|
56 | 55 | $frame = new Page_Frame_Decorator($root, $dompdf); |
57 | 56 | $frame->set_reflower( new Page_Frame_Reflower($frame) ); |
58 | 57 | $root->set_decorator($frame); |
59 | 58 | return $frame; |
60 | - } |
|
59 | + } |
|
61 | 60 | |
62 | - // FIXME: this is admittedly a little smelly... |
|
63 | - static function decorate_frame(Frame $frame, $dompdf) { |
|
61 | + // FIXME: this is admittedly a little smelly... |
|
62 | + static function decorate_frame(Frame $frame, $dompdf) { |
|
64 | 63 | if ( is_null($dompdf) ) |
65 | - throw new Exception("foo"); |
|
64 | + throw new Exception("foo"); |
|
66 | 65 | switch ($frame->get_style()->display) { |
67 | 66 | |
68 | 67 | case "block": |
69 | 68 | $positioner = "Block"; |
70 | - $decorator = "Block"; |
|
71 | - $reflower = "Block"; |
|
72 | - break; |
|
69 | + $decorator = "Block"; |
|
70 | + $reflower = "Block"; |
|
71 | + break; |
|
73 | 72 | |
74 | 73 | case "inline-block": |
75 | 74 | $positioner = "Inline"; |
76 | - $decorator = "Block"; |
|
77 | - $reflower = "Block"; |
|
78 | - break; |
|
75 | + $decorator = "Block"; |
|
76 | + $reflower = "Block"; |
|
77 | + break; |
|
79 | 78 | |
80 | 79 | case "inline": |
81 | 80 | $positioner = "Inline"; |
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
81 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | 82 | $decorator = "Text"; |
84 | 83 | $reflower = "Text"; |
85 | - } else { |
|
84 | + } else { |
|
86 | 85 | $decorator = "Inline"; |
87 | 86 | $reflower = "Inline"; |
88 | - } |
|
89 | - break; |
|
87 | + } |
|
88 | + break; |
|
90 | 89 | |
91 | 90 | case "table": |
92 | 91 | $positioner = "Block"; |
93 | - $decorator = "Table"; |
|
94 | - $reflower = "Table"; |
|
95 | - break; |
|
92 | + $decorator = "Table"; |
|
93 | + $reflower = "Table"; |
|
94 | + break; |
|
96 | 95 | |
97 | 96 | case "inline-table": |
98 | 97 | $positioner = "Inline"; |
99 | - $decorator = "Table"; |
|
100 | - $reflower = "Table"; |
|
101 | - break; |
|
98 | + $decorator = "Table"; |
|
99 | + $reflower = "Table"; |
|
100 | + break; |
|
102 | 101 | |
103 | 102 | case "table-row-group": |
104 | 103 | case "table-header-group": |
105 | 104 | case "table-footer-group": |
106 | 105 | $positioner = "Null"; |
107 | - $decorator = "Table_Row_Group"; |
|
108 | - $reflower = "Table_Row_Group"; |
|
109 | - break; |
|
106 | + $decorator = "Table_Row_Group"; |
|
107 | + $reflower = "Table_Row_Group"; |
|
108 | + break; |
|
110 | 109 | |
111 | 110 | case "table-row": |
112 | 111 | $positioner = "Null"; |
113 | - $decorator = "Table_Row"; |
|
114 | - $reflower = "Table_Row"; |
|
115 | - break; |
|
112 | + $decorator = "Table_Row"; |
|
113 | + $reflower = "Table_Row"; |
|
114 | + break; |
|
116 | 115 | |
117 | 116 | case "table-cell": |
118 | 117 | $positioner = "Table_Cell"; |
119 | - $decorator = "Table_Cell"; |
|
120 | - $reflower = "Table_Cell"; |
|
121 | - break; |
|
118 | + $decorator = "Table_Cell"; |
|
119 | + $reflower = "Table_Cell"; |
|
120 | + break; |
|
122 | 121 | |
123 | 122 | case "list-item": |
124 | 123 | $positioner = "Block"; |
125 | - $decorator = "Block"; |
|
126 | - $reflower = "Block"; |
|
127 | - break; |
|
124 | + $decorator = "Block"; |
|
125 | + $reflower = "Block"; |
|
126 | + break; |
|
128 | 127 | |
129 | 128 | case "-dompdf-list-bullet": |
130 | 129 | if ( $frame->get_style()->list_style_position === "inside" ) |
131 | 130 | $positioner = "Inline"; |
132 | - else |
|
131 | + else |
|
133 | 132 | $positioner = "List_Bullet"; |
134 | 133 | |
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
134 | + if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | 135 | $decorator = "List_Bullet_Image"; |
137 | - else |
|
136 | + else |
|
138 | 137 | $decorator = "List_Bullet"; |
139 | 138 | |
140 | - $reflower = "List_Bullet"; |
|
141 | - break; |
|
139 | + $reflower = "List_Bullet"; |
|
140 | + break; |
|
142 | 141 | |
143 | 142 | case "-dompdf-image": |
144 | 143 | $positioner = "Inline"; |
145 | - $decorator = "Image"; |
|
146 | - $reflower = "Image"; |
|
147 | - break; |
|
144 | + $decorator = "Image"; |
|
145 | + $reflower = "Image"; |
|
146 | + break; |
|
148 | 147 | |
149 | 148 | case "-dompdf-br": |
150 | 149 | $positioner = "Inline"; |
151 | - $decorator = "Inline"; |
|
152 | - $reflower = "Inline"; |
|
153 | - break; |
|
150 | + $decorator = "Inline"; |
|
151 | + $reflower = "Inline"; |
|
152 | + break; |
|
154 | 153 | |
155 | 154 | default: |
156 | 155 | // FIXME: should throw some sort of warning or something? |
157 | 156 | case "none": |
158 | 157 | $positioner = "Null"; |
159 | - $decorator = "Null"; |
|
160 | - $reflower = "Null"; |
|
161 | - break; |
|
158 | + $decorator = "Null"; |
|
159 | + $reflower = "Null"; |
|
160 | + break; |
|
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | 164 | if ( $frame->get_style()->position === "absolute" || |
166 | 165 | $frame->get_style()->position === "fixed" ) |
167 | - $positioner = "Absolute"; |
|
166 | + $positioner = "Absolute"; |
|
168 | 167 | |
169 | 168 | $positioner .= "_Positioner"; |
170 | 169 | $decorator .= "_Frame_Decorator"; |
@@ -176,10 +175,10 @@ discard block |
||
176 | 175 | |
177 | 176 | // Generated content is a special case |
178 | 177 | if ( $frame->get_node()->nodeName === "_dompdf_generated" ) { |
179 | - // Decorate the reflower |
|
180 | - $gen = new Generated_Frame_Reflower( $deco ); |
|
181 | - $gen->set_reflower( $reflow ); |
|
182 | - $reflow = $gen; |
|
178 | + // Decorate the reflower |
|
179 | + $gen = new Generated_Frame_Reflower( $deco ); |
|
180 | + $gen->set_reflower( $reflow ); |
|
181 | + $reflow = $gen; |
|
183 | 182 | } |
184 | 183 | |
185 | 184 | $deco->set_reflower( $reflow ); |
@@ -204,6 +203,6 @@ discard block |
||
204 | 203 | // } |
205 | 204 | |
206 | 205 | return $deco; |
207 | - } |
|
206 | + } |
|
208 | 207 | |
209 | 208 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,62 +46,62 @@ discard block |
||
47 | 46 | */ |
48 | 47 | abstract class Frame_Decorator extends Frame { |
49 | 48 | |
50 | - /** |
|
51 | - * The root node of the DOM tree |
|
52 | - * |
|
53 | - * @var Frame |
|
54 | - */ |
|
55 | - protected $_root; |
|
56 | - |
|
57 | - /** |
|
58 | - * The decorated frame |
|
59 | - * |
|
60 | - * @var Frame |
|
61 | - */ |
|
62 | - protected $_frame; |
|
63 | - |
|
64 | - /** |
|
65 | - * Positioner object used to position this frame (Strategy pattern) |
|
66 | - * |
|
67 | - * @var Positioner |
|
68 | - */ |
|
69 | - protected $_positioner; |
|
70 | - |
|
71 | - /** |
|
72 | - * Reflower object used to calculate frame dimensions (Strategy pattern) |
|
73 | - * |
|
74 | - * @var Frame_Reflower |
|
75 | - */ |
|
76 | - protected $_reflower; |
|
49 | + /** |
|
50 | + * The root node of the DOM tree |
|
51 | + * |
|
52 | + * @var Frame |
|
53 | + */ |
|
54 | + protected $_root; |
|
55 | + |
|
56 | + /** |
|
57 | + * The decorated frame |
|
58 | + * |
|
59 | + * @var Frame |
|
60 | + */ |
|
61 | + protected $_frame; |
|
62 | + |
|
63 | + /** |
|
64 | + * Positioner object used to position this frame (Strategy pattern) |
|
65 | + * |
|
66 | + * @var Positioner |
|
67 | + */ |
|
68 | + protected $_positioner; |
|
69 | + |
|
70 | + /** |
|
71 | + * Reflower object used to calculate frame dimensions (Strategy pattern) |
|
72 | + * |
|
73 | + * @var Frame_Reflower |
|
74 | + */ |
|
75 | + protected $_reflower; |
|
77 | 76 | |
78 | - /** |
|
79 | - * Reference to the current dompdf instance |
|
80 | - * |
|
81 | - * @var DOMPDF |
|
82 | - */ |
|
83 | - protected $_dompdf; |
|
84 | - |
|
85 | - /** |
|
86 | - * Class constructor |
|
87 | - * |
|
88 | - * @param Frame $frame the decoration target |
|
89 | - */ |
|
90 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
77 | + /** |
|
78 | + * Reference to the current dompdf instance |
|
79 | + * |
|
80 | + * @var DOMPDF |
|
81 | + */ |
|
82 | + protected $_dompdf; |
|
83 | + |
|
84 | + /** |
|
85 | + * Class constructor |
|
86 | + * |
|
87 | + * @param Frame $frame the decoration target |
|
88 | + */ |
|
89 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
91 | 90 | $this->_frame = $frame; |
92 | 91 | $this->_root = null; |
93 | 92 | $this->_dompdf = $dompdf; |
94 | 93 | $frame->set_decorator($this); |
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * "Destructor": foribly free all references held by this object |
|
99 | - * |
|
100 | - * @param bool $recursive if true, call dispose on all children |
|
101 | - */ |
|
102 | - function dispose($recursive = false) { |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * "Destructor": foribly free all references held by this object |
|
98 | + * |
|
99 | + * @param bool $recursive if true, call dispose on all children |
|
100 | + */ |
|
101 | + function dispose($recursive = false) { |
|
103 | 102 | |
104 | 103 | if ( $recursive ) { |
105 | - while ( $child = $this->get_first_child() ) |
|
104 | + while ( $child = $this->get_first_child() ) |
|
106 | 105 | $child->dispose(true); |
107 | 106 | } |
108 | 107 | |
@@ -112,52 +111,52 @@ discard block |
||
112 | 111 | unset($this->_positioner); |
113 | 112 | unset($this->_reflower); |
114 | 113 | |
115 | - } |
|
114 | + } |
|
116 | 115 | |
117 | - // Return a copy of this frame with $node as its node |
|
118 | - function copy(DomNode $node) { |
|
116 | + // Return a copy of this frame with $node as its node |
|
117 | + function copy(DomNode $node) { |
|
119 | 118 | $frame = new Frame($node); |
120 | 119 | $frame->set_style(clone $this->_frame->get_original_style()); |
121 | 120 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
122 | 121 | $deco->set_root($this->_root); |
123 | 122 | return $deco; |
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Create a deep copy: copy this node and all children |
|
128 | - * |
|
129 | - * @return Frame |
|
130 | - */ |
|
131 | - function deep_copy() { |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Create a deep copy: copy this node and all children |
|
127 | + * |
|
128 | + * @return Frame |
|
129 | + */ |
|
130 | + function deep_copy() { |
|
132 | 131 | $frame = new Frame($this->get_node()->cloneNode()); |
133 | 132 | $frame->set_style(clone $this->_frame->get_original_style()); |
134 | 133 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
135 | 134 | $deco->set_root($this->_root); |
136 | 135 | |
137 | 136 | foreach ($this->get_children() as $child) |
138 | - $deco->append_child($child->deep_copy()); |
|
137 | + $deco->append_child($child->deep_copy()); |
|
139 | 138 | |
140 | 139 | return $deco; |
141 | - } |
|
142 | - //........................................................................ |
|
140 | + } |
|
141 | + //........................................................................ |
|
143 | 142 | |
144 | - // Delegate calls to decorated frame object |
|
145 | - function reset() { |
|
143 | + // Delegate calls to decorated frame object |
|
144 | + function reset() { |
|
146 | 145 | $this->_frame->reset(); |
147 | 146 | |
148 | 147 | // Reset all children |
149 | 148 | foreach ($this->get_children() as $child) |
150 | - $child->reset(); |
|
149 | + $child->reset(); |
|
151 | 150 | |
152 | - } |
|
151 | + } |
|
153 | 152 | |
154 | - function get_node() { return $this->_frame->get_node(); } |
|
155 | - function get_id() { return $this->_frame->get_id(); } |
|
156 | - function get_style() { return $this->_frame->get_style(); } |
|
157 | - function get_original_style() { return $this->_frame->get_original_style(); } |
|
158 | - function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
|
159 | - function get_position($i = null) { return $this->_frame->get_position($i); } |
|
160 | - function get_dompdf() { return $this->_dompdf; } |
|
153 | + function get_node() { return $this->_frame->get_node(); } |
|
154 | + function get_id() { return $this->_frame->get_id(); } |
|
155 | + function get_style() { return $this->_frame->get_style(); } |
|
156 | + function get_original_style() { return $this->_frame->get_original_style(); } |
|
157 | + function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
|
158 | + function get_position($i = null) { return $this->_frame->get_position($i); } |
|
159 | + function get_dompdf() { return $this->_dompdf; } |
|
161 | 160 | // function get_decorator() { |
162 | 161 | // if ( isset($this->_decorator) ) |
163 | 162 | // return $this->_decorator; |
@@ -165,201 +164,201 @@ discard block |
||
165 | 164 | // return $this; |
166 | 165 | // } |
167 | 166 | |
168 | - function get_margin_height() { return $this->_frame->get_margin_height(); } |
|
169 | - function get_margin_width() { return $this->_frame->get_margin_width(); } |
|
170 | - function get_padding_box() { return $this->_frame->get_padding_box(); } |
|
171 | - function get_border_box() { return $this->_frame->get_border_box(); } |
|
167 | + function get_margin_height() { return $this->_frame->get_margin_height(); } |
|
168 | + function get_margin_width() { return $this->_frame->get_margin_width(); } |
|
169 | + function get_padding_box() { return $this->_frame->get_padding_box(); } |
|
170 | + function get_border_box() { return $this->_frame->get_border_box(); } |
|
172 | 171 | |
173 | - function set_id($id) { $this->_frame->set_id($id); } |
|
174 | - function set_style(Style $style) { $this->_frame->set_style($style); } |
|
172 | + function set_id($id) { $this->_frame->set_id($id); } |
|
173 | + function set_style(Style $style) { $this->_frame->set_style($style); } |
|
175 | 174 | |
176 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
175 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
177 | 176 | $this->_frame->set_containing_block($x, $y, $w, $h); |
178 | - } |
|
177 | + } |
|
179 | 178 | |
180 | - function set_position($x = null, $y = null) { |
|
179 | + function set_position($x = null, $y = null) { |
|
181 | 180 | $this->_frame->set_position($x, $y); |
182 | - } |
|
183 | - function __toString() { return $this->_frame->__toString(); } |
|
181 | + } |
|
182 | + function __toString() { return $this->_frame->__toString(); } |
|
184 | 183 | |
185 | - function prepend_child(Frame $child, $update_node = true) { |
|
184 | + function prepend_child(Frame $child, $update_node = true) { |
|
186 | 185 | while ( $child instanceof Frame_Decorator ) |
187 | - $child = $child->_frame; |
|
186 | + $child = $child->_frame; |
|
188 | 187 | |
189 | 188 | $this->_frame->prepend_child($child, $update_node); |
190 | - } |
|
189 | + } |
|
191 | 190 | |
192 | - function append_child(Frame $child, $update_node = true) { |
|
191 | + function append_child(Frame $child, $update_node = true) { |
|
193 | 192 | while ( $child instanceof Frame_Decorator ) |
194 | - $child = $child->_frame; |
|
193 | + $child = $child->_frame; |
|
195 | 194 | |
196 | 195 | $this->_frame->append_child($child, $update_node); |
197 | - } |
|
196 | + } |
|
198 | 197 | |
199 | - function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
198 | + function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
200 | 199 | while ( $new_child instanceof Frame_Decorator ) |
201 | - $new_child = $new_child->_frame; |
|
200 | + $new_child = $new_child->_frame; |
|
202 | 201 | |
203 | 202 | if ( $ref instanceof Frame_Decorator ) |
204 | - $ref = $ref->_frame; |
|
203 | + $ref = $ref->_frame; |
|
205 | 204 | |
206 | 205 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | - } |
|
206 | + } |
|
208 | 207 | |
209 | - function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
208 | + function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
210 | 209 | while ( $new_child instanceof Frame_Decorator ) |
211 | - $new_child = $new_child->_frame; |
|
210 | + $new_child = $new_child->_frame; |
|
212 | 211 | |
213 | 212 | while ( $ref instanceof Frame_Decorator ) |
214 | - $ref = $ref->_frame; |
|
213 | + $ref = $ref->_frame; |
|
215 | 214 | |
216 | 215 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | - } |
|
216 | + } |
|
218 | 217 | |
219 | - function remove_child(Frame $child, $update_node = true) { |
|
218 | + function remove_child(Frame $child, $update_node = true) { |
|
220 | 219 | while ( $child instanceof Frame_Decorator ) |
221 | - $child = $new_child->_frame; |
|
220 | + $child = $new_child->_frame; |
|
222 | 221 | |
223 | 222 | $this->_frame->remove_child($child, $update_node); |
224 | - } |
|
223 | + } |
|
225 | 224 | |
226 | - //........................................................................ |
|
225 | + //........................................................................ |
|
227 | 226 | |
228 | - function get_parent() { |
|
227 | + function get_parent() { |
|
229 | 228 | |
230 | 229 | $p = $this->_frame->get_parent(); |
231 | 230 | |
232 | 231 | if ( $p && $deco = $p->get_decorator() ) { |
233 | - while ( $tmp = $deco->get_decorator() ) |
|
232 | + while ( $tmp = $deco->get_decorator() ) |
|
234 | 233 | $deco = $tmp; |
235 | - return $deco; |
|
234 | + return $deco; |
|
236 | 235 | } else if ( $p ) |
237 | - return $p; |
|
236 | + return $p; |
|
238 | 237 | else |
239 | - return null; |
|
240 | - } |
|
238 | + return null; |
|
239 | + } |
|
241 | 240 | |
242 | - function get_first_child() { |
|
241 | + function get_first_child() { |
|
243 | 242 | $c = $this->_frame->get_first_child(); |
244 | 243 | if ( $c && $deco = $c->get_decorator() ) { |
245 | - while ( $tmp = $deco->get_decorator() ) |
|
244 | + while ( $tmp = $deco->get_decorator() ) |
|
246 | 245 | $deco = $tmp; |
247 | - return $deco; |
|
246 | + return $deco; |
|
248 | 247 | } else if ( $c ) |
249 | - return $c; |
|
248 | + return $c; |
|
250 | 249 | else |
251 | - return null; |
|
252 | - } |
|
250 | + return null; |
|
251 | + } |
|
253 | 252 | |
254 | - function get_last_child() { |
|
253 | + function get_last_child() { |
|
255 | 254 | $c = $this->_frame->get_last_child(); |
256 | 255 | if ( $c && $deco = $c->get_decorator() ) { |
257 | - while ( $tmp = $deco->get_decorator() ) |
|
256 | + while ( $tmp = $deco->get_decorator() ) |
|
258 | 257 | $deco = $tmp; |
259 | - return $deco; |
|
258 | + return $deco; |
|
260 | 259 | } else if ( $c ) |
261 | - return $c; |
|
260 | + return $c; |
|
262 | 261 | else |
263 | - return null; |
|
264 | - } |
|
262 | + return null; |
|
263 | + } |
|
265 | 264 | |
266 | - function get_prev_sibling() { |
|
265 | + function get_prev_sibling() { |
|
267 | 266 | $s = $this->_frame->get_prev_sibling(); |
268 | 267 | if ( $s && $deco = $s->get_decorator() ) { |
269 | - while ( $tmp = $deco->get_decorator() ) |
|
268 | + while ( $tmp = $deco->get_decorator() ) |
|
270 | 269 | $deco = $tmp; |
271 | - return $deco; |
|
270 | + return $deco; |
|
272 | 271 | } else if ( $s ) |
273 | - return $s; |
|
272 | + return $s; |
|
274 | 273 | else |
275 | - return null; |
|
276 | - } |
|
274 | + return null; |
|
275 | + } |
|
277 | 276 | |
278 | - function get_next_sibling() { |
|
277 | + function get_next_sibling() { |
|
279 | 278 | $s = $this->_frame->get_next_sibling(); |
280 | 279 | if ( $s && $deco = $s->get_decorator() ) { |
281 | - while ( $tmp = $deco->get_decorator() ) |
|
280 | + while ( $tmp = $deco->get_decorator() ) |
|
282 | 281 | $deco = $tmp; |
283 | - return $deco; |
|
282 | + return $deco; |
|
284 | 283 | } else if ( $s ) |
285 | - return $s; |
|
284 | + return $s; |
|
286 | 285 | else |
287 | - return null; |
|
288 | - } |
|
286 | + return null; |
|
287 | + } |
|
289 | 288 | |
290 | - function get_children() { |
|
289 | + function get_children() { |
|
291 | 290 | return new FrameList($this); |
292 | - } |
|
291 | + } |
|
293 | 292 | |
294 | - function get_subtree() { |
|
293 | + function get_subtree() { |
|
295 | 294 | return new FrameTreeList($this); |
296 | - } |
|
295 | + } |
|
297 | 296 | |
298 | - //........................................................................ |
|
297 | + //........................................................................ |
|
299 | 298 | |
300 | - function set_positioner(Positioner $posn) { |
|
299 | + function set_positioner(Positioner $posn) { |
|
301 | 300 | $this->_positioner = $posn; |
302 | 301 | if ( $this->_frame instanceof Frame_Decorator ) |
303 | - $this->_frame->set_positioner($posn); |
|
304 | - } |
|
302 | + $this->_frame->set_positioner($posn); |
|
303 | + } |
|
305 | 304 | |
306 | - //........................................................................ |
|
305 | + //........................................................................ |
|
307 | 306 | |
308 | - function set_reflower(Frame_Reflower $reflower) { |
|
307 | + function set_reflower(Frame_Reflower $reflower) { |
|
309 | 308 | $this->_reflower = $reflower; |
310 | 309 | if ( $this->_frame instanceof Frame_Decorator ) |
311 | - $this->_frame->set_reflower( $reflower ); |
|
312 | - } |
|
310 | + $this->_frame->set_reflower( $reflower ); |
|
311 | + } |
|
313 | 312 | |
314 | - function get_reflower() { return $this->_reflower; } |
|
313 | + function get_reflower() { return $this->_reflower; } |
|
315 | 314 | |
316 | - //........................................................................ |
|
315 | + //........................................................................ |
|
317 | 316 | |
318 | - function set_root(Frame $root) { |
|
317 | + function set_root(Frame $root) { |
|
319 | 318 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
319 | + if ( $this->_frame instanceof Frame_Decorator ) |
|
321 | 320 | $this->_frame->set_root($root); |
322 | - } |
|
321 | + } |
|
323 | 322 | |
324 | - function get_root() { return $this->_root; } |
|
323 | + function get_root() { return $this->_root; } |
|
325 | 324 | |
326 | - //........................................................................ |
|
325 | + //........................................................................ |
|
327 | 326 | |
328 | - function find_block_parent() { |
|
327 | + function find_block_parent() { |
|
329 | 328 | |
330 | 329 | // Find our nearest block level parent |
331 | 330 | $p = $this->get_parent(); |
332 | 331 | |
333 | 332 | while ( $p ) { |
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
333 | + if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
335 | 334 | break; |
336 | 335 | |
337 | - $p = $p->get_parent(); |
|
336 | + $p = $p->get_parent(); |
|
338 | 337 | } |
339 | 338 | |
340 | 339 | return $p; |
341 | - } |
|
340 | + } |
|
342 | 341 | |
343 | - //........................................................................ |
|
342 | + //........................................................................ |
|
344 | 343 | |
345 | - /** |
|
346 | - * split this frame at $child. |
|
347 | - * |
|
348 | - * The current frame is cloned and $child and all children following |
|
349 | - * $child are added to the clone. The clone is then passed to the |
|
350 | - * current frame's parent->split() method. |
|
351 | - * |
|
352 | - * @param Frame $child |
|
353 | - */ |
|
354 | - function split($child = null) { |
|
344 | + /** |
|
345 | + * split this frame at $child. |
|
346 | + * |
|
347 | + * The current frame is cloned and $child and all children following |
|
348 | + * $child are added to the clone. The clone is then passed to the |
|
349 | + * current frame's parent->split() method. |
|
350 | + * |
|
351 | + * @param Frame $child |
|
352 | + */ |
|
353 | + function split($child = null) { |
|
355 | 354 | |
356 | 355 | if ( is_null( $child ) ) { |
357 | - $this->get_parent()->split($this); |
|
358 | - return; |
|
356 | + $this->get_parent()->split($this); |
|
357 | + return; |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | if ( $child->get_parent() !== $this ) |
362 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
361 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
363 | 362 | |
364 | 363 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
365 | 364 | $split->reset(); |
@@ -368,29 +367,29 @@ discard block |
||
368 | 367 | // Add $frame and all following siblings to the new split node |
369 | 368 | $iter = $child; |
370 | 369 | while ($iter) { |
371 | - $frame = $iter; |
|
372 | - $iter = $iter->get_next_sibling(); |
|
373 | - $frame->reset(); |
|
374 | - $split->append_child($frame); |
|
370 | + $frame = $iter; |
|
371 | + $iter = $iter->get_next_sibling(); |
|
372 | + $frame->reset(); |
|
373 | + $split->append_child($frame); |
|
375 | 374 | } |
376 | 375 | |
377 | 376 | $this->get_parent()->split($split); |
378 | - } |
|
377 | + } |
|
379 | 378 | |
380 | - //........................................................................ |
|
379 | + //........................................................................ |
|
381 | 380 | |
382 | - final function position() { $this->_positioner->position(); } |
|
381 | + final function position() { $this->_positioner->position(); } |
|
383 | 382 | |
384 | - final function reflow() { |
|
383 | + final function reflow() { |
|
385 | 384 | // Uncomment this to see the frames before they're laid out, instead of |
386 | 385 | // during rendering. |
387 | 386 | //echo $this->_frame; flush(); |
388 | 387 | $this->_reflower->reflow(); |
389 | - } |
|
388 | + } |
|
390 | 389 | |
391 | - final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); } |
|
390 | + final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); } |
|
392 | 391 | |
393 | - //........................................................................ |
|
392 | + //........................................................................ |
|
394 | 393 | |
395 | 394 | |
396 | 395 | } |
@@ -35,7 +35,6 @@ discard block |
||
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @contributor Helmut Tischer <[email protected]> |
37 | 37 | * @package dompdf |
38 | - |
|
39 | 38 | * |
40 | 39 | * Changes |
41 | 40 | * @contributor Helmut Tischer <[email protected]> |
@@ -54,34 +53,34 @@ discard block |
||
54 | 53 | */ |
55 | 54 | class Text_Renderer extends Abstract_Renderer { |
56 | 55 | |
57 | - const DECO_THICKNESS = 0.04; // Thickness of underline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | - |
|
59 | - //Tweaking if $base and $descent are not accurate. |
|
60 | - //Check method_exists( $this->_canvas, "get_cpdf" ) |
|
61 | - //- For cpdf these can and must stay 0, because font metrics are used directly. |
|
62 | - //- For other renderers, if different values are wanted, separate the parameter sets. |
|
63 | - // But $size and $size-$height seem to be accurate enough |
|
64 | - const UNDERLINE_OFFSET = 0.0; // Relative to bottom of text, as fraction of height. |
|
65 | - const OVERLINE_OFFSET = 0.0; // Relative to top of text |
|
66 | - const LINETHROUGH_OFFSET = 0.0; // Relative to centre of text. |
|
67 | - const DECO_EXTENSION = 0.0; // How far to extend lines past either end, in pt |
|
56 | + const DECO_THICKNESS = 0.04; // Thickness of underline. Screen: 0.08, print: better less, e.g. 0.04 |
|
57 | + |
|
58 | + //Tweaking if $base and $descent are not accurate. |
|
59 | + //Check method_exists( $this->_canvas, "get_cpdf" ) |
|
60 | + //- For cpdf these can and must stay 0, because font metrics are used directly. |
|
61 | + //- For other renderers, if different values are wanted, separate the parameter sets. |
|
62 | + // But $size and $size-$height seem to be accurate enough |
|
63 | + const UNDERLINE_OFFSET = 0.0; // Relative to bottom of text, as fraction of height. |
|
64 | + const OVERLINE_OFFSET = 0.0; // Relative to top of text |
|
65 | + const LINETHROUGH_OFFSET = 0.0; // Relative to centre of text. |
|
66 | + const DECO_EXTENSION = 0.0; // How far to extend lines past either end, in pt |
|
68 | 67 | |
69 | - //........................................................................ |
|
68 | + //........................................................................ |
|
70 | 69 | |
71 | - function render(Frame $frame) { |
|
70 | + function render(Frame $frame) { |
|
72 | 71 | |
73 | 72 | $style = $frame->get_style(); |
74 | 73 | list($x, $y) = $frame->get_position(); |
75 | 74 | $cb = $frame->get_containing_block(); |
76 | 75 | |
77 | 76 | if ( ($ml = $style->margin_left) === "auto" || $ml === "none" ) |
78 | - $ml = 0; |
|
77 | + $ml = 0; |
|
79 | 78 | |
80 | 79 | if ( ($pl = $style->padding_left) === "auto" || $pl === "none" ) |
81 | - $pl = 0; |
|
80 | + $pl = 0; |
|
82 | 81 | |
83 | 82 | if ( ($bl = $style->border_left_width) === "auto" || $bl === "none" ) |
84 | - $bl = 0; |
|
83 | + $bl = 0; |
|
85 | 84 | |
86 | 85 | $x += $style->length_in_pt( array($ml, $pl, $bl), $cb["w"] ); |
87 | 86 | |
@@ -96,19 +95,19 @@ discard block |
||
96 | 95 | // return; |
97 | 96 | |
98 | 97 | $this->_canvas->text($x, $y, $text, |
99 | - $font, $size, |
|
100 | - $style->color, $spacing); |
|
98 | + $font, $size, |
|
99 | + $style->color, $spacing); |
|
101 | 100 | |
102 | 101 | if ( method_exists( $this->_canvas, "get_cpdf" ) ) { |
103 | - $base = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][3]*$size)/1000; |
|
104 | - $descent = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][1]*$size)/1000; |
|
105 | - //print '<pre>Text_Renderer cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
|
102 | + $base = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][3]*$size)/1000; |
|
103 | + $descent = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][1]*$size)/1000; |
|
104 | + //print '<pre>Text_Renderer cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
|
106 | 105 | } else { |
107 | - //Descent is font part below baseline, typically negative. $height is about full height of font box. |
|
108 | - //$descent = -$size/6; is less accurate, depends on font family. |
|
109 | - $base = $size; |
|
110 | - $descent = $size-$height; |
|
111 | - //print '<pre>Text_Renderer other than cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
|
106 | + //Descent is font part below baseline, typically negative. $height is about full height of font box. |
|
107 | + //$descent = -$size/6; is less accurate, depends on font family. |
|
108 | + $base = $size; |
|
109 | + $descent = $size-$height; |
|
110 | + //print '<pre>Text_Renderer other than cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
|
112 | 111 | } |
113 | 112 | |
114 | 113 | // Handle text decoration: |
@@ -119,42 +118,42 @@ discard block |
||
119 | 118 | $p = $frame; |
120 | 119 | $stack = array(); |
121 | 120 | while ( $p = $p->get_parent() ) |
122 | - $stack[] = $p; |
|
121 | + $stack[] = $p; |
|
123 | 122 | |
124 | 123 | while ( count($stack) > 0 ) { |
125 | - $f = array_pop($stack); |
|
124 | + $f = array_pop($stack); |
|
126 | 125 | |
127 | - $deco_y = $y; |
|
128 | - if ( ($text_deco = $f->get_style()->text_decoration) === "none" ) |
|
126 | + $deco_y = $y; |
|
127 | + if ( ($text_deco = $f->get_style()->text_decoration) === "none" ) |
|
129 | 128 | continue; |
130 | 129 | |
131 | - $color = $f->get_style()->color; |
|
130 | + $color = $f->get_style()->color; |
|
132 | 131 | |
133 | - switch ($text_deco) { |
|
132 | + switch ($text_deco) { |
|
134 | 133 | |
135 | - default: |
|
134 | + default: |
|
136 | 135 | continue; |
137 | 136 | |
138 | - case "underline": |
|
137 | + case "underline": |
|
139 | 138 | $deco_y += $base - $descent+ $size * (self::UNDERLINE_OFFSET - self::DECO_THICKNESS/2); |
140 | 139 | break; |
141 | 140 | |
142 | - case "overline": |
|
141 | + case "overline": |
|
143 | 142 | $deco_y += $size * (self::OVERLINE_OFFSET + self::DECO_THICKNESS/2); |
144 | 143 | break; |
145 | 144 | |
146 | - case "line-through": |
|
145 | + case "line-through": |
|
147 | 146 | $deco_y += $base * 0.7 + $size * self::LINETHROUGH_OFFSET; |
148 | 147 | break; |
149 | 148 | |
150 | - } |
|
149 | + } |
|
151 | 150 | |
152 | - $dx = 0; |
|
153 | - $x1 = $x - self::DECO_EXTENSION; |
|
154 | - $x2 = $x + $style->width + $dx + self::DECO_EXTENSION; |
|
155 | - $this->_canvas->line($x1, $deco_y, $x2, $deco_y, $color, $size * self::DECO_THICKNESS); |
|
151 | + $dx = 0; |
|
152 | + $x1 = $x - self::DECO_EXTENSION; |
|
153 | + $x2 = $x + $style->width + $dx + self::DECO_EXTENSION; |
|
154 | + $this->_canvas->line($x1, $deco_y, $x2, $deco_y, $color, $size * self::DECO_THICKNESS); |
|
156 | 155 | |
157 | 156 | } |
158 | - } |
|
157 | + } |
|
159 | 158 | |
160 | 159 | } |
@@ -74,144 +74,144 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -35,7 +35,6 @@ discard block |
||
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @contributor Helmut Tischer <[email protected]> |
37 | 37 | * @package dompdf |
38 | - |
|
39 | 38 | * |
40 | 39 | * Changes |
41 | 40 | * @contributor Helmut Tischer <[email protected]> |
@@ -53,9 +52,9 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class List_Bullet_Renderer extends Abstract_Renderer { |
55 | 54 | |
56 | - //........................................................................ |
|
55 | + //........................................................................ |
|
57 | 56 | |
58 | - function render(Frame $frame) { |
|
57 | + function render(Frame $frame) { |
|
59 | 58 | |
60 | 59 | $style = $frame->get_style(); |
61 | 60 | $font_size = $style->get_font_size(); |
@@ -66,36 +65,36 @@ discard block |
||
66 | 65 | if ( $style->list_style_image !== "none" && |
67 | 66 | strcmp($img = $frame->get_image_url(), DOMPDF_LIB_DIR . "/res/broken_image.png") != 0) { |
68 | 67 | |
69 | - list($x,$y) = $frame->get_position(); |
|
68 | + list($x,$y) = $frame->get_position(); |
|
70 | 69 | |
71 | - //For expected size and aspect, instead of box size, use image natural size scaled to DPI. |
|
72 | - // Resample the bullet image to be consistent with 'auto' sized images |
|
73 | - // See also Image_Frame_Reflower::get_min_max_width |
|
74 | - // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary. |
|
75 | - //$w = $frame->get_width(); |
|
76 | - //$h = $frame->get_height(); |
|
77 | - list($width, $height) = getimagesize($img); |
|
78 | - $w = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
79 | - $h = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
70 | + //For expected size and aspect, instead of box size, use image natural size scaled to DPI. |
|
71 | + // Resample the bullet image to be consistent with 'auto' sized images |
|
72 | + // See also Image_Frame_Reflower::get_min_max_width |
|
73 | + // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary. |
|
74 | + //$w = $frame->get_width(); |
|
75 | + //$h = $frame->get_height(); |
|
76 | + list($width, $height) = getimagesize($img); |
|
77 | + $w = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
78 | + $h = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
80 | 79 | |
81 | - $x -= $w; |
|
82 | - $y -= ($line_height - $font_size)/2; //Reverse hinting of list_bullet_positioner |
|
80 | + $x -= $w; |
|
81 | + $y -= ($line_height - $font_size)/2; //Reverse hinting of list_bullet_positioner |
|
83 | 82 | |
84 | - $this->_canvas->image( $img, $frame->get_image_ext(), $x, $y, $w, $h); |
|
83 | + $this->_canvas->image( $img, $frame->get_image_ext(), $x, $y, $w, $h); |
|
85 | 84 | |
86 | 85 | } else { |
87 | 86 | |
88 | - $bullet_style = $style->list_style_type; |
|
87 | + $bullet_style = $style->list_style_type; |
|
89 | 88 | |
90 | - $fill = false; |
|
89 | + $fill = false; |
|
91 | 90 | |
92 | - switch ($bullet_style) { |
|
91 | + switch ($bullet_style) { |
|
93 | 92 | |
94 | - default: |
|
93 | + default: |
|
95 | 94 | case "disc": |
96 | 95 | $fill = true; |
97 | 96 | |
98 | - case "circle": |
|
97 | + case "circle": |
|
99 | 98 | list($x,$y) = $frame->get_position(); |
100 | 99 | $r = ($font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE /*-List_Bullet_Frame_Decorator::BULLET_THICKNESS*/ ))/2; |
101 | 100 | $x -= $font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE/2); |
@@ -104,7 +103,7 @@ discard block |
||
104 | 103 | $this->_canvas->circle($x, $y, $r, $style->color, $o, null, $fill); |
105 | 104 | break; |
106 | 105 | |
107 | - case "square": |
|
106 | + case "square": |
|
108 | 107 | list($x, $y) = $frame->get_position(); |
109 | 108 | $w = $font_size*List_Bullet_Frame_Decorator::BULLET_SIZE; |
110 | 109 | $x -= $w; |
@@ -112,10 +111,10 @@ discard block |
||
112 | 111 | $this->_canvas->filled_rectangle($x, $y, $w, $w, $style->color); |
113 | 112 | break; |
114 | 113 | |
115 | - case "none": |
|
114 | + case "none": |
|
116 | 115 | break; |
117 | 116 | |
118 | - } |
|
117 | + } |
|
118 | + } |
|
119 | 119 | } |
120 | - } |
|
121 | 120 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_cell_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -48,15 +47,15 @@ discard block |
||
48 | 47 | */ |
49 | 48 | class Table_Cell_Frame_Reflower extends Block_Frame_Reflower { |
50 | 49 | |
51 | - //........................................................................ |
|
50 | + //........................................................................ |
|
52 | 51 | |
53 | - function __construct(Frame $frame) { |
|
52 | + function __construct(Frame $frame) { |
|
54 | 53 | parent::__construct($frame); |
55 | - } |
|
54 | + } |
|
56 | 55 | |
57 | - //........................................................................ |
|
56 | + //........................................................................ |
|
58 | 57 | |
59 | - function reflow() { |
|
58 | + function reflow() { |
|
60 | 59 | |
61 | 60 | $style = $this->_frame->get_style(); |
62 | 61 | |
@@ -70,31 +69,31 @@ discard block |
||
70 | 69 | |
71 | 70 | $w = 0; |
72 | 71 | foreach ( $cells["columns"] as $i ) { |
73 | - $col = $cellmap->get_column( $i ); |
|
74 | - $w += $col["used-width"]; |
|
72 | + $col = $cellmap->get_column( $i ); |
|
73 | + $w += $col["used-width"]; |
|
75 | 74 | } |
76 | 75 | |
77 | 76 | //FIXME? |
78 | 77 | $h = $this->_frame->get_containing_block("h"); |
79 | 78 | |
80 | 79 | $left_space = $style->length_in_pt(array($style->margin_left, |
81 | - $style->padding_left, |
|
82 | - $style->border_left_width), |
|
83 | - $w); |
|
80 | + $style->padding_left, |
|
81 | + $style->border_left_width), |
|
82 | + $w); |
|
84 | 83 | |
85 | 84 | $right_space = $style->length_in_pt(array($style->padding_right, |
86 | - $style->margin_right, |
|
87 | - $style->border_right_width), |
|
85 | + $style->margin_right, |
|
86 | + $style->border_right_width), |
|
88 | 87 | $w); |
89 | 88 | |
90 | 89 | $top_space = $style->length_in_pt(array($style->margin_top, |
91 | 90 | $style->padding_top, |
92 | 91 | $style->border_top_width), |
93 | - $w); |
|
92 | + $w); |
|
94 | 93 | $bottom_space = $style->length_in_pt(array($style->margin_bottom, |
95 | - $style->padding_bottom, |
|
96 | - $style->border_bottom_width), |
|
97 | - $w); |
|
94 | + $style->padding_bottom, |
|
95 | + $style->border_bottom_width), |
|
96 | + $w); |
|
98 | 97 | |
99 | 98 | $style->width = $cb_w = $w - $left_space - $right_space; |
100 | 99 | |
@@ -112,13 +111,13 @@ discard block |
||
112 | 111 | // Set the containing blocks and reflow each child |
113 | 112 | foreach ( $this->_frame->get_children() as $child ) { |
114 | 113 | |
115 | - if ( $page->is_full() ) |
|
114 | + if ( $page->is_full() ) |
|
116 | 115 | break; |
117 | 116 | |
118 | - $child->set_containing_block($content_x, $content_y, $cb_w, $h); |
|
119 | - $child->reflow(); |
|
117 | + $child->set_containing_block($content_x, $content_y, $cb_w, $h); |
|
118 | + $child->reflow(); |
|
120 | 119 | |
121 | - $this->_frame->add_frame_to_line( $child ); |
|
120 | + $this->_frame->add_frame_to_line( $child ); |
|
122 | 121 | |
123 | 122 | } |
124 | 123 | |
@@ -133,10 +132,10 @@ discard block |
||
133 | 132 | $cell_height = $height / count($cells["rows"]); |
134 | 133 | |
135 | 134 | if ($style_height < $height) |
136 | - $cell_height += $top_space + $bottom_space; |
|
135 | + $cell_height += $top_space + $bottom_space; |
|
137 | 136 | |
138 | 137 | foreach ($cells["rows"] as $i) |
139 | - $cellmap->set_row_height($i, $cell_height); |
|
138 | + $cellmap->set_row_height($i, $cell_height); |
|
140 | 139 | |
141 | 140 | $style->height = $height; |
142 | 141 | |
@@ -144,6 +143,6 @@ discard block |
||
144 | 143 | |
145 | 144 | $this->vertical_align(); |
146 | 145 | |
147 | - } |
|
146 | + } |
|
148 | 147 | |
149 | 148 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -49,17 +48,17 @@ discard block |
||
49 | 48 | */ |
50 | 49 | abstract class Positioner { |
51 | 50 | |
52 | - // protected members |
|
53 | - protected $_frame; |
|
51 | + // protected members |
|
52 | + protected $_frame; |
|
54 | 53 | |
55 | - //........................................................................ |
|
54 | + //........................................................................ |
|
56 | 55 | |
57 | - function __construct(Frame_Decorator $frame) { |
|
56 | + function __construct(Frame_Decorator $frame) { |
|
58 | 57 | $this->_frame = $frame; |
59 | - } |
|
58 | + } |
|
60 | 59 | |
61 | - //........................................................................ |
|
60 | + //........................................................................ |
|
62 | 61 | |
63 | - abstract function position(); |
|
62 | + abstract function position(); |
|
64 | 63 | |
65 | 64 | } |