PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 2.4.2
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v2.4.2
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
pdf-print / mpdf / Tag.php

Tag.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 2.4.2, at mpdf/Tag.php

6,119 lines 255.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Tag
4 {
5
6 private $mpdf;
7
8 public function __construct(mPDF $mpdf)
9 {
10 $this->mpdf = $mpdf;
11 }
12
13 function OpenTag($tag, $attr, &$ahtml, &$ihtml)
14 { // mPDF 6
15 //Opening tag
16 // mPDF 6
17 // Correct for tags where HTML5 specifies optional end tags excluding table elements (cf WriteHTML() )
18 if ($this->mpdf->allow_html_optional_endtags) {
19 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['tag'])) {
20 $closed = false;
21 // li end tag may be omitted if immediately followed by another li element
22 if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'LI' && $tag == 'LI') {
23 $this->CloseTag('LI', $ahtml, $ihtml);
24 $closed = true;
25 }
26 // dt end tag may be omitted if immediately followed by another dt element or a dd element
27 if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'DT' && ($tag == 'DT' || $tag == 'DD')) {
28 $this->CloseTag('DT', $ahtml, $ihtml);
29 $closed = true;
30 }
31 // dd end tag may be omitted if immediately followed by another dd element or a dt element
32 if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'DD' && ($tag == 'DT' || $tag == 'DD')) {
33 $this->CloseTag('DD', $ahtml, $ihtml);
34 $closed = true;
35 }
36 // p end tag may be omitted if immediately followed by an address, article, aside, blockquote, div, dl, fieldset, form,
37 // h1, h2, h3, h4, h5, h6, hgroup, hr, main, nav, ol, p, pre, section, table, ul
38 if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'P' && ($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'UL' || $tag == 'OL' || $tag == 'TABLE' || $tag == 'PRE' || $tag == 'FORM' || $tag == 'ADDRESS' || $tag == 'BLOCKQUOTE' || $tag == 'CENTER' || $tag == 'DL' || $tag == 'HR' || $tag == 'ARTICLE' || $tag == 'ASIDE' || $tag == 'FIELDSET' || $tag == 'HGROUP' || $tag == 'MAIN' || $tag == 'NAV' || $tag == 'SECTION')) {
39 $this->CloseTag('P', $ahtml, $ihtml);
40 $closed = true;
41 }
42 // option end tag may be omitted if immediately followed by another option element (or if it is immediately followed by an optgroup element)
43 if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'OPTION' && $tag == 'OPTION') {
44 $this->CloseTag('OPTION', $ahtml, $ihtml);
45 $closed = true;
46 }
47 // Table elements - see also WriteHTML()
48 if (!$closed && ($tag == 'TD' || $tag == 'TH') && $this->mpdf->lastoptionaltag == 'TD') {
49 $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
50 $closed = true;
51 } // *TABLES*
52 if (!$closed && ($tag == 'TD' || $tag == 'TH') && $this->mpdf->lastoptionaltag == 'TH') {
53 $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
54 $closed = true;
55 } // *TABLES*
56 if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TR') {
57 $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
58 $closed = true;
59 } // *TABLES*
60 if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TD') {
61 $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
62 $this->CloseTag('TR', $ahtml, $ihtml);
63 $this->CloseTag('THEAD', $ahtml, $ihtml);
64 $closed = true;
65 } // *TABLES*
66 if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TH') {
67 $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml);
68 $this->CloseTag('TR', $ahtml, $ihtml);
69 $this->CloseTag('THEAD', $ahtml, $ihtml);
70 $closed = true;
71 } // *TABLES*
72 }
73 }
74
75 $align = array('left' => 'L', 'center' => 'C', 'right' => 'R', 'top' => 'T', 'text-top' => 'TT', 'middle' => 'M', 'baseline' => 'BS', 'bottom' => 'B', 'text-bottom' => 'TB', 'justify' => 'J');
76
77 switch ($tag) {
78
79 case 'DOTTAB':
80 $objattr = array();
81 $objattr['type'] = 'dottab';
82 $dots = str_repeat('.', 3) . " "; // minimum number of dots
83 $objattr['width'] = $this->mpdf->GetStringWidth($dots);
84 $objattr['margin_top'] = 0;
85 $objattr['margin_bottom'] = 0;
86 $objattr['margin_left'] = 0;
87 $objattr['margin_right'] = 0;
88 $objattr['height'] = 0;
89 $objattr['colorarray'] = $this->mpdf->colorarray;
90 $objattr['border_top']['w'] = 0;
91 $objattr['border_bottom']['w'] = 0;
92 $objattr['border_left']['w'] = 0;
93 $objattr['border_right']['w'] = 0;
94 $objattr['vertical_align'] = 'BS'; // mPDF 6 DOTTAB
95
96 $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
97 if (isset($properties['OUTDENT'])) {
98 $objattr['outdent'] = $this->mpdf->ConvertSize($properties['OUTDENT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
99 } else if (isset($attr['OUTDENT'])) {
100 $objattr['outdent'] = $this->mpdf->ConvertSize($attr['OUTDENT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
101 } else {
102 $objattr['outdent'] = 0;
103 }
104
105 $objattr['fontfamily'] = $this->mpdf->FontFamily;
106 $objattr['fontsize'] = $this->mpdf->FontSizePt;
107
108 $e = "\xbb\xa4\xactype=dottab,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
109 /* -- TABLES -- */
110 // Output it to buffers
111 if ($this->mpdf->tableLevel) {
112 if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
113 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
114 } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
115 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
116 }
117 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
118 $this->mpdf->_saveCellTextBuffer($e);
119 } else {
120 /* -- END TABLES -- */
121 $this->mpdf->_saveTextBuffer($e);
122 } // *TABLES*
123 break;
124
125 case 'PAGEHEADER':
126 case 'PAGEFOOTER':
127 $this->mpdf->ignorefollowingspaces = true;
128 if ($attr['NAME']) {
129 $pname = $attr['NAME'];
130 } else {
131 $pname = '_nonhtmldefault';
132 } // mPDF 6
133
134 $p = array(); // mPDF 6
135 $p['L'] = array();
136 $p['C'] = array();
137 $p['R'] = array();
138 $p['L']['font-style'] = '';
139 $p['C']['font-style'] = '';
140 $p['R']['font-style'] = '';
141
142 if (isset($attr['CONTENT-LEFT'])) {
143 $p['L']['content'] = $attr['CONTENT-LEFT'];
144 }
145 if (isset($attr['CONTENT-CENTER'])) {
146 $p['C']['content'] = $attr['CONTENT-CENTER'];
147 }
148 if (isset($attr['CONTENT-RIGHT'])) {
149 $p['R']['content'] = $attr['CONTENT-RIGHT'];
150 }
151
152 if (isset($attr['HEADER-STYLE']) || isset($attr['FOOTER-STYLE'])) { // font-family,size,weight,style,color
153 if ($tag == 'PAGEHEADER') {
154 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE']);
155 } else {
156 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE']);
157 }
158 if (isset($properties['FONT-FAMILY'])) {
159 $p['L']['font-family'] = $properties['FONT-FAMILY'];
160 $p['C']['font-family'] = $properties['FONT-FAMILY'];
161 $p['R']['font-family'] = $properties['FONT-FAMILY'];
162 }
163 if (isset($properties['FONT-SIZE'])) {
164 $p['L']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
165 $p['C']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
166 $p['R']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
167 }
168 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
169 $p['L']['font-style'] = 'B';
170 $p['C']['font-style'] = 'B';
171 $p['R']['font-style'] = 'B';
172 }
173 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
174 $p['L']['font-style'] .= 'I';
175 $p['C']['font-style'] .= 'I';
176 $p['R']['font-style'] .= 'I';
177 }
178 if (isset($properties['COLOR'])) {
179 $p['L']['color'] = $properties['COLOR'];
180 $p['C']['color'] = $properties['COLOR'];
181 $p['R']['color'] = $properties['COLOR'];
182 }
183 }
184 if (isset($attr['HEADER-STYLE-LEFT']) || isset($attr['FOOTER-STYLE-LEFT'])) {
185 if ($tag == 'PAGEHEADER') {
186 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-LEFT']);
187 } else {
188 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-LEFT']);
189 }
190 if (isset($properties['FONT-FAMILY'])) {
191 $p['L']['font-family'] = $properties['FONT-FAMILY'];
192 }
193 if (isset($properties['FONT-SIZE'])) {
194 $p['L']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
195 }
196 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
197 $p['L']['font-style'] = 'B';
198 }
199 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
200 $p['L']['font-style'] .='I';
201 }
202 if (isset($properties['COLOR'])) {
203 $p['L']['color'] = $properties['COLOR'];
204 }
205 }
206 if (isset($attr['HEADER-STYLE-CENTER']) || isset($attr['FOOTER-STYLE-CENTER'])) {
207 if ($tag == 'PAGEHEADER') {
208 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-CENTER']);
209 } else {
210 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-CENTER']);
211 }
212 if (isset($properties['FONT-FAMILY'])) {
213 $p['C']['font-family'] = $properties['FONT-FAMILY'];
214 }
215 if (isset($properties['FONT-SIZE'])) {
216 $p['C']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
217 }
218 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
219 $p['C']['font-style'] = 'B';
220 }
221 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
222 $p['C']['font-style'] .= 'I';
223 }
224 if (isset($properties['COLOR'])) {
225 $p['C']['color'] = $properties['COLOR'];
226 }
227 }
228 if (isset($attr['HEADER-STYLE-RIGHT']) || isset($attr['FOOTER-STYLE-RIGHT'])) {
229 if ($tag == 'PAGEHEADER') {
230 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-RIGHT']);
231 } else {
232 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-RIGHT']);
233 }
234 if (isset($properties['FONT-FAMILY'])) {
235 $p['R']['font-family'] = $properties['FONT-FAMILY'];
236 }
237 if (isset($properties['FONT-SIZE'])) {
238 $p['R']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
239 }
240 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
241 $p['R']['font-style'] = 'B';
242 }
243 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
244 $p['R']['font-style'] .= 'I';
245 }
246 if (isset($properties['COLOR'])) {
247 $p['R']['color'] = $properties['COLOR'];
248 }
249 }
250 if (isset($attr['LINE']) && $attr['LINE']) { // 0|1|on|off
251 if ($attr['LINE'] == '1' || strtoupper($attr['LINE']) == 'ON') {
252 $lineset = 1;
253 } else {
254 $lineset = 0;
255 }
256 $p['line'] = $lineset;
257 }
258 // mPDF 6
259 if ($tag == 'PAGEHEADER') {
260 $this->mpdf->DefHeaderByName($pname, $p);
261 } else {
262 $this->mpdf->DefFooterByName($pname, $p);
263 }
264 break;
265
266
267 case 'SETPAGEHEADER': // mPDF 6
268 case 'SETPAGEFOOTER':
269 case 'SETHTMLPAGEHEADER':
270 case 'SETHTMLPAGEFOOTER':
271 $this->mpdf->ignorefollowingspaces = true;
272 if (isset($attr['NAME']) && $attr['NAME']) {
273 $pname = $attr['NAME'];
274 } else if ($tag == 'SETPAGEHEADER' || $tag == 'SETPAGEFOOTER') {
275 $pname = '_nonhtmldefault';
276 } // mPDF 6
277 else {
278 $pname = '_default';
279 }
280 if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
281 if (strtoupper($attr['PAGE']) == 'O' || strtoupper($attr['PAGE']) == 'ODD') {
282 $side = 'odd';
283 } else if (strtoupper($attr['PAGE']) == 'E' || strtoupper($attr['PAGE']) == 'EVEN') {
284 $side = 'even';
285 } else if (strtoupper($attr['PAGE']) == 'ALL') {
286 $side = 'both';
287 } else {
288 $side = 'odd';
289 }
290 } else {
291 $side = 'odd';
292 }
293 if (isset($attr['VALUE']) && $attr['VALUE']) { // -1|1|on|off
294 if ($attr['VALUE'] == '1' || strtoupper($attr['VALUE']) == 'ON') {
295 $set = 1;
296 } else if ($attr['VALUE'] == '-1' || strtoupper($attr['VALUE']) == 'OFF') {
297 $set = 0;
298 } else {
299 $set = 1;
300 }
301 } else {
302 $set = 1;
303 }
304 if (isset($attr['SHOW-THIS-PAGE']) && $attr['SHOW-THIS-PAGE'] && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) {
305 $write = 1;
306 } else {
307 $write = 0;
308 }
309 if ($side == 'odd' || $side == 'both') {
310 if ($set && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) {
311 $this->mpdf->SetHTMLHeader($this->mpdf->pageHTMLheaders[$pname], 'O', $write);
312 } else if ($set && ($tag == 'SETHTMLPAGEFOOTER' || $tag == 'SETPAGEFOOTER')) {
313 $this->mpdf->SetHTMLFooter($this->mpdf->pageHTMLfooters[$pname], 'O');
314 } else if ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER') {
315 $this->mpdf->SetHTMLHeader('', 'O');
316 } else {
317 $this->mpdf->SetHTMLFooter('', 'O');
318 }
319 }
320 if ($side == 'even' || $side == 'both') {
321 if ($set && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) {
322 $this->mpdf->SetHTMLHeader($this->mpdf->pageHTMLheaders[$pname], 'E', $write);
323 } else if ($set && ($tag == 'SETHTMLPAGEFOOTER' || $tag == 'SETPAGEFOOTER')) {
324 $this->mpdf->SetHTMLFooter($this->mpdf->pageHTMLfooters[$pname], 'E');
325 } else if ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER') {
326 $this->mpdf->SetHTMLHeader('', 'E');
327 } else {
328 $this->mpdf->SetHTMLFooter('', 'E');
329 }
330 }
331 break;
332
333
334
335 /* -- TOC -- */
336 case 'TOC': //added custom-tag - set Marker for insertion later of ToC
337 if (!class_exists('tocontents', false)) {
338 include(_MPDF_PATH . 'classes/tocontents.php');
339 }
340 if (empty($this->mpdf->tocontents)) {
341 $this->mpdf->tocontents = new tocontents($this);
342 }
343 $this->mpdf->tocontents->openTagTOC($attr);
344 break;
345
346
347 case 'TOCPAGEBREAK': // custom-tag - set Marker for insertion later of ToC AND adds PAGEBREAK
348 if (!class_exists('tocontents', false)) {
349 include(_MPDF_PATH . 'classes/tocontents.php');
350 }
351 if (empty($this->mpdf->tocontents)) {
352 $this->mpdf->tocontents = new tocontents($this->mpdf);
353 }
354 list($isbreak, $toc_id) = $this->mpdf->tocontents->openTagTOCPAGEBREAK($attr);
355 if ($isbreak)
356 break;
357 if (!isset($attr['RESETPAGENUM']) || $attr['RESETPAGENUM'] < 1) {
358 $attr['RESETPAGENUM'] = 1;
359 } // mPDF 6
360 // No break - continues as PAGEBREAK...
361 /* -- END TOC -- */
362
363
364 case 'PAGE_BREAK': //custom-tag
365 case 'PAGEBREAK': //custom-tag
366 case 'NEWPAGE': //custom-tag
367 case 'FORMFEED': //custom-tag
368
369 if (isset($attr['SHEET-SIZE'])) {
370 // Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h)
371 $prop = preg_split('/\s+/', trim($attr['SHEET-SIZE']));
372 if (count($prop) == 2) {
373 $newformat = array($this->mpdf->ConvertSize($prop[0]), $this->mpdf->ConvertSize($prop[1]));
374 } else {
375 $newformat = $attr['SHEET-SIZE'];
376 }
377 } else {
378 $newformat = '';
379 }
380
381 $save_blklvl = $this->mpdf->blklvl;
382 $save_blk = $this->mpdf->blk;
383 $save_silp = $this->mpdf->saveInlineProperties();
384 $save_ilp = $this->mpdf->InlineProperties;
385 $save_bflp = $this->mpdf->InlineBDF;
386 $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
387
388 $mgr = $mgl = $mgt = $mgb = $mgh = $mgf = '';
389 if (isset($attr['MARGIN-RIGHT'])) {
390 $mgr = $this->mpdf->ConvertSize($attr['MARGIN-RIGHT'], $this->mpdf->w, $this->mpdf->FontSize, false);
391 }
392 if (isset($attr['MARGIN-LEFT'])) {
393 $mgl = $this->mpdf->ConvertSize($attr['MARGIN-LEFT'], $this->mpdf->w, $this->mpdf->FontSize, false);
394 }
395 if (isset($attr['MARGIN-TOP'])) {
396 $mgt = $this->mpdf->ConvertSize($attr['MARGIN-TOP'], $this->mpdf->w, $this->mpdf->FontSize, false);
397 }
398 if (isset($attr['MARGIN-BOTTOM'])) {
399 $mgb = $this->mpdf->ConvertSize($attr['MARGIN-BOTTOM'], $this->mpdf->w, $this->mpdf->FontSize, false);
400 }
401 if (isset($attr['MARGIN-HEADER'])) {
402 $mgh = $this->mpdf->ConvertSize($attr['MARGIN-HEADER'], $this->mpdf->w, $this->mpdf->FontSize, false);
403 }
404 if (isset($attr['MARGIN-FOOTER'])) {
405 $mgf = $this->mpdf->ConvertSize($attr['MARGIN-FOOTER'], $this->mpdf->w, $this->mpdf->FontSize, false);
406 }
407 $ohname = $ehname = $ofname = $efname = '';
408 if (isset($attr['ODD-HEADER-NAME'])) {
409 $ohname = $attr['ODD-HEADER-NAME'];
410 }
411 if (isset($attr['EVEN-HEADER-NAME'])) {
412 $ehname = $attr['EVEN-HEADER-NAME'];
413 }
414 if (isset($attr['ODD-FOOTER-NAME'])) {
415 $ofname = $attr['ODD-FOOTER-NAME'];
416 }
417 if (isset($attr['EVEN-FOOTER-NAME'])) {
418 $efname = $attr['EVEN-FOOTER-NAME'];
419 }
420 $ohvalue = $ehvalue = $ofvalue = $efvalue = 0;
421 if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '1' || strtoupper($attr['ODD-HEADER-VALUE']) == 'ON')) {
422 $ohvalue = 1;
423 } else if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '-1' || strtoupper($attr['ODD-HEADER-VALUE']) == 'OFF')) {
424 $ohvalue = -1;
425 }
426 if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '1' || strtoupper($attr['EVEN-HEADER-VALUE']) == 'ON')) {
427 $ehvalue = 1;
428 } else if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '-1' || strtoupper($attr['EVEN-HEADER-VALUE']) == 'OFF')) {
429 $ehvalue = -1;
430 }
431 if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '1' || strtoupper($attr['ODD-FOOTER-VALUE']) == 'ON')) {
432 $ofvalue = 1;
433 } else if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '-1' || strtoupper($attr['ODD-FOOTER-VALUE']) == 'OFF')) {
434 $ofvalue = -1;
435 }
436 if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '1' || strtoupper($attr['EVEN-FOOTER-VALUE']) == 'ON')) {
437 $efvalue = 1;
438 } else if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '-1' || strtoupper($attr['EVEN-FOOTER-VALUE']) == 'OFF')) {
439 $efvalue = -1;
440 }
441
442 if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'L' || strtoupper($attr['ORIENTATION']) == 'LANDSCAPE')) {
443 $orient = 'L';
444 } else if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'P' || strtoupper($attr['ORIENTATION']) == 'PORTRAIT')) {
445 $orient = 'P';
446 } else {
447 $orient = $this->mpdf->CurOrientation;
448 }
449
450 if (isset($attr['PAGE-SELECTOR']) && $attr['PAGE-SELECTOR']) {
451 $pagesel = $attr['PAGE-SELECTOR'];
452 } else {
453 $pagesel = '';
454 }
455
456 // mPDF 6 pagebreaktype
457 $pagebreaktype = $this->mpdf->defaultPagebreakType;
458 if ($tag == 'FORMFEED') {
459 $pagebreaktype = 'slice';
460 } // can be overridden by PAGE-BREAK-TYPE
461 $startpage = $this->mpdf->page;
462 if (isset($attr['PAGE-BREAK-TYPE'])) {
463 if (strtolower($attr['PAGE-BREAK-TYPE']) == 'cloneall' || strtolower($attr['PAGE-BREAK-TYPE']) == 'clonebycss' || strtolower($attr['PAGE-BREAK-TYPE']) == 'slice') {
464 $pagebreaktype = strtolower($attr['PAGE-BREAK-TYPE']);
465 }
466 }
467 if ($tag == 'TOCPAGEBREAK') {
468 $pagebreaktype = 'cloneall';
469 } else if ($this->mpdf->ColActive) {
470 $pagebreaktype = 'cloneall';
471 }
472 // Any change in headers/footers (may need to _getHtmlHeight), or page size/orientation, @page selector, or margins - force cloneall
473 else if ($mgr !== '' || $mgl !== '' || $mgt !== '' || $mgb !== '' || $mgh !== '' || $mgf !== '' ||
474 $ohname !== '' || $ehname !== '' || $ofname !== '' || $efname !== '' ||
475 $ohvalue || $ehvalue || $ofvalue || $efvalue ||
476 $orient != $this->mpdf->CurOrientation || $newformat || $pagesel) {
477 $pagebreaktype = 'cloneall';
478 }
479
480 // mPDF 6 pagebreaktype
481 $this->mpdf->_preForcedPagebreak($pagebreaktype);
482
483 $this->mpdf->ignorefollowingspaces = true;
484
485
486 $resetpagenum = '';
487 $pagenumstyle = '';
488 $suppress = '';
489 if (isset($attr['RESETPAGENUM'])) {
490 $resetpagenum = $attr['RESETPAGENUM'];
491 }
492 if (isset($attr['PAGENUMSTYLE'])) {
493 $pagenumstyle = $attr['PAGENUMSTYLE'];
494 }
495 if (isset($attr['SUPPRESS'])) {
496 $suppress = $attr['SUPPRESS'];
497 }
498
499 if ($tag == 'TOCPAGEBREAK') {
500 $type = 'NEXT-ODD';
501 } else if (isset($attr['TYPE'])) {
502 $type = strtoupper($attr['TYPE']);
503 } else {
504 $type = '';
505 }
506
507 if ($type == 'E' || $type == 'EVEN') {
508 $this->mpdf->AddPage($orient, 'E', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
509 } else if ($type == 'O' || $type == 'ODD') {
510 $this->mpdf->AddPage($orient, 'O', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
511 } else if ($type == 'NEXT-ODD') {
512 $this->mpdf->AddPage($orient, 'NEXT-ODD', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
513 } else if ($type == 'NEXT-EVEN') {
514 $this->mpdf->AddPage($orient, 'NEXT-EVEN', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
515 } else {
516 $this->mpdf->AddPage($orient, '', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
517 }
518
519 /* -- TOC -- */
520 if ($tag == 'TOCPAGEBREAK') {
521 if ($toc_id) {
522 $this->mpdf->tocontents->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page;
523 } else {
524 $this->mpdf->tocontents->TOCmark = $this->mpdf->page;
525 }
526 }
527 /* -- END TOC -- */
528
529 // mPDF 6 pagebreaktype
530 $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
531
532 $this->mpdf->InlineProperties = $save_ilp;
533 $this->mpdf->InlineBDF = $save_bflp;
534 $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
535 $this->mpdf->restoreInlineProperties($save_silp);
536
537 break;
538
539
540 /* -- TOC -- */
541 case 'TOCENTRY':
542 if (isset($attr['CONTENT']) && $attr['CONTENT']) {
543 $objattr = array();
544 $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
545 $objattr['type'] = 'toc';
546 $objattr['vertical-align'] = 'T';
547 if (isset($attr['LEVEL']) && $attr['LEVEL']) {
548 $objattr['toclevel'] = $attr['LEVEL'];
549 } else {
550 $objattr['toclevel'] = 0;
551 }
552 if (isset($attr['NAME']) && $attr['NAME']) {
553 $objattr['toc_id'] = $attr['NAME'];
554 } else {
555 $objattr['toc_id'] = 0;
556 }
557 $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
558 if ($this->mpdf->tableLevel) {
559 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
560 } // *TABLES*
561 else { // *TABLES*
562 $this->mpdf->textbuffer[] = array($e);
563 } // *TABLES*
564 }
565 break;
566 /* -- END TOC -- */
567
568 /* -- INDEX -- */
569 case 'INDEXENTRY':
570 if (isset($attr['CONTENT']) && $attr['CONTENT']) {
571 if (isset($attr['XREF']) && $attr['XREF']) {
572 $this->mpdf->IndexEntry(htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES), $attr['XREF']);
573 break;
574 }
575 $objattr = array();
576 $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
577 $objattr['type'] = 'indexentry';
578 $objattr['vertical-align'] = 'T';
579 $e = "\xbb\xa4\xactype=indexentry,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
580 if ($this->mpdf->tableLevel) {
581 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
582 } // *TABLES*
583 else { // *TABLES*
584 $this->mpdf->textbuffer[] = array($e);
585 } // *TABLES*
586 }
587 break;
588
589
590 case 'INDEXINSERT':
591 if (isset($attr['COLLATION'])) {
592 $indexCollationLocale = $attr['COLLATION'];
593 } else {
594 $indexCollationLocale = '';
595 }
596 if (isset($attr['COLLATION-GROUP'])) {
597 $indexCollationGroup = $attr['COLLATION-GROUP'];
598 } else {
599 $indexCollationGroup = '';
600 }
601 if (isset($attr['USEDIVLETTERS']) && (strtoupper($attr['USEDIVLETTERS']) == 'OFF' || $attr['USEDIVLETTERS'] == -1 || $attr['USEDIVLETTERS'] === '0')) {
602 $usedivletters = 0;
603 } else {
604 $usedivletters = 1;
605 }
606 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' || $attr['LINKS'] == 1)) {
607 $links = true;
608 } else {
609 $links = false;
610 }
611 $this->mpdf->InsertIndex($usedivletters, $links, $indexCollationLocale, $indexCollationGroup);
612
613 break;
614 /* -- END INDEX -- */
615
616 /* -- WATERMARK -- */
617
618 case 'WATERMARKTEXT':
619 if (isset($attr['CONTENT']) && $attr['CONTENT']) {
620 $txt = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
621 } else {
622 $txt = '';
623 }
624 if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) {
625 $alpha = $attr['ALPHA'];
626 } else {
627 $alpha = -1;
628 }
629 $this->mpdf->SetWatermarkText($txt, $alpha);
630 break;
631
632
633 case 'WATERMARKIMAGE':
634 if (isset($attr['SRC'])) {
635 $src = $attr['SRC'];
636 } else {
637 $src = '';
638 }
639 if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) {
640 $alpha = $attr['ALPHA'];
641 } else {
642 $alpha = -1;
643 }
644 if (isset($attr['SIZE']) && $attr['SIZE']) {
645 $size = $attr['SIZE'];
646 if (strpos($size, ',')) {
647 $size = explode(',', $size);
648 }
649 } else {
650 $size = 'D';
651 }
652 if (isset($attr['POSITION']) && $attr['POSITION']) { // mPDF 5.7.2
653 $pos = $attr['POSITION'];
654 if (strpos($pos, ',')) {
655 $pos = explode(',', $pos);
656 }
657 } else {
658 $pos = 'P';
659 }
660 $this->mpdf->SetWatermarkImage($src, $alpha, $size, $pos);
661 break;
662 /* -- END WATERMARK -- */
663
664 /* -- BOOKMARKS -- */
665 case 'BOOKMARK':
666 if (isset($attr['CONTENT'])) {
667 $objattr = array();
668 $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
669 $objattr['type'] = 'bookmark';
670 if (isset($attr['LEVEL']) && $attr['LEVEL']) {
671 $objattr['bklevel'] = $attr['LEVEL'];
672 } else {
673 $objattr['bklevel'] = 0;
674 }
675 $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
676 if ($this->mpdf->tableLevel) {
677 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
678 } // *TABLES*
679 else { // *TABLES*
680 $this->mpdf->textbuffer[] = array($e);
681 } // *TABLES*
682 }
683 break;
684 /* -- END BOOKMARKS -- */
685
686 /* -- ANNOTATIONS -- */
687 case 'ANNOTATION':
688
689 //if (isset($attr['CONTENT']) && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) { // Stops annotations in FixedPos
690 if (isset($attr['CONTENT'])) {
691 $objattr = array();
692 $objattr['margin_top'] = 0;
693 $objattr['margin_bottom'] = 0;
694 $objattr['margin_left'] = 0;
695 $objattr['margin_right'] = 0;
696 $objattr['width'] = 0;
697 $objattr['height'] = 0;
698 $objattr['border_top']['w'] = 0;
699 $objattr['border_bottom']['w'] = 0;
700 $objattr['border_left']['w'] = 0;
701 $objattr['border_right']['w'] = 0;
702 $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
703 $objattr['type'] = 'annot';
704 $objattr['POPUP'] = '';
705 } else {
706 break;
707 }
708 if (isset($attr['POS-X'])) {
709 $objattr['POS-X'] = $attr['POS-X'];
710 } else {
711 $objattr['POS-X'] = 0;
712 }
713 if (isset($attr['POS-Y'])) {
714 $objattr['POS-Y'] = $attr['POS-Y'];
715 } else {
716 $objattr['POS-Y'] = 0;
717 }
718 if (isset($attr['ICON'])) {
719 $objattr['ICON'] = $attr['ICON'];
720 } else {
721 $objattr['ICON'] = 'Note';
722 }
723 if (isset($attr['AUTHOR'])) {
724 $objattr['AUTHOR'] = $attr['AUTHOR'];
725 } else if (isset($attr['TITLE'])) {
726 $objattr['AUTHOR'] = $attr['TITLE'];
727 } else {
728 $objattr['AUTHOR'] = '';
729 }
730 if (isset($attr['FILE'])) {
731 $objattr['FILE'] = $attr['FILE'];
732 } else {
733 $objattr['FILE'] = '';
734 }
735 if (isset($attr['SUBJECT'])) {
736 $objattr['SUBJECT'] = $attr['SUBJECT'];
737 } else {
738 $objattr['SUBJECT'] = '';
739 }
740 if (isset($attr['OPACITY']) && $attr['OPACITY'] > 0 && $attr['OPACITY'] <= 1) {
741 $objattr['OPACITY'] = $attr['OPACITY'];
742 } else if ($this->mpdf->annotMargin) {
743 $objattr['OPACITY'] = 1;
744 } else {
745 $objattr['OPACITY'] = $this->mpdf->annotOpacity;
746 }
747 if (isset($attr['COLOR'])) {
748 $cor = $this->mpdf->ConvertColor($attr['COLOR']);
749 if ($cor) {
750 $objattr['COLOR'] = $cor;
751 } else {
752 $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
753 }
754 } else {
755 $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
756 }
757
758 if (isset($attr['POPUP']) && !empty($attr['POPUP'])) {
759 $pop = preg_split('/\s+/', trim($attr['POPUP']));
760 if (count($pop) > 1) {
761 $objattr['POPUP'] = $pop;
762 } else {
763 $objattr['POPUP'] = true;
764 }
765 }
766 $e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
767 if ($this->mpdf->tableLevel) {
768 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e);
769 } // *TABLES*
770 else { // *TABLES*
771 $this->mpdf->textbuffer[] = array($e);
772 } // *TABLES*
773 break;
774 /* -- END ANNOTATIONS -- */
775
776
777 /* -- COLUMNS -- */
778 case 'COLUMNS': //added custom-tag
779 if (isset($attr['COLUMN-COUNT']) && ($attr['COLUMN-COUNT'] || $attr['COLUMN-COUNT'] === '0')) {
780 // Close any open block tags
781 for ($b = $this->mpdf->blklvl; $b > 0; $b--) {
782 $this->CloseTag($this->mpdf->blk[$b]['tag'], $ahtml, $ihtml);
783 }
784 if (!empty($this->mpdf->textbuffer)) { //Output previously buffered content
785 $this->mpdf->printbuffer($this->mpdf->textbuffer);
786 $this->mpdf->textbuffer = array();
787 }
788
789 if (isset($attr['VALIGN']) && $attr['VALIGN']) {
790 if ($attr['VALIGN'] == 'J') {
791 $valign = 'J';
792 } else {
793 $valign = $align[$attr['VALIGN']];
794 }
795 } else {
796 $valign = '';
797 }
798 if (isset($attr['COLUMN-GAP']) && $attr['COLUMN-GAP']) {
799 $this->mpdf->SetColumns($attr['COLUMN-COUNT'], $valign, $attr['COLUMN-GAP']);
800 } else {
801 $this->mpdf->SetColumns($attr['COLUMN-COUNT'], $valign);
802 }
803 }
804 $this->mpdf->ignorefollowingspaces = true;
805 break;
806
807 case 'COLUMN_BREAK': //custom-tag
808 case 'COLUMNBREAK': //custom-tag
809 case 'NEWCOLUMN': //custom-tag
810 $this->mpdf->ignorefollowingspaces = true;
811 $this->mpdf->NewColumn();
812 $this->mpdf->ColumnAdjust = false; // disables all column height adjustment for the page.
813 break;
814
815 /* -- END COLUMNS -- */
816
817
818 case 'TTZ':
819 $this->mpdf->ttz = true;
820 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
821 $this->mpdf->setCSS(array('FONT-FAMILY' => 'czapfdingbats', 'FONT-WEIGHT' => 'normal', 'FONT-STYLE' => 'normal'), 'INLINE');
822 break;
823
824 case 'TTS':
825 $this->mpdf->tts = true;
826 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
827 $this->mpdf->setCSS(array('FONT-FAMILY' => 'csymbol', 'FONT-WEIGHT' => 'normal', 'FONT-STYLE' => 'normal'), 'INLINE');
828 break;
829
830 case 'TTA':
831 $this->mpdf->tta = true;
832 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
833
834 if (in_array($this->mpdf->FontFamily, $this->mpdf->mono_fonts)) {
835 $this->mpdf->setCSS(array('FONT-FAMILY' => 'ccourier'), 'INLINE');
836 } else if (in_array($this->mpdf->FontFamily, $this->mpdf->serif_fonts)) {
837 $this->mpdf->setCSS(array('FONT-FAMILY' => 'ctimes'), 'INLINE');
838 } else {
839 $this->mpdf->setCSS(array('FONT-FAMILY' => 'chelvetica'), 'INLINE');
840 }
841 break;
842
843
844
845 // INLINE PHRASES OR STYLES
846 case 'SUB':
847 case 'SUP':
848 case 'ACRONYM':
849 case 'BIG':
850 case 'SMALL':
851 case 'INS':
852 case 'S':
853 case 'STRIKE':
854 case 'DEL':
855 case 'STRONG':
856 case 'CITE':
857 case 'Q':
858 case 'EM':
859 case 'B':
860 case 'I':
861 case 'U':
862 case 'SAMP':
863 case 'CODE':
864 case 'KBD':
865 case 'TT':
866 case 'VAR':
867 case 'FONT':
868 case 'MARK':
869 case 'TIME':
870 case 'BDO': // mPDF 6
871 case 'BDI': // mPDF 6
872
873 case 'SPAN':
874 /* -- ANNOTATIONS -- */
875 if ($this->mpdf->title2annots && isset($attr['TITLE'])) {
876 $objattr = array();
877 $objattr['margin_top'] = 0;
878 $objattr['margin_bottom'] = 0;
879 $objattr['margin_left'] = 0;
880 $objattr['margin_right'] = 0;
881 $objattr['width'] = 0;
882 $objattr['height'] = 0;
883 $objattr['border_top']['w'] = 0;
884 $objattr['border_bottom']['w'] = 0;
885 $objattr['border_left']['w'] = 0;
886 $objattr['border_right']['w'] = 0;
887
888 $objattr['CONTENT'] = $attr['TITLE'];
889 $objattr['type'] = 'annot';
890 $objattr['POS-X'] = 0;
891 $objattr['POS-Y'] = 0;
892 $objattr['ICON'] = 'Comment';
893 $objattr['AUTHOR'] = '';
894 $objattr['SUBJECT'] = '';
895 $objattr['OPACITY'] = $this->mpdf->annotOpacity;
896 $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
897 $annot = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
898 }
899 /* -- END ANNOTATIONS -- */
900
901 // mPDF 5.7.3 Inline tags
902 if (!isset($this->mpdf->InlineProperties[$tag])) {
903 $this->mpdf->InlineProperties[$tag] = array($this->mpdf->saveInlineProperties());
904 } else {
905 $this->mpdf->InlineProperties[$tag][] = $this->mpdf->saveInlineProperties();
906 }
907 if (isset($annot)) { // *ANNOTATIONS*
908 if (!isset($this->mpdf->InlineAnnots[$tag])) {
909 $this->mpdf->InlineAnnots[$tag] = array($annot);
910 } // *ANNOTATIONS*
911 else {
912 $this->mpdf->InlineAnnots[$tag][] = $annot;
913 } // *ANNOTATIONS*
914 } // *ANNOTATIONS*
915
916 $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
917 if (!empty($properties))
918 $this->mpdf->setCSS($properties, 'INLINE');
919
920 // mPDF 6 Bidirectional formatting for inline elements
921 $bdf = false;
922 $bdf2 = '';
923 $popd = '';
924
925 // Get current direction
926 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction'])) {
927 $currdir = $this->mpdf->blk[$this->mpdf->blklvl]['direction'];
928 } else {
929 $currdir = 'ltr';
930 }
931 if ($this->mpdf->tableLevel && isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['direction']) && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['direction'] == 'rtl') {
932 $currdir = 'rtl';
933 }
934 if (isset($attr['DIR']) and $attr['DIR'] != '') {
935 $currdir = strtolower($attr['DIR']);
936 }
937 if (isset($properties['DIRECTION'])) {
938 $currdir = strtolower($properties['DIRECTION']);
939 }
940
941 // mPDF 6 bidi
942 // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
943 if ($tag == 'BDO') {
944 if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
945 $bdf = 0x202E;
946 $popd = 'RLOPDF';
947 } // U+202E RLO
948 else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
949 $bdf = 0x202D;
950 $popd = 'LROPDF';
951 } // U+202D LRO
952 } else if ($tag == 'BDI') {
953 if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
954 $bdf = 0x2067;
955 $popd = 'RLIPDI';
956 } // U+2067 RLI
957 else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
958 $bdf = 0x2066;
959 $popd = 'LRIPDI';
960 } // U+2066 LRI
961 else {
962 $bdf = 0x2068;
963 $popd = 'FSIPDI';
964 } // U+2068 FSI
965 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'bidi-override') {
966 if ($currdir == 'rtl') {
967 $bdf = 0x202E;
968 $popd = 'RLOPDF';
969 } // U+202E RLO
970 else {
971 $bdf = 0x202D;
972 $popd = 'LROPDF';
973 } // U+202D LRO
974 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'embed') {
975 if ($currdir == 'rtl') {
976 $bdf = 0x202B;
977 $popd = 'RLEPDF';
978 } // U+202B RLE
979 else {
980 $bdf = 0x202A;
981 $popd = 'LREPDF';
982 } // U+202A LRE
983 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate') {
984 if ($currdir == 'rtl') {
985 $bdf = 0x2067;
986 $popd = 'RLIPDI';
987 } // U+2067 RLI
988 else {
989 $bdf = 0x2066;
990 $popd = 'LRIPDI';
991 } // U+2066 LRI
992 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate-override') {
993 if ($currdir == 'rtl') {
994 $bdf = 0x2067;
995 $bdf2 = 0x202E;
996 $popd = 'RLIRLOPDFPDI';
997 } // U+2067 RLI // U+202E RLO
998 else {
999 $bdf = 0x2066;
1000 $bdf2 = 0x202D;
1001 $popd = 'LRILROPDFPDI';
1002 } // U+2066 LRI // U+202D LRO
1003 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') {
1004 $bdf = 0x2068;
1005 $popd = 'FSIPDI'; // U+2068 FSI
1006 } else {
1007 if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
1008 $bdf = 0x202B;
1009 $popd = 'RLEPDF';
1010 } // U+202B RLE
1011 else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
1012 $bdf = 0x202A;
1013 $popd = 'LREPDF';
1014 } // U+202A LRE
1015 }
1016
1017 if ($bdf) {
1018 // mPDF 5.7.3 Inline tags
1019 if (!isset($this->mpdf->InlineBDF[$tag])) {
1020 $this->mpdf->InlineBDF[$tag] = array(array($popd, $this->mpdf->InlineBDFctr));
1021 } else {
1022 $this->mpdf->InlineBDF[$tag][] = array($popd, $this->mpdf->InlineBDFctr);
1023 }
1024 $this->mpdf->InlineBDFctr++;
1025 if ($bdf2) {
1026 $bdf2 = code2utf($bdf);
1027 }
1028 $this->mpdf->OTLdata = array();
1029 if ($this->mpdf->tableLevel) {
1030 $this->mpdf->_saveCellTextBuffer(code2utf($bdf) . $bdf2);
1031 } else {
1032 $this->mpdf->_saveTextBuffer(code2utf($bdf) . $bdf2);
1033 }
1034 $this->mpdf->biDirectional = true;
1035 }
1036
1037 break;
1038
1039
1040 case 'A':
1041 if (isset($attr['NAME']) and $attr['NAME'] != '') {
1042 $e = '';
1043 /* -- BOOKMARKS -- */
1044 if ($this->mpdf->anchor2Bookmark) {
1045 $objattr = array();
1046 $objattr['CONTENT'] = htmlspecialchars_decode($attr['NAME'], ENT_QUOTES);
1047 $objattr['type'] = 'bookmark';
1048 if (isset($attr['LEVEL']) && $attr['LEVEL']) {
1049 $objattr['bklevel'] = $attr['LEVEL'];
1050 } else {
1051 $objattr['bklevel'] = 0;
1052 }
1053 $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
1054 }
1055 /* -- END BOOKMARKS -- */
1056 if ($this->mpdf->tableLevel) { // *TABLES*
1057 $this->mpdf->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
1058 } // *TABLES*
1059 else { // *TABLES*
1060 $this->mpdf->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
1061 } // *TABLES*
1062 }
1063 if (isset($attr['HREF'])) {
1064 $this->mpdf->InlineProperties['A'] = $this->mpdf->saveInlineProperties();
1065 $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
1066 if (!empty($properties))
1067 $this->mpdf->setCSS($properties, 'INLINE');
1068 $this->mpdf->HREF = $attr['HREF']; // mPDF 5.7.4 URLs
1069 }
1070 break;
1071
1072 case 'LEGEND':
1073 $this->mpdf->InlineProperties['LEGEND'] = $this->mpdf->saveInlineProperties();
1074 $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
1075 if (!empty($properties))
1076 $this->mpdf->setCSS($properties, 'INLINE');
1077 break;
1078
1079
1080
1081 case 'PROGRESS':
1082 case 'METER':
1083 $this->mpdf->inMeter = true;
1084
1085 if (isset($attr['MAX']) && $attr['MAX']) {
1086 $max = $attr['MAX'];
1087 } else {
1088 $max = 1;
1089 }
1090 if (isset($attr['MIN']) && $attr['MIN'] && $tag == 'METER') {
1091 $min = $attr['MIN'];
1092 } else {
1093 $min = 0;
1094 }
1095 if ($max < $min) {
1096 $max = $min;
1097 }
1098
1099 if (isset($attr['VALUE']) && ($attr['VALUE'] || $attr['VALUE'] === '0')) {
1100 $value = $attr['VALUE'];
1101 if ($value < $min) {
1102 $value = $min;
1103 } else if ($value > $max) {
1104 $value = $max;
1105 }
1106 } else {
1107 $value = '';
1108 }
1109
1110 if (isset($attr['LOW']) && $attr['LOW']) {
1111 $low = $attr['LOW'];
1112 } else {
1113 $low = $min;
1114 }
1115 if ($low < $min) {
1116 $low = $min;
1117 } else if ($low > $max) {
1118 $low = $max;
1119 }
1120 if (isset($attr['HIGH']) && $attr['HIGH']) {
1121 $high = $attr['HIGH'];
1122 } else {
1123 $high = $max;
1124 }
1125 if ($high < $low) {
1126 $high = $low;
1127 } else if ($high > $max) {
1128 $high = $max;
1129 }
1130 if (isset($attr['OPTIMUM']) && $attr['OPTIMUM']) {
1131 $optimum = $attr['OPTIMUM'];
1132 } else {
1133 $optimum = $min + (($max - $min) / 2);
1134 }
1135 if ($optimum < $min) {
1136 $optimum = $min;
1137 } else if ($optimum > $max) {
1138 $optimum = $max;
1139 }
1140 if (isset($attr['TYPE']) && $attr['TYPE']) {
1141 $type = $attr['TYPE'];
1142 } else {
1143 $type = '';
1144 }
1145 $objattr = array();
1146 $objattr['margin_top'] = 0;
1147 $objattr['margin_bottom'] = 0;
1148 $objattr['margin_left'] = 0;
1149 $objattr['margin_right'] = 0;
1150 $objattr['padding_top'] = 0;
1151 $objattr['padding_bottom'] = 0;
1152 $objattr['padding_left'] = 0;
1153 $objattr['padding_right'] = 0;
1154 $objattr['width'] = 0;
1155 $objattr['height'] = 0;
1156 $objattr['border_top']['w'] = 0;
1157 $objattr['border_bottom']['w'] = 0;
1158 $objattr['border_left']['w'] = 0;
1159 $objattr['border_right']['w'] = 0;
1160
1161 $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
1162 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
1163 return;
1164 }
1165 $objattr['visibility'] = 'visible';
1166 if (isset($properties['VISIBILITY'])) {
1167 $v = strtolower($properties['VISIBILITY']);
1168 if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') {
1169 $objattr['visibility'] = $v;
1170 }
1171 }
1172
1173 if (isset($properties['MARGIN-TOP'])) {
1174 $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1175 }
1176 if (isset($properties['MARGIN-BOTTOM'])) {
1177 $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1178 }
1179 if (isset($properties['MARGIN-LEFT'])) {
1180 $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1181 }
1182 if (isset($properties['MARGIN-RIGHT'])) {
1183 $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1184 }
1185
1186 if (isset($properties['PADDING-TOP'])) {
1187 $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1188 }
1189 if (isset($properties['PADDING-BOTTOM'])) {
1190 $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1191 }
1192 if (isset($properties['PADDING-LEFT'])) {
1193 $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1194 }
1195 if (isset($properties['PADDING-RIGHT'])) {
1196 $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1197 }
1198
1199 if (isset($properties['BORDER-TOP'])) {
1200 $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
1201 }
1202 if (isset($properties['BORDER-BOTTOM'])) {
1203 $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
1204 }
1205 if (isset($properties['BORDER-LEFT'])) {
1206 $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
1207 }
1208 if (isset($properties['BORDER-RIGHT'])) {
1209 $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
1210 }
1211
1212 if (isset($properties['VERTICAL-ALIGN'])) {
1213 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
1214 }
1215 $w = 0;
1216 $h = 0;
1217 if (isset($properties['WIDTH']))
1218 $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1219 else if (isset($attr['WIDTH']))
1220 $w = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1221
1222 if (isset($properties['HEIGHT']))
1223 $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1224 else if (isset($attr['HEIGHT']))
1225 $h = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1226
1227 if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
1228 $objattr['opacity'] = $properties['OPACITY'];
1229 }
1230 if ($this->mpdf->HREF) {
1231 if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) {
1232 $href = $this->mpdf->HREF;
1233 while (array_key_exists($href, $this->mpdf->internallink))
1234 $href = "#" . $href;
1235 $this->mpdf->internallink[$href] = $this->mpdf->AddLink();
1236 $objattr['link'] = $this->mpdf->internallink[$href];
1237 } else {
1238 $objattr['link'] = $this->mpdf->HREF;
1239 }
1240 }
1241 $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
1242 $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
1243
1244 // Image file
1245 if (!class_exists('meter', false)) {
1246 include(_MPDF_PATH . 'classes/meter.php');
1247 }
1248 $this->mpdf->meter = new meter();
1249 $svg = $this->mpdf->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
1250 //Save to local file
1251 $srcpath = _MPDF_TEMP_PATH . '_tempSVG' . uniqid(rand(1, 100000), true) . '_' . strtolower($tag) . '.svg';
1252 file_put_contents($srcpath, $svg);
1253 $orig_srcpath = $srcpath;
1254 $this->mpdf->GetFullPath($srcpath);
1255
1256 $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath);
1257 if (!$info) {
1258 $info = $this->mpdf->_getImage($this->mpdf->noImageFile);
1259 if ($info) {
1260 $srcpath = $this->mpdf->noImageFile;
1261 $w = ($info['w'] * (25.4 / $this->mpdf->dpi));
1262 $h = ($info['h'] * (25.4 / $this->mpdf->dpi));
1263 }
1264 }
1265 if (!$info)
1266 break;
1267
1268 $objattr['file'] = $srcpath;
1269 //Default width and height calculation if needed
1270 if ($w == 0 and $h == 0) {
1271 // SVG units are pixels
1272 $w = $this->mpdf->FontSize / (10 / _MPDFK) * abs($info['w']) / _MPDFK;
1273 $h = $this->mpdf->FontSize / (10 / _MPDFK) * abs($info['h']) / _MPDFK;
1274 }
1275 // IF WIDTH OR HEIGHT SPECIFIED
1276 if ($w == 0)
1277 $w = abs($h * $info['w'] / $info['h']);
1278 if ($h == 0)
1279 $h = abs($w * $info['h'] / $info['w']);
1280
1281 // Resize to maximum dimensions of page
1282 $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
1283 $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 1);
1284 if ($this->mpdf->fullImageHeight) {
1285 $maxHeight = $this->mpdf->fullImageHeight;
1286 }
1287 if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth
1288 $w = $maxWidth - $extrawidth;
1289 $h = abs($w * $info['h'] / $info['w']);
1290 }
1291
1292 if ($h + $extraheight > $maxHeight) {
1293 $h = $maxHeight - $extraheight;
1294 $w = abs($h * $info['w'] / $info['h']);
1295 }
1296 $objattr['type'] = 'image';
1297 $objattr['itype'] = $info['type'];
1298
1299 $objattr['orig_h'] = $info['h'];
1300 $objattr['orig_w'] = $info['w'];
1301 $objattr['wmf_x'] = $info['x'];
1302 $objattr['wmf_y'] = $info['y'];
1303 $objattr['height'] = $h + $extraheight;
1304 $objattr['width'] = $w + $extrawidth;
1305 $objattr['image_height'] = $h;
1306 $objattr['image_width'] = $w;
1307 $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
1308 $properties = array();
1309 if ($this->mpdf->tableLevel) {
1310 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
1311 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
1312 } else {
1313 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
1314 }
1315
1316 break;
1317
1318
1319 case 'BR':
1320 // Added mPDF 3.0 Float DIV - CLEAR
1321 if (isset($attr['STYLE'])) {
1322 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['STYLE']);
1323 if (isset($properties['CLEAR'])) {
1324 $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl);
1325 } // *CSS-FLOAT*
1326 }
1327
1328 // mPDF 6 bidi
1329 // Inline
1330 // If unicode-bidi set, any embedding levels, isolates, or overrides started by the inline box are closed at the br and reopened on the other side
1331 $blockpre = '';
1332 $blockpost = '';
1333 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
1334 $blockpre = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
1335 $blockpost = $this->mpdf->_setBidiCodes('start', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
1336 }
1337
1338 // Inline
1339 // If unicode-bidi set, any embedding levels, isolates, or overrides started by the inline box are closed at the br and reopened on the other side
1340 $inlinepre = '';
1341 $inlinepost = '';
1342 $iBDF = array();
1343 if (count($this->mpdf->InlineBDF)) {
1344 foreach ($this->mpdf->InlineBDF AS $k => $ib) {
1345 foreach ($ib AS $ib2) {
1346 $iBDF[$ib2[1]] = $ib2[0];
1347 }
1348 }
1349 if (count($iBDF)) {
1350 ksort($iBDF);
1351 for ($i = count($iBDF) - 1; $i >= 0; $i--) {
1352 $inlinepre .= $this->mpdf->_setBidiCodes('end', $iBDF[$i]);
1353 }
1354 for ($i = 0; $i < count($iBDF); $i++) {
1355 $inlinepost .= $this->mpdf->_setBidiCodes('start', $iBDF[$i]);
1356 }
1357 }
1358 }
1359
1360 /* -- TABLES -- */
1361 if ($this->mpdf->tableLevel) {
1362
1363 if ($this->mpdf->blockjustfinished) {
1364 $this->mpdf->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
1365 }
1366
1367 $this->mpdf->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
1368 if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
1369 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
1370 } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
1371 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
1372 }
1373 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
1374 } else {
1375 /* -- END TABLES -- */
1376 if (count($this->mpdf->textbuffer)) {
1377 $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0] = preg_replace('/ $/', '', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0]);
1378 if (!empty($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18])) {
1379 $this->mpdf->otl->trimOTLdata($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18], false, true);
1380 } // *OTL*
1381 }
1382 $this->mpdf->_saveTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
1383 } // *TABLES*
1384 $this->mpdf->ignorefollowingspaces = true;
1385 $this->mpdf->blockjustfinished = false;
1386
1387 $this->mpdf->linebreakjustfinished = true;
1388 break;
1389
1390
1391 // *********** BLOCKS ********************
1392
1393
1394 case 'PRE':
1395 $this->mpdf->ispre = true; // ADDED - Prevents left trim of textbuffer in printbuffer()
1396
1397 case 'DIV':
1398 case 'FORM':
1399 case 'CENTER':
1400
1401 case 'BLOCKQUOTE':
1402 case 'ADDRESS':
1403
1404 case 'CAPTION':
1405 case 'P':
1406 case 'H1':
1407 case 'H2':
1408 case 'H3':
1409 case 'H4':
1410 case 'H5':
1411 case 'H6':
1412 case 'DL':
1413 case 'DT':
1414 case 'DD':
1415 case 'UL': // mPDF 6 Lists
1416 case 'OL': // mPDF 6
1417 case 'LI': // mPDF 6
1418 case 'FIELDSET':
1419 case 'DETAILS':
1420 case 'SUMMARY':
1421 case 'ARTICLE':
1422 case 'ASIDE':
1423 case 'FIGURE':
1424 case 'FIGCAPTION':
1425 case 'FOOTER':
1426 case 'HEADER':
1427 case 'HGROUP':
1428 case 'NAV':
1429 case 'SECTION':
1430 case 'MAIN':
1431 // mPDF 6 Lists
1432 $this->mpdf->lastoptionaltag = '';
1433
1434 // mPDF 6 bidi
1435 // Block
1436 // If unicode-bidi set on current clock, any embedding levels, isolates, or overrides are closed (not inherited)
1437 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
1438 $blockpost = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
1439 if ($blockpost) {
1440 $this->mpdf->OTLdata = array();
1441 if ($this->mpdf->tableLevel) {
1442 $this->mpdf->_saveCellTextBuffer($blockpost);
1443 } else {
1444 $this->mpdf->_saveTextBuffer($blockpost);
1445 }
1446 }
1447 }
1448
1449
1450 $p = $this->mpdf->cssmgr->PreviewBlockCSS($tag, $attr);
1451 if (isset($p['DISPLAY']) && strtolower($p['DISPLAY']) == 'none') {
1452 $this->mpdf->blklvl++;
1453 $this->mpdf->blk[$this->mpdf->blklvl]['hide'] = true;
1454 $this->mpdf->blk[$this->mpdf->blklvl]['tag'] = $tag; // mPDF 6
1455 return;
1456 }
1457 if ($tag == 'CAPTION') {
1458 // position is written in AdjstHTML
1459 if (isset($attr['POSITION']) && strtolower($attr['POSITION']) == 'bottom') {
1460 $divpos = 'B';
1461 } else {
1462 $divpos = 'T';
1463 }
1464 if (isset($attr['ALIGN']) && strtolower($attr['ALIGN']) == 'bottom') {
1465 $cappos = 'B';
1466 } else if (isset($p['CAPTION-SIDE']) && strtolower($p['CAPTION-SIDE']) == 'bottom') {
1467 $cappos = 'B';
1468 } else {
1469 $cappos = 'T';
1470 }
1471 if (isset($attr['ALIGN'])) {
1472 unset($attr['ALIGN']);
1473 }
1474 if ($cappos != $divpos) {
1475 $this->mpdf->blklvl++;
1476 $this->mpdf->blk[$this->mpdf->blklvl]['hide'] = true;
1477 $this->mpdf->blk[$this->mpdf->blklvl]['tag'] = $tag; // mPDF 6
1478 return;
1479 }
1480 }
1481
1482 /* -- FORMS -- */
1483 if ($tag == 'FORM') {
1484 if (isset($attr['METHOD']) && strtolower($attr['METHOD']) == 'get') {
1485 $this->mpdf->mpdfform->formMethod = 'GET';
1486 } else {
1487 $this->mpdf->mpdfform->formMethod = 'POST';
1488 }
1489 if (isset($attr['ACTION'])) {
1490 $this->mpdf->mpdfform->formAction = $attr['ACTION'];
1491 } else {
1492 $this->mpdf->mpdfform->formAction = '';
1493 }
1494 }
1495 /* -- END FORMS -- */
1496
1497
1498 /* -- CSS-POSITION -- */
1499 if ((isset($p['POSITION']) && (strtolower($p['POSITION']) == 'fixed' || strtolower($p['POSITION']) == 'absolute')) && $this->mpdf->blklvl == 0) {
1500 if ($this->mpdf->inFixedPosBlock) {
1501 throw new MpdfException("Cannot nest block with position:fixed or position:absolute");
1502 }
1503 $this->mpdf->inFixedPosBlock = true;
1504 return;
1505 }
1506 /* -- END CSS-POSITION -- */
1507 // Start Block
1508 $this->mpdf->ignorefollowingspaces = true;
1509
1510 if ($this->mpdf->blockjustfinished && !count($this->mpdf->textbuffer) && $this->mpdf->y != $this->mpdf->tMargin && $this->mpdf->collapseBlockMargins) {
1511 $lastbottommargin = $this->mpdf->lastblockbottommargin;
1512 } else {
1513 $lastbottommargin = 0;
1514 }
1515 $this->mpdf->lastblockbottommargin = 0;
1516 $this->mpdf->blockjustfinished = false;
1517
1518
1519 $this->mpdf->InlineBDF = array(); // mPDF 6
1520 $this->mpdf->InlineBDFctr = 0; // mPDF 6
1521 $this->mpdf->InlineProperties = array();
1522 $this->mpdf->divbegin = true;
1523
1524 $this->mpdf->linebreakjustfinished = false;
1525
1526 /* -- TABLES -- */
1527 if ($this->mpdf->tableLevel) {
1528 // If already something on the line
1529 if ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] > 0 && !$this->mpdf->nestedtablejustfinished) {
1530 $this->mpdf->_saveCellTextBuffer("\n");
1531 if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
1532 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
1533 } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
1534 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
1535 }
1536 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
1537 }
1538 // Cannot set block properties inside table - use Bold to indicate h1-h6
1539 if ($tag == 'CENTER' && $this->mpdf->tdbegin) {
1540 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'] = $align['center'];
1541 }
1542
1543 $this->mpdf->InlineProperties['BLOCKINTABLE'] = $this->mpdf->saveInlineProperties();
1544 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
1545 if (!empty($properties))
1546 $this->mpdf->setCSS($properties, 'INLINE');
1547
1548 // mPDF 6 Lists
1549 if ($tag == 'UL' || $tag == 'OL') {
1550 $this->mpdf->listlvl++;
1551 if (isset($attr['START'])) {
1552 $this->mpdf->listcounter[$this->mpdf->listlvl] = intval($attr['START']) - 1;
1553 } else {
1554 $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
1555 }
1556 $this->mpdf->listitem = array();
1557 if ($tag == 'OL')
1558 $this->mpdf->listtype[$this->mpdf->listlvl] = 'decimal';
1559 else if ($tag == 'UL') {
1560 if ($this->mpdf->listlvl % 3 == 1)
1561 $this->mpdf->listtype[$this->mpdf->listlvl] = 'disc';
1562 elseif ($this->mpdf->listlvl % 3 == 2)
1563 $this->mpdf->listtype[$this->mpdf->listlvl] = 'circle';
1564 else
1565 $this->mpdf->listtype[$this->mpdf->listlvl] = 'square';
1566 }
1567 }
1568
1569 // mPDF 6 Lists - in Tables
1570 if ($tag == 'LI') {
1571 if ($this->mpdf->listlvl == 0) { //in case of malformed HTML code. Example:(...)</p><li>Content</li><p>Paragraph1</p>(...)
1572 $this->mpdf->listlvl++; // first depth level
1573 $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
1574 }
1575 $this->mpdf->listcounter[$this->mpdf->listlvl] ++;
1576 $this->mpdf->listitem = array();
1577 //if in table - output here as a tabletextbuffer
1578 //position:inside OR position:outside (always output in table as position:inside)
1579 switch ($this->mpdf->listtype[$this->mpdf->listlvl]) {
1580 case 'upper-alpha':
1581 case 'upper-latin':
1582 case 'A':
1583 $blt = $this->mpdf->dec2alpha($this->mpdf->listcounter[$this->mpdf->listlvl], true) . $this->mpdf->list_number_suffix;
1584 break;
1585 case 'lower-alpha':
1586 case 'lower-latin':
1587 case 'a':
1588 $blt = $this->mpdf->dec2alpha($this->mpdf->listcounter[$this->mpdf->listlvl], false) . $this->mpdf->list_number_suffix;
1589 break;
1590 case 'upper-roman':
1591 case 'I':
1592 $blt = $this->mpdf->dec2roman($this->mpdf->listcounter[$this->mpdf->listlvl], true) . $this->mpdf->list_number_suffix;
1593 break;
1594 case 'lower-roman':
1595 case 'i':
1596 $blt = $this->mpdf->dec2roman($this->mpdf->listcounter[$this->mpdf->listlvl], false) . $this->mpdf->list_number_suffix;
1597 break;
1598 case 'decimal':
1599 case '1':
1600 $blt = $this->mpdf->listcounter[$this->mpdf->listlvl] . $this->mpdf->list_number_suffix;
1601 break;
1602 default:
1603 if ($this->mpdf->listlvl % 3 == 1 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 8226)) {
1604 $blt = "\xe2\x80\xa2";
1605 } // &#8226;
1606 else if ($this->mpdf->listlvl % 3 == 2 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9900)) {
1607 $blt = "\xe2\x9a\xac";
1608 } // &#9900;
1609 else if ($this->mpdf->listlvl % 3 == 0 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9642)) {
1610 $blt = "\xe2\x96\xaa";
1611 } // &#9642;
1612 else {
1613 $blt = '-';
1614 }
1615 break;
1616 }
1617
1618 // change to &nbsp; spaces
1619 if ($this->mpdf->usingCoreFont) {
1620 $ls = str_repeat(chr(160) . chr(160), ($this->mpdf->listlvl - 1) * 2) . $blt . ' ';
1621 } else {
1622 $ls = str_repeat("\xc2\xa0\xc2\xa0", ($this->mpdf->listlvl - 1) * 2) . $blt . ' ';
1623 }
1624 $this->mpdf->_saveCellTextBuffer($ls);
1625 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $this->mpdf->GetStringWidth($ls);
1626 }
1627
1628 break;
1629 }
1630 /* -- END TABLES -- */
1631
1632 if ($this->mpdf->lastblocklevelchange == 1) {
1633 $blockstate = 1;
1634 } // Top margins/padding only
1635 else if ($this->mpdf->lastblocklevelchange < 1) {
1636 $blockstate = 0;
1637 } // NO margins/padding
1638 $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
1639 $this->mpdf->textbuffer = array();
1640
1641 $save_blklvl = $this->mpdf->blklvl;
1642 $save_blk = $this->mpdf->blk;
1643
1644 $this->mpdf->Reset();
1645
1646 $pagesel = '';
1647 /* -- CSS-PAGE -- */
1648 if (isset($p['PAGE'])) {
1649 $pagesel = $p['PAGE'];
1650 } // mPDF 6 (uses $p - preview of properties so blklvl can be incremented after page-break)
1651 /* -- END CSS-PAGE -- */
1652
1653 // If page-box has changed AND/OR PAGE-BREAK-BEFORE
1654 // mPDF 6 (uses $p - preview of properties so blklvl can be imcremented after page-break)
1655 if (!$this->mpdf->tableLevel && (($pagesel && (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current'])) || (isset($p['PAGE-BREAK-BEFORE']) && $p['PAGE-BREAK-BEFORE']))) {
1656 // mPDF 6 pagebreaktype
1657 $startpage = $this->mpdf->page;
1658 $pagebreaktype = $this->mpdf->defaultPagebreakType;
1659 $this->mpdf->lastblocklevelchange = -1;
1660 if ($this->mpdf->ColActive) {
1661 $pagebreaktype = 'cloneall';
1662 }
1663 if ($pagesel && (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current'])) {
1664 $pagebreaktype = 'cloneall';
1665 }
1666 $this->mpdf->_preForcedPagebreak($pagebreaktype);
1667
1668 if (isset($p['PAGE-BREAK-BEFORE'])) {
1669 if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'RIGHT') {
1670 $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
1671 } else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'LEFT') {
1672 $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
1673 } else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'ALWAYS') {
1674 $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
1675 } else if ($this->mpdf->page_box['current'] != $pagesel) {
1676 $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
1677 } // *CSS-PAGE*
1678 }
1679 /* -- CSS-PAGE -- */
1680 // Must Add new page if changed page properties
1681 else if (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current']) {
1682 $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel);
1683 }
1684 /* -- END CSS-PAGE -- */
1685
1686 // mPDF 6 pagebreaktype
1687 $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
1688 }
1689
1690 // mPDF 6 pagebreaktype - moved after pagebreak
1691 $this->mpdf->blklvl++;
1692 $currblk = & $this->mpdf->blk[$this->mpdf->blklvl];
1693 $this->mpdf->initialiseBlock($currblk);
1694 $prevblk = & $this->mpdf->blk[$this->mpdf->blklvl - 1];
1695 $currblk['tag'] = $tag;
1696 $currblk['attr'] = $attr;
1697
1698 $properties = $this->mpdf->cssmgr->MergeCSS('BLOCK', $tag, $attr); // mPDF 6 - moved to after page-break-before
1699 // mPDF 6 page-break-inside:avoid
1700 if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together && !isset($attr['PAGEBREAKAVOIDCHECKED'])) { // avoid re-iterating using PAGEBREAKAVOIDCHECKED; set in CloseTag
1701 $currblk['keep_block_together'] = 1;
1702 $currblk['array_i'] = $ihtml; // mPDF 6
1703 $this->mpdf->kt_y00 = $this->mpdf->y;
1704 $this->mpdf->kt_p00 = $this->mpdf->page;
1705 $this->mpdf->keep_block_together = 1;
1706 }
1707 if ($lastbottommargin && isset($properties['MARGIN-TOP']) && $properties['MARGIN-TOP'] && empty($properties['FLOAT'])) {
1708 $currblk['lastbottommargin'] = $lastbottommargin;
1709 }
1710
1711 if (isset($properties['Z-INDEX']) && $this->mpdf->current_layer == 0) {
1712 $v = intval($properties['Z-INDEX']);
1713 if ($v > 0) {
1714 $currblk['z-index'] = $v;
1715 $this->mpdf->BeginLayer($v);
1716 }
1717 }
1718
1719
1720 // mPDF 6 Lists
1721 // List-type set by attribute
1722 if ($tag == 'OL' || $tag == 'UL' || $tag == 'LI') {
1723 if (isset($attr['TYPE']) && $attr['TYPE']) {
1724 $listtype = $attr['TYPE'];
1725 switch ($listtype) {
1726 case 'A':
1727 $listtype = 'upper-latin';
1728 break;
1729 case 'a':
1730 $listtype = 'lower-latin';
1731 break;
1732 case 'I':
1733 $listtype = 'upper-roman';
1734 break;
1735 case 'i':
1736 $listtype = 'lower-roman';
1737 break;
1738 case '1':
1739 $listtype = 'decimal';
1740 break;
1741 }
1742 $currblk['list_style_type'] = $listtype;
1743 }
1744 }
1745
1746 $this->mpdf->setCSS($properties, 'BLOCK', $tag); //name(id/class/style) found in the CSS array!
1747 $currblk['InlineProperties'] = $this->mpdf->saveInlineProperties();
1748
1749 if (isset($properties['VISIBILITY'])) {
1750 $v = strtolower($properties['VISIBILITY']);
1751 if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible' && !$this->mpdf->tableLevel) {
1752 $currblk['visibility'] = $v;
1753 $this->mpdf->SetVisibility($v);
1754 }
1755 }
1756
1757 // mPDF 6
1758 if (isset($attr['ALIGN']) && $attr['ALIGN']) {
1759 $currblk['block-align'] = $align[strtolower($attr['ALIGN'])];
1760 }
1761
1762
1763 if (isset($properties['HEIGHT'])) {
1764 $currblk['css_set_height'] = $this->mpdf->ConvertSize($properties['HEIGHT'], ($this->mpdf->h - $this->mpdf->tMargin - $this->mpdf->bMargin), $this->mpdf->FontSize, false);
1765 if (($currblk['css_set_height'] + $this->mpdf->y) > $this->mpdf->PageBreakTrigger && $this->mpdf->y > $this->mpdf->tMargin + 5 && $currblk['css_set_height'] < ($this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin))) {
1766 $this->mpdf->AddPage($this->mpdf->CurOrientation);
1767 }
1768 } else {
1769 $currblk['css_set_height'] = false;
1770 }
1771
1772
1773 // Added mPDF 3.0 Float DIV
1774 if (isset($prevblk['blockContext'])) {
1775 $currblk['blockContext'] = $prevblk['blockContext'];
1776 } // *CSS-FLOAT*
1777
1778 if (isset($properties['CLEAR'])) {
1779 $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl - 1);
1780 } // *CSS-FLOAT*
1781
1782 $container_w = $prevblk['inner_width'];
1783 $bdr = $currblk['border_right']['w'];
1784 $bdl = $currblk['border_left']['w'];
1785 $pdr = $currblk['padding_right'];
1786 $pdl = $currblk['padding_left'];
1787
1788 if (isset($currblk['css_set_width'])) {
1789 $setwidth = $currblk['css_set_width'];
1790 } else {
1791 $setwidth = 0;
1792 }
1793
1794 /* -- CSS-FLOAT -- */
1795 if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'RIGHT' && !$this->mpdf->ColActive) {
1796 // Cancel Keep-Block-together
1797 $currblk['keep_block_together'] = false;
1798 $this->mpdf->kt_y00 = '';
1799 $this->mpdf->keep_block_together = 0;
1800
1801 $this->mpdf->blockContext++;
1802 $currblk['blockContext'] = $this->mpdf->blockContext;
1803
1804 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
1805
1806 // DIV is too narrow for text to fit!
1807 $maxw = $container_w - $l_width - $r_width;
1808 if (($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) {
1809 // Too narrow to fit - try to move down past L or R float
1810 if ($l_max < $r_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $r_width) && (($container_w - $r_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
1811 $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1);
1812 } else if ($r_max < $l_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $l_width) && (($container_w - $l_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
1813 $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1);
1814 } else {
1815 $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1);
1816 }
1817 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
1818 }
1819
1820 if ($r_exists) {
1821 $currblk['margin_right'] += $r_width;
1822 }
1823
1824 $currblk['float'] = 'R';
1825 $currblk['float_start_y'] = $this->mpdf->y;
1826 if ($currblk['css_set_width']) {
1827 $currblk['margin_left'] = $container_w - ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
1828 $currblk['float_width'] = ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
1829 } else {
1830 // *** If no width set - would need to buffer and keep track of max width, then Right-align if not full width
1831 // and do borders and backgrounds - For now - just set to maximum width left
1832
1833 if ($l_exists) {
1834 $currblk['margin_left'] += $l_width;
1835 }
1836 $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr);
1837
1838 $currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']);
1839 }
1840 } else if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'LEFT' && !$this->mpdf->ColActive) {
1841 // Cancel Keep-Block-together
1842 $currblk['keep_block_together'] = false;
1843 $this->mpdf->kt_y00 = '';
1844 $this->mpdf->keep_block_together = 0;
1845
1846 $this->mpdf->blockContext++;
1847 $currblk['blockContext'] = $this->mpdf->blockContext;
1848
1849 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
1850
1851 // DIV is too narrow for text to fit!
1852 $maxw = $container_w - $l_width - $r_width;
1853 if (($setwidth + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) {
1854 // Too narrow to fit - try to move down past L or R float
1855 if ($l_max < $r_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $r_width) && (($container_w - $r_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
1856 $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1);
1857 } else if ($r_max < $l_max && ($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $l_width) && (($container_w - $l_width) - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
1858 $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1);
1859 } else {
1860 $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1);
1861 }
1862 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
1863 }
1864
1865 if ($l_exists) {
1866 $currblk['margin_left'] += $l_width;
1867 }
1868
1869 $currblk['float'] = 'L';
1870 $currblk['float_start_y'] = $this->mpdf->y;
1871 if ($setwidth) {
1872 $currblk['margin_right'] = $container_w - ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']);
1873 $currblk['float_width'] = ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']);
1874 } else {
1875 // *** If no width set - would need to buffer and keep track of max width, then Right-align if not full width
1876 // and do borders and backgrounds - For now - just set to maximum width left
1877
1878 if ($r_exists) {
1879 $currblk['margin_right'] += $r_width;
1880 }
1881 $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr);
1882
1883 $currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']);
1884 }
1885 } else {
1886 // Don't allow overlap - if floats present - adjust padding to avoid overlap with Floats
1887 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
1888 $maxw = $container_w - $l_width - $r_width;
1889 if (($setwidth + $currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_right'] + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) {
1890 // Too narrow to fit - try to move down past L or R float
1891 if ($l_max < $r_max && ($setwidth + $currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $r_width) && (($container_w - $r_width) - ($currblk['margin_right'] + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
1892 $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1);
1893 } else if ($r_max < $l_max && ($setwidth + $currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) <= ($container_w - $l_width) && (($container_w - $l_width) - ($currblk['margin_right'] + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) > (2 * $this->mpdf->GetCharWidth('W', false))) {
1894 $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1);
1895 } else {
1896 $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1);
1897 }
1898 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1);
1899 }
1900 if ($r_exists) {
1901 $currblk['padding_right'] = max(($r_width - $currblk['margin_right'] - $bdr), $pdr);
1902 }
1903 if ($l_exists) {
1904 $currblk['padding_left'] = max(($l_width - $currblk['margin_left'] - $bdl), $pdl);
1905 }
1906 }
1907 /* -- END CSS-FLOAT -- */
1908
1909
1910 /* -- BORDER-RADIUS -- */
1911 // Automatically increase padding if required for border-radius
1912 if ($this->mpdf->autoPadding && !$this->mpdf->ColActive) {
1913 if ($currblk['border_radius_TL_H'] > $currblk['padding_left'] && $currblk['border_radius_TL_V'] > $currblk['padding_top']) {
1914 if ($currblk['border_radius_TL_H'] > $currblk['border_radius_TL_V']) {
1915 $this->mpdf->_borderPadding($currblk['border_radius_TL_H'], $currblk['border_radius_TL_V'], $currblk['padding_left'], $currblk['padding_top']);
1916 } else {
1917 $this->mpdf->_borderPadding($currblk['border_radius_TL_V'], $currblk['border_radius_TL_H'], $currblk['padding_top'], $currblk['padding_left']);
1918 }
1919 }
1920 if ($currblk['border_radius_TR_H'] > $currblk['padding_right'] && $currblk['border_radius_TR_V'] > $currblk['padding_top']) {
1921 if ($currblk['border_radius_TR_H'] > $currblk['border_radius_TR_V']) {
1922 $this->mpdf->_borderPadding($currblk['border_radius_TR_H'], $currblk['border_radius_TR_V'], $currblk['padding_right'], $currblk['padding_top']);
1923 } else {
1924 $this->mpdf->_borderPadding($currblk['border_radius_TR_V'], $currblk['border_radius_TR_H'], $currblk['padding_top'], $currblk['padding_right']);
1925 }
1926 }
1927 if ($currblk['border_radius_BL_H'] > $currblk['padding_left'] && $currblk['border_radius_BL_V'] > $currblk['padding_bottom']) {
1928 if ($currblk['border_radius_BL_H'] > $currblk['border_radius_BL_V']) {
1929 $this->mpdf->_borderPadding($currblk['border_radius_BL_H'], $currblk['border_radius_BL_V'], $currblk['padding_left'], $currblk['padding_bottom']);
1930 } else {
1931 $this->mpdf->_borderPadding($currblk['border_radius_BL_V'], $currblk['border_radius_BL_H'], $currblk['padding_bottom'], $currblk['padding_left']);
1932 }
1933 }
1934 if ($currblk['border_radius_BR_H'] > $currblk['padding_right'] && $currblk['border_radius_BR_V'] > $currblk['padding_bottom']) {
1935 if ($currblk['border_radius_BR_H'] > $currblk['border_radius_BR_V']) {
1936 $this->mpdf->_borderPadding($currblk['border_radius_BR_H'], $currblk['border_radius_BR_V'], $currblk['padding_right'], $currblk['padding_bottom']);
1937 } else {
1938 $this->mpdf->_borderPadding($currblk['border_radius_BR_V'], $currblk['border_radius_BR_H'], $currblk['padding_bottom'], $currblk['padding_right']);
1939 }
1940 }
1941 }
1942 /* -- END BORDER-RADIUS -- */
1943
1944
1945 // Hanging indent - if negative indent: ensure padding is >= indent
1946 if (!isset($currblk['text_indent'])) {
1947 $currblk['text_indent'] = null;
1948 }
1949 if (!isset($currblk['inner_width'])) {
1950 $currblk['inner_width'] = null;
1951 }
1952 $cbti = $this->mpdf->ConvertSize($currblk['text_indent'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
1953 if ($cbti < 0) {
1954 $hangind = -($cbti);
1955 if (isset($currblk['direction']) && $currblk['direction'] == 'rtl') { // *OTL*
1956 $currblk['padding_right'] = max($currblk['padding_right'], $hangind); // *OTL*
1957 } // *OTL*
1958 else { // *OTL*
1959 $currblk['padding_left'] = max($currblk['padding_left'], $hangind);
1960 } // *OTL*
1961 }
1962
1963 if (isset($currblk['css_set_width'])) {
1964 if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT']) == 'auto' && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
1965 // Try to reduce margins to accomodate - if still too wide, set margin-right/left=0 (reduces width)
1966 $anyextra = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
1967 if ($anyextra > 0) {
1968 $currblk['margin_left'] = $currblk['margin_right'] = $anyextra / 2;
1969 } else {
1970 $currblk['margin_left'] = $currblk['margin_right'] = 0;
1971 }
1972 } else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
1973 // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
1974 $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']);
1975 if ($currblk['margin_left'] < 0) {
1976 $currblk['margin_left'] = 0;
1977 }
1978 } else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
1979 // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
1980 $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
1981 if ($currblk['margin_right'] < 0) {
1982 $currblk['margin_right'] = 0;
1983 }
1984 } else {
1985 if ($currblk['direction'] == 'rtl') { // *OTL*
1986 // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width)
1987 $currblk['margin_left'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_right']); // *OTL*
1988 if ($currblk['margin_left'] < 0) { // *OTL*
1989 $currblk['margin_left'] = 0; // *OTL*
1990 } // *OTL*
1991 } // *OTL*
1992 else { // *OTL*
1993 // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width)
1994 $currblk['margin_right'] = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right'] + $currblk['margin_left']);
1995 if ($currblk['margin_right'] < 0) {
1996 $currblk['margin_right'] = 0;
1997 }
1998 } // *OTL*
1999 }
2000 }
2001
2002 $currblk['outer_left_margin'] = $prevblk['outer_left_margin'] + $currblk['margin_left'] + $prevblk['border_left']['w'] + $prevblk['padding_left'];
2003 $currblk['outer_right_margin'] = $prevblk['outer_right_margin'] + $currblk['margin_right'] + $prevblk['border_right']['w'] + $prevblk['padding_right'];
2004
2005 $currblk['width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']);
2006 $currblk['inner_width'] = $currblk['width'] - ($currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
2007
2008 // Check DIV is not now too narrow to fit text
2009 $mw = 2 * $this->mpdf->GetCharWidth('W', false);
2010 if ($currblk['inner_width'] < $mw) {
2011 $currblk['padding_left'] = 0;
2012 $currblk['padding_right'] = 0;
2013 $currblk['border_left']['w'] = 0.2;
2014 $currblk['border_right']['w'] = 0.2;
2015 $currblk['margin_left'] = 0;
2016 $currblk['margin_right'] = 0;
2017 $currblk['outer_left_margin'] = $prevblk['outer_left_margin'] + $currblk['margin_left'] + $prevblk['border_left']['w'] + $prevblk['padding_left'];
2018 $currblk['outer_right_margin'] = $prevblk['outer_right_margin'] + $currblk['margin_right'] + $prevblk['border_right']['w'] + $prevblk['padding_right'];
2019 $currblk['width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']);
2020 $currblk['inner_width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']);
2021 // if ($currblk['inner_width'] < $mw) { throw new MpdfException("DIV is too narrow for text to fit!"); }
2022 }
2023
2024 $this->mpdf->x = $this->mpdf->lMargin + $currblk['outer_left_margin'];
2025
2026 /* -- BACKGROUNDS -- */
2027 if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together) {
2028 $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']);
2029 if ($ret) {
2030 $currblk['background-image'] = $ret;
2031 }
2032 }
2033 /* -- END BACKGROUNDS -- */
2034
2035 /* -- TABLES -- */
2036 if ($this->mpdf->use_kwt && isset($attr['KEEP-WITH-TABLE']) && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together) {
2037 $this->mpdf->kwt = true;
2038 $this->mpdf->kwt_y0 = $this->mpdf->y;
2039 //$this->mpdf->kwt_x0 = $this->mpdf->x;
2040 $this->mpdf->kwt_x0 = $this->mpdf->lMargin; // mPDF 6
2041 $this->mpdf->kwt_height = 0;
2042 $this->mpdf->kwt_buffer = array();
2043 $this->mpdf->kwt_Links = array();
2044 $this->mpdf->kwt_Annots = array();
2045 $this->mpdf->kwt_moved = false;
2046 $this->mpdf->kwt_saved = false;
2047 $this->mpdf->kwt_Reference = array();
2048 $this->mpdf->kwt_BMoutlines = array();
2049 $this->mpdf->kwt_toc = array();
2050 } else {
2051 /* -- END TABLES -- */
2052 $this->mpdf->kwt = false;
2053 } // *TABLES*
2054 //Save x,y coords in case we need to print borders...
2055 $currblk['y0'] = $this->mpdf->y;
2056 $currblk['initial_y0'] = $this->mpdf->y; // mPDF 6
2057 $currblk['x0'] = $this->mpdf->x;
2058 $currblk['initial_x0'] = $this->mpdf->x; // mPDF 6
2059 $currblk['initial_startpage'] = $this->mpdf->page;
2060 $currblk['startpage'] = $this->mpdf->page; // mPDF 6
2061 $this->mpdf->oldy = $this->mpdf->y;
2062
2063 $this->mpdf->lastblocklevelchange = 1;
2064
2065
2066 // mPDF 6 Lists
2067 if ($tag == 'OL' || $tag == 'UL') {
2068 $this->mpdf->listlvl++;
2069 if (isset($attr['START']) && $attr['START']) {
2070 $this->mpdf->listcounter[$this->mpdf->listlvl] = intval($attr['START']) - 1;
2071 } else {
2072 $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
2073 }
2074 $this->mpdf->listitem = array();
2075
2076 // List-type
2077 if (!isset($currblk['list_style_type']) || !$currblk['list_style_type']) {
2078 if ($tag == 'OL')
2079 $currblk['list_style_type'] = 'decimal';
2080 else if ($tag == 'UL') {
2081 if ($this->mpdf->listlvl % 3 == 1)
2082 $currblk['list_style_type'] = 'disc';
2083 elseif ($this->mpdf->listlvl % 3 == 2)
2084 $currblk['list_style_type'] = 'circle';
2085 else
2086 $currblk['list_style_type'] = 'square';
2087 }
2088 }
2089
2090 // List-image
2091 if (!isset($currblk['list_style_image']) || !$currblk['list_style_image']) {
2092 $currblk['list_style_image'] = 'none';
2093 }
2094
2095 // List-position
2096 if (!isset($currblk['list_style_position']) || !$currblk['list_style_position']) {
2097 $currblk['list_style_position'] = 'outside';
2098 }
2099
2100 // Default indentation using padding
2101 if (strtolower($this->mpdf->list_auto_mode) == 'mpdf' && isset($currblk['list_style_position']) && $currblk['list_style_position'] == 'outside' && isset($currblk['list_style_image']) && $currblk['list_style_image'] == 'none' && (!isset($currblk['list_style_type']) || !preg_match('/U\+([a-fA-F0-9]+)/i', $currblk['list_style_type']))) {
2102 $autopadding = $this->mpdf->_getListMarkerWidth($currblk, $ahtml, $ihtml);
2103 if ($this->mpdf->listlvl > 1 || $this->mpdf->list_indent_first_level) {
2104 $autopadding += $this->mpdf->ConvertSize($this->mpdf->list_indent_default_mpdf, $currblk['inner_width'], $this->mpdf->FontSize, false);
2105 }
2106 // autopadding value is applied to left or right according
2107 // to dir of block. Once a CSS value is set for padding it overrides this default value.
2108 if (isset($properties['PADDING-RIGHT']) && $properties['PADDING-RIGHT'] == 'auto' && isset($currblk['direction']) && $currblk['direction'] == 'rtl') {
2109 $currblk['padding_right'] = $autopadding;
2110 } else if (isset($properties['PADDING-LEFT']) && $properties['PADDING-LEFT'] == 'auto') {
2111 $currblk['padding_left'] = $autopadding;
2112 }
2113 } else {
2114 // Initial default value is set by $this->mpdf->list_indent_default in config.php; this value is applied to left or right according
2115 // to dir of block. Once a CSS value is set for padding it overrides this default value.
2116 if (isset($properties['PADDING-RIGHT']) && $properties['PADDING-RIGHT'] == 'auto' && isset($currblk['direction']) && $currblk['direction'] == 'rtl') {
2117 $currblk['padding_right'] = $this->mpdf->ConvertSize($this->mpdf->list_indent_default, $currblk['inner_width'], $this->mpdf->FontSize, false);
2118 } else if (isset($properties['PADDING-LEFT']) && $properties['PADDING-LEFT'] == 'auto') {
2119 $currblk['padding_left'] = $this->mpdf->ConvertSize($this->mpdf->list_indent_default, $currblk['inner_width'], $this->mpdf->FontSize, false);
2120 }
2121 }
2122 }
2123
2124
2125 // mPDF 6 Lists
2126 if ($tag == 'LI') {
2127 if ($this->mpdf->listlvl == 0) { //in case of malformed HTML code. Example:(...)</p><li>Content</li><p>Paragraph1</p>(...)
2128 $this->mpdf->listlvl++; // first depth level
2129 $this->mpdf->listcounter[$this->mpdf->listlvl] = 0;
2130 }
2131 $this->mpdf->listcounter[$this->mpdf->listlvl] ++;
2132 $this->mpdf->listitem = array();
2133
2134 // Listitem-type
2135 $this->mpdf->_setListMarker($currblk['list_style_type'], $currblk['list_style_image'], $currblk['list_style_position']);
2136 }
2137
2138 // mPDF 6 Bidirectional formatting for block elements
2139 $bdf = false;
2140 $bdf2 = '';
2141 $popd = '';
2142
2143 // Get current direction
2144 if (isset($currblk['direction'])) {
2145 $currdir = $currblk['direction'];
2146 } else {
2147 $currdir = 'ltr';
2148 }
2149 if (isset($attr['DIR']) and $attr['DIR'] != '') {
2150 $currdir = strtolower($attr['DIR']);
2151 }
2152 if (isset($properties['DIRECTION'])) {
2153 $currdir = strtolower($properties['DIRECTION']);
2154 }
2155
2156 // mPDF 6 bidi
2157 // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
2158 if (isset($properties ['UNICODE-BIDI']) && (strtolower($properties ['UNICODE-BIDI']) == 'bidi-override' || strtolower($properties ['UNICODE-BIDI']) == 'isolate-override')) {
2159 if ($currdir == 'rtl') {
2160 $bdf = 0x202E;
2161 $popd = 'RLOPDF';
2162 } // U+202E RLO
2163 else {
2164 $bdf = 0x202D;
2165 $popd = 'LROPDF';
2166 } // U+202D LRO
2167 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') {
2168 $bdf = 0x2068;
2169 $popd = 'FSIPDI'; // U+2068 FSI
2170 }
2171 if ($bdf) {
2172 if ($bdf2) {
2173 $bdf2 = code2utf($bdf);
2174 }
2175 $this->mpdf->OTLdata = array();
2176 if ($this->mpdf->tableLevel) {
2177 $this->mpdf->_saveCellTextBuffer(code2utf($bdf) . $bdf2);
2178 } else {
2179 $this->mpdf->_saveTextBuffer(code2utf($bdf) . $bdf2);
2180 }
2181 $this->mpdf->biDirectional = true;
2182 $currblk['bidicode'] = $popd;
2183 }
2184
2185 break;
2186
2187 case 'HR':
2188 // Added mPDF 3.0 Float DIV - CLEAR
2189 if (isset($attr['STYLE'])) {
2190 $properties = $this->mpdf->cssmgr->readInlineCSS($attr['STYLE']);
2191 if (isset($properties['CLEAR'])) {
2192 $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl);
2193 } // *CSS-FLOAT*
2194 }
2195
2196 $this->mpdf->ignorefollowingspaces = true;
2197
2198 $objattr = array();
2199 $objattr['margin_top'] = 0;
2200 $objattr['margin_bottom'] = 0;
2201 $objattr['margin_left'] = 0;
2202 $objattr['margin_right'] = 0;
2203 $objattr['width'] = 0;
2204 $objattr['height'] = 0;
2205 $objattr['border_top']['w'] = 0;
2206 $objattr['border_bottom']['w'] = 0;
2207 $objattr['border_left']['w'] = 0;
2208 $objattr['border_right']['w'] = 0;
2209 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
2210 if (isset($properties['MARGIN-TOP'])) {
2211 $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2212 }
2213 if (isset($properties['MARGIN-BOTTOM'])) {
2214 $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2215 }
2216 if (isset($properties['WIDTH'])) {
2217 $objattr['width'] = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
2218 } else if (isset($attr['WIDTH']) && $attr['WIDTH'] != '')
2219 $objattr['width'] = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
2220 if (isset($properties['TEXT-ALIGN'])) {
2221 $objattr['align'] = $align[strtolower($properties['TEXT-ALIGN'])];
2222 } else if (isset($attr['ALIGN']) && $attr['ALIGN'] != '')
2223 $objattr['align'] = $align[strtolower($attr['ALIGN'])];
2224
2225 if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
2226 $objattr['align'] = 'R';
2227 }
2228 if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
2229 $objattr['align'] = 'L';
2230 if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto' && isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
2231 $objattr['align'] = 'C';
2232 }
2233 }
2234 if (isset($properties['COLOR'])) {
2235 $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
2236 } else if (isset($attr['COLOR']) && $attr['COLOR'] != '')
2237 $objattr['color'] = $this->mpdf->ConvertColor($attr['COLOR']);
2238 if (isset($properties['HEIGHT'])) {
2239 $objattr['linewidth'] = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2240 }
2241
2242
2243 /* -- TABLES -- */
2244 if ($this->mpdf->tableLevel) {
2245 $objattr['W-PERCENT'] = 100;
2246 if (isset($properties['WIDTH']) && stristr($properties['WIDTH'], '%')) {
2247 $properties['WIDTH'] += 0; //make "90%" become simply "90"
2248 $objattr['W-PERCENT'] = $properties['WIDTH'];
2249 }
2250 if (isset($attr['WIDTH']) && stristr($attr['WIDTH'], '%')) {
2251 $attr['WIDTH'] += 0; //make "90%" become simply "90"
2252 $objattr['W-PERCENT'] = $attr['WIDTH'];
2253 }
2254 }
2255 /* -- END TABLES -- */
2256
2257 $objattr['type'] = 'hr';
2258 $objattr['height'] = $objattr['linewidth'] + $objattr['margin_top'] + $objattr['margin_bottom'];
2259 $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
2260
2261 // Clear properties - tidy up
2262 $properties = array();
2263
2264 /* -- TABLES -- */
2265 // Output it to buffers
2266 if ($this->mpdf->tableLevel) {
2267 if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
2268 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
2269 } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
2270 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
2271 }
2272 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
2273 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
2274 } else {
2275 /* -- END TABLES -- */
2276 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
2277 } // *TABLES*
2278
2279 break;
2280
2281
2282 /* -- BARCODES -- */
2283
2284 case 'BARCODE':
2285 $this->mpdf->ignorefollowingspaces = false;
2286 if (isset($attr['CODE']) && $attr['CODE']) {
2287 $objattr = array();
2288 $objattr['margin_top'] = 0;
2289 $objattr['margin_bottom'] = 0;
2290 $objattr['margin_left'] = 0;
2291 $objattr['margin_right'] = 0;
2292 $objattr['padding_top'] = 0;
2293 $objattr['padding_bottom'] = 0;
2294 $objattr['padding_left'] = 0;
2295 $objattr['padding_right'] = 0;
2296 $objattr['width'] = 0;
2297 $objattr['height'] = 0;
2298 $objattr['border_top']['w'] = 0;
2299 $objattr['border_bottom']['w'] = 0;
2300 $objattr['border_left']['w'] = 0;
2301 $objattr['border_right']['w'] = 0;
2302 $objattr['code'] = $attr['CODE'];
2303
2304 if (isset($attr['TYPE'])) {
2305 $objattr['btype'] = trim(strtoupper($attr['TYPE']));
2306 } else {
2307 $objattr['btype'] = 'EAN13';
2308 } // default
2309 if (preg_match('/^(EAN13|ISBN|ISSN|EAN8|UPCA|UPCE)P([25])$/', $objattr['btype'], $m)) {
2310 $objattr['btype'] = $m[1];
2311 $objattr['bsupp'] = $m[2];
2312 if (preg_match('/^(\S+)\s+(.*)$/', $objattr['code'], $mm)) {
2313 $objattr['code'] = $mm[1];
2314 $objattr['bsupp_code'] = $mm[2];
2315 }
2316 } else {
2317 $objattr['bsupp'] = 0;
2318 }
2319
2320 if (isset($attr['TEXT']) && $attr['TEXT'] == 1) {
2321 $objattr['showtext'] = 1;
2322 } else {
2323 $objattr['showtext'] = 0;
2324 }
2325 if (isset($attr['SIZE']) && $attr['SIZE'] > 0) {
2326 $objattr['bsize'] = $attr['SIZE'];
2327 } else {
2328 $objattr['bsize'] = 1;
2329 }
2330 if (isset($attr['HEIGHT']) && $attr['HEIGHT'] > 0) {
2331 $objattr['bheight'] = $attr['HEIGHT'];
2332 } else {
2333 $objattr['bheight'] = 1;
2334 }
2335 if (isset($attr['PR']) && $attr['PR'] > 0) {
2336 $objattr['pr_ratio'] = $attr['PR'];
2337 } else {
2338 $objattr['pr_ratio'] = '';
2339 }
2340 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
2341 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
2342 return;
2343 }
2344 if (isset($properties['MARGIN-TOP'])) {
2345 $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2346 }
2347 if (isset($properties['MARGIN-BOTTOM'])) {
2348 $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2349 }
2350 if (isset($properties['MARGIN-LEFT'])) {
2351 $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2352 }
2353 if (isset($properties['MARGIN-RIGHT'])) {
2354 $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2355 }
2356
2357 if (isset($properties['PADDING-TOP'])) {
2358 $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2359 }
2360 if (isset($properties['PADDING-BOTTOM'])) {
2361 $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2362 }
2363 if (isset($properties['PADDING-LEFT'])) {
2364 $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2365 }
2366 if (isset($properties['PADDING-RIGHT'])) {
2367 $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2368 }
2369
2370 if (isset($properties['BORDER-TOP'])) {
2371 $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
2372 }
2373 if (isset($properties['BORDER-BOTTOM'])) {
2374 $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
2375 }
2376 if (isset($properties['BORDER-LEFT'])) {
2377 $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
2378 }
2379 if (isset($properties['BORDER-RIGHT'])) {
2380 $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
2381 }
2382
2383 if (isset($properties['VERTICAL-ALIGN'])) {
2384 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
2385 }
2386 if (isset($properties['COLOR']) && $properties['COLOR'] != '') {
2387 $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
2388 } else {
2389 $objattr['color'] = false;
2390 }
2391 if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
2392 $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
2393 } else {
2394 $objattr['bgcolor'] = false;
2395 }
2396
2397 if (!class_exists('PDFBarcode', false)) {
2398 include(_MPDF_PATH . 'classes/barcode.php');
2399 }
2400 $this->mpdf->barcode = new PDFBarcode();
2401
2402 if ($objattr['btype'] == 'EAN13' || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN' || $objattr['btype'] == 'UPCA' || $objattr['btype'] == 'UPCE' || $objattr['btype'] == 'EAN8') {
2403 $code = preg_replace('/\-/', '', $objattr['code']);
2404 if ($objattr['btype'] == 'ISSN' || $objattr['btype'] == 'ISBN') {
2405 $arrcode = $this->mpdf->barcode->getBarcodeArray($code, 'EAN13');
2406 } else {
2407 $arrcode = $this->mpdf->barcode->getBarcodeArray($code, $objattr['btype']);
2408 }
2409 if ($arrcode === false) {
2410 throw new MpdfException('Error in barcode string.');
2411 }
2412
2413 if ($objattr['bsupp'] == 2 || $objattr['bsupp'] == 5) { // EAN-2 or -5 Supplement
2414 $supparrcode = $this->mpdf->barcode->getBarcodeArray($objattr['bsupp_code'], 'EAN' . $objattr['bsupp']);
2415 $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR'] + $supparrcode["maxw"] + $supparrcode['sepM']) * $arrcode['nom-X'] * $objattr['bsize'];
2416 } else {
2417 $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize'];
2418 }
2419 $h = $arrcode['nom-H'] * $objattr['bsize'] * $objattr['bheight'];
2420 // Add height for ISBN string + margin from top of bars
2421 if (($objattr['showtext'] && $objattr['btype'] == 'EAN13') || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN') {
2422 $tisbnm = 1.5 * $objattr['bsize']; // Top margin between TOP TEXT (isbn - if shown) & bars
2423 $isbn_fontsize = 2.1 * $objattr['bsize'];
2424 $h += $isbn_fontsize + $tisbnm;
2425 }
2426 }
2427 // QR-code
2428 else if ($objattr['btype'] == 'QR') {
2429 $w = $h = $objattr['bsize'] * 25; // Factor of 25mm (default)
2430 $objattr['errorlevel'] = 'L';
2431 if (isset($attr['ERROR'])) {
2432 $objattr['errorlevel'] = $attr['ERROR'];
2433 }
2434 } else if ($objattr['btype'] == 'IMB' || $objattr['btype'] == 'RM4SCC' || $objattr['btype'] == 'KIX' || $objattr['btype'] == 'POSTNET' || $objattr['btype'] == 'PLANET') {
2435 $arrcode = $this->mpdf->barcode->getBarcodeArray($objattr['code'], $objattr['btype']);
2436 if ($arrcode === false) {
2437 throw new MpdfException('Error in barcode string.');
2438 }
2439 $w = ($arrcode["maxw"] * $arrcode['nom-X'] * $objattr['bsize']) + $arrcode['quietL'] + $arrcode['quietR'];
2440 $h = ($arrcode['nom-H'] * $objattr['bsize']) + (2 * $arrcode['quietTB']);
2441 } else if (in_array($objattr['btype'], array('C128A', 'C128B', 'C128C', 'EAN128A', 'EAN128B', 'EAN128C', 'C39', 'C39+', 'C39E', 'C39E+', 'S25', 'S25+', 'I25', 'I25+', 'I25B', 'I25B+', 'C93', 'MSI', 'MSI+', 'CODABAR', 'CODE11'))) {
2442 $arrcode = $this->mpdf->barcode->getBarcodeArray($objattr['code'], $objattr['btype'], $objattr['pr_ratio']);
2443 if ($arrcode === false) {
2444 throw new MpdfException('Error in barcode string.');
2445 }
2446 $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize'];
2447 $h = ((2 * $arrcode['lightTB'] * $arrcode['nom-X']) + $arrcode['nom-H']) * $objattr['bsize'] * $objattr['bheight'];
2448 } else {
2449 break;
2450 }
2451
2452 $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
2453 $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
2454
2455 $objattr['type'] = 'barcode';
2456 $objattr['height'] = $h + $extraheight;
2457 $objattr['width'] = $w + $extrawidth;
2458 $objattr['barcode_height'] = $h;
2459 $objattr['barcode_width'] = $w;
2460 /* -- CSS-IMAGE-FLOAT -- */
2461 if (!$this->mpdf->ColActive && !$this->mpdf->tableLevel && !$this->mpdf->listlvl && !$this->mpdf->kwt) {
2462 if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) {
2463 $objattr['float'] = substr(strtoupper($properties['FLOAT']), 0, 1);
2464 }
2465 }
2466 /* -- END CSS-IMAGE-FLOAT -- */
2467
2468 $e = "\xbb\xa4\xactype=barcode,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
2469
2470 // Clear properties - tidy up
2471 $properties = array();
2472
2473 /* -- TABLES -- */
2474 // Output it to buffers
2475 if ($this->mpdf->tableLevel) {
2476 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
2477 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
2478 } else {
2479 /* -- END TABLES -- */
2480 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
2481 } // *TABLES*
2482 }
2483 break;
2484 /* -- END BARCODES -- */
2485
2486
2487 // *********** FORM ELEMENTS ********************
2488
2489 /* -- FORMS -- */
2490 case 'SELECT':
2491 $this->mpdf->lastoptionaltag = ''; // Save current HTML specified optional endtag
2492 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
2493 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
2494 if (isset($properties['FONT-FAMILY'])) {
2495 $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
2496 }
2497 if (isset($properties['FONT-SIZE'])) {
2498 $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK);
2499 $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
2500 }
2501 if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
2502 $this->mpdf->selectoption['SPELLCHECK'] = true;
2503 }
2504
2505 if (isset($properties['COLOR'])) {
2506 $this->mpdf->selectoption['COLOR'] = $this->mpdf->ConvertColor($properties['COLOR']);
2507 }
2508 $this->mpdf->specialcontent = "type=select";
2509 if (isset($attr['DISABLED'])) {
2510 $this->mpdf->selectoption['DISABLED'] = $attr['DISABLED'];
2511 }
2512 if (isset($attr['READONLY'])) {
2513 $this->mpdf->selectoption['READONLY'] = $attr['READONLY'];
2514 }
2515 if (isset($attr['REQUIRED'])) {
2516 $this->mpdf->selectoption['REQUIRED'] = $attr['REQUIRED'];
2517 }
2518 if (isset($attr['EDITABLE'])) {
2519 $this->mpdf->selectoption['EDITABLE'] = $attr['EDITABLE'];
2520 }
2521 if (isset($attr['TITLE'])) {
2522 $this->mpdf->selectoption['TITLE'] = $attr['TITLE'];
2523 }
2524 if (isset($attr['MULTIPLE'])) {
2525 $this->mpdf->selectoption['MULTIPLE'] = $attr['MULTIPLE'];
2526 }
2527 if (isset($attr['SIZE']) && $attr['SIZE'] > 1) {
2528 $this->mpdf->selectoption['SIZE'] = $attr['SIZE'];
2529 }
2530 if ($this->mpdf->useActiveForms) {
2531 if (isset($attr['NAME'])) {
2532 $this->mpdf->selectoption['NAME'] = $attr['NAME'];
2533 }
2534 if (isset($attr['ONCHANGE'])) {
2535 $this->mpdf->selectoption['ONCHANGE'] = $attr['ONCHANGE'];
2536 }
2537 }
2538
2539 $properties = array();
2540 break;
2541
2542 case 'OPTION':
2543 $this->mpdf->lastoptionaltag = '';
2544 $this->mpdf->selectoption['ACTIVE'] = true;
2545 $this->mpdf->selectoption['currentSEL'] = false;
2546 if (empty($this->mpdf->selectoption)) {
2547 $this->mpdf->selectoption['MAXWIDTH'] = '';
2548 $this->mpdf->selectoption['SELECTED'] = '';
2549 }
2550 if (isset($attr['SELECTED'])) {
2551 $this->mpdf->selectoption['SELECTED'] = '';
2552 $this->mpdf->selectoption['currentSEL'] = true;
2553 }
2554 if (isset($attr['VALUE'])) {
2555 $attr['VALUE'] = strcode2utf($attr['VALUE']);
2556 $attr['VALUE'] = $this->mpdf->lesser_entity_decode($attr['VALUE']);
2557 if ($this->mpdf->onlyCoreFonts)
2558 $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8');
2559 }
2560 $this->mpdf->selectoption['currentVAL'] = $attr['VALUE'];
2561 break;
2562
2563 case 'TEXTAREA':
2564 $objattr = array();
2565 $objattr['margin_top'] = 0;
2566 $objattr['margin_bottom'] = 0;
2567 $objattr['margin_left'] = 0;
2568 $objattr['margin_right'] = 0;
2569 $objattr['width'] = 0;
2570 $objattr['height'] = 0;
2571 $objattr['border_top']['w'] = 0;
2572 $objattr['border_bottom']['w'] = 0;
2573 $objattr['border_left']['w'] = 0;
2574 $objattr['border_right']['w'] = 0;
2575 if (isset($attr['DISABLED'])) {
2576 $objattr['disabled'] = true;
2577 }
2578 if (isset($attr['READONLY'])) {
2579 $objattr['readonly'] = true;
2580 }
2581 if (isset($attr['REQUIRED'])) {
2582 $objattr['required'] = true;
2583 }
2584 if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
2585 $objattr['spellcheck'] = true;
2586 }
2587 if (isset($attr['TITLE'])) {
2588 $objattr['title'] = $attr['TITLE'];
2589 if ($this->mpdf->onlyCoreFonts)
2590 $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mpdf->mb_enc, 'UTF-8');
2591 }
2592 if ($this->mpdf->useActiveForms) {
2593 if (isset($attr['NAME'])) {
2594 $objattr['fieldname'] = $attr['NAME'];
2595 }
2596 $this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] = 0;
2597 $this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] = 0;
2598 if (isset($attr['ONCALCULATE'])) {
2599 $objattr['onCalculate'] = $attr['ONCALCULATE'];
2600 } else if (isset($attr['ONCHANGE'])) {
2601 $objattr['onCalculate'] = $attr['ONCHANGE'];
2602 }
2603 if (isset($attr['ONVALIDATE'])) {
2604 $objattr['onValidate'] = $attr['ONVALIDATE'];
2605 }
2606 if (isset($attr['ONKEYSTROKE'])) {
2607 $objattr['onKeystroke'] = $attr['ONKEYSTROKE'];
2608 }
2609 if (isset($attr['ONFORMAT'])) {
2610 $objattr['onFormat'] = $attr['ONFORMAT'];
2611 }
2612 }
2613 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
2614 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
2615 if (isset($properties['FONT-FAMILY'])) {
2616 $this->mpdf->SetFont($properties['FONT-FAMILY'], '', 0, false);
2617 }
2618 if (isset($properties['FONT-SIZE'])) {
2619 $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK);
2620 $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
2621 }
2622 if (isset($properties['COLOR'])) {
2623 $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
2624 }
2625 $objattr['fontfamily'] = $this->mpdf->FontFamily;
2626 $objattr['fontsize'] = $this->mpdf->FontSizePt;
2627 if ($this->mpdf->useActiveForms) {
2628 if (isset($properties['TEXT-ALIGN'])) {
2629 $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])];
2630 } else if (isset($attr['ALIGN'])) {
2631 $objattr['text_align'] = $align[strtolower($attr['ALIGN'])];
2632 }
2633 if (isset($properties['OVERFLOW']) && strtolower($properties['OVERFLOW']) == 'hidden') {
2634 $objattr['donotscroll'] = true;
2635 }
2636 if (isset($properties['BORDER-TOP-COLOR'])) {
2637 $objattr['border-col'] = $this->mpdf->ConvertColor($properties['BORDER-TOP-COLOR']);
2638 }
2639 if (isset($properties['BACKGROUND-COLOR'])) {
2640 $objattr['background-col'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
2641 }
2642 }
2643 $this->mpdf->SetLineHeight('', $this->mpdf->mpdfform->textarea_lineheight);
2644
2645 $w = 0;
2646 $h = 0;
2647 if (isset($properties['WIDTH']))
2648 $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2649 if (isset($properties['HEIGHT']))
2650 $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2651 if (isset($properties['VERTICAL-ALIGN'])) {
2652 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
2653 }
2654
2655 $colsize = 20; //HTML default value
2656 $rowsize = 2; //HTML default value
2657 if (isset($attr['COLS']))
2658 $colsize = intval($attr['COLS']);
2659 if (isset($attr['ROWS']))
2660 $rowsize = intval($attr['ROWS']);
2661
2662 $charsize = $this->mpdf->GetCharWidth('w', false);
2663 if ($w) {
2664 $colsize = round(($w - ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['h'] * 2) - ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['h'] * 2)) / $charsize);
2665 }
2666 if ($h) {
2667 $rowsize = round(($h - ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] * 2) - ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] * 2)) / $this->mpdf->lineheight);
2668 }
2669
2670 $objattr['type'] = 'textarea';
2671 $objattr['width'] = ($colsize * $charsize) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['h'] * 2);
2672 $objattr['height'] = ($rowsize * $this->mpdf->lineheight) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] * 2);
2673 $objattr['rows'] = $rowsize;
2674 $objattr['cols'] = $colsize;
2675
2676 $this->mpdf->specialcontent = serialize($objattr);
2677
2678 if ($this->mpdf->tableLevel) { // *TABLES*
2679 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; // *TABLES*
2680 } // *TABLES*
2681 // Clear properties - tidy up
2682 $properties = array();
2683 break;
2684
2685
2686
2687 // *********** FORM - INPUT ********************
2688
2689 case 'INPUT':
2690 $this->mpdf->ignorefollowingspaces = false;
2691 if (!isset($attr['TYPE']))
2692 $attr['TYPE'] == 'TEXT';
2693 $objattr = array();
2694 $objattr['margin_top'] = 0;
2695 $objattr['margin_bottom'] = 0;
2696 $objattr['margin_left'] = 0;
2697 $objattr['margin_right'] = 0;
2698 $objattr['width'] = 0;
2699 $objattr['height'] = 0;
2700 $objattr['border_top']['w'] = 0;
2701 $objattr['border_bottom']['w'] = 0;
2702 $objattr['border_left']['w'] = 0;
2703 $objattr['border_right']['w'] = 0;
2704 $objattr['type'] = 'input';
2705 if (isset($attr['DISABLED'])) {
2706 $objattr['disabled'] = true;
2707 }
2708 if (isset($attr['READONLY'])) {
2709 $objattr['readonly'] = true;
2710 }
2711 if (isset($attr['REQUIRED'])) {
2712 $objattr['required'] = true;
2713 }
2714 if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
2715 $objattr['spellcheck'] = true;
2716 }
2717 if (isset($attr['TITLE'])) {
2718 $objattr['title'] = $attr['TITLE'];
2719 } else if (isset($attr['ALT'])) {
2720 $objattr['title'] = $attr['ALT'];
2721 } else
2722 $objattr['title'] = '';
2723 $objattr['title'] = strcode2utf($objattr['title']);
2724 $objattr['title'] = $this->mpdf->lesser_entity_decode($objattr['title']);
2725 if ($this->mpdf->onlyCoreFonts)
2726 $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mpdf->mb_enc, 'UTF-8');
2727 if ($this->mpdf->useActiveForms) {
2728 if (isset($attr['NAME'])) {
2729 $objattr['fieldname'] = $attr['NAME'];
2730 }
2731 }
2732 if (isset($attr['VALUE'])) {
2733 $attr['VALUE'] = strcode2utf($attr['VALUE']);
2734 $attr['VALUE'] = $this->mpdf->lesser_entity_decode($attr['VALUE']);
2735 if ($this->mpdf->onlyCoreFonts)
2736 $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8');
2737 $objattr['value'] = $attr['VALUE'];
2738 }
2739
2740 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
2741 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
2742 $objattr['vertical-align'] = '';
2743
2744 if (isset($properties['FONT-FAMILY'])) {
2745 $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
2746 }
2747 if (isset($properties['FONT-SIZE'])) {
2748 $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], ($this->mpdf->default_font_size / _MPDFK));
2749 $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
2750 }
2751 if (isset($properties['COLOR'])) {
2752 $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
2753 }
2754 $objattr['fontfamily'] = $this->mpdf->FontFamily;
2755 $objattr['fontsize'] = $this->mpdf->FontSizePt;
2756 if ($this->mpdf->useActiveForms) {
2757 if (isset($attr['ALIGN'])) {
2758 $objattr['text_align'] = $align[strtolower($attr['ALIGN'])];
2759 } else if (isset($properties['TEXT-ALIGN'])) {
2760 $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])];
2761 }
2762 if (isset($properties['BORDER-TOP-COLOR'])) {
2763 $objattr['border-col'] = $this->mpdf->ConvertColor($properties['BORDER-TOP-COLOR']);
2764 }
2765 if (isset($properties['BACKGROUND-COLOR'])) {
2766 $objattr['background-col'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
2767 }
2768 }
2769
2770 $type = '';
2771 $texto = '';
2772 $height = $this->mpdf->FontSize;
2773 $width = 0;
2774 $spacesize = $this->mpdf->GetCharWidth(' ', false);
2775
2776 $w = 0;
2777 if (isset($properties['WIDTH']))
2778 $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
2779
2780 if ($properties['VERTICAL-ALIGN']) {
2781 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
2782 }
2783
2784 switch (strtoupper($attr['TYPE'])) {
2785 case 'HIDDEN':
2786 $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
2787 if ($this->mpdf->useActiveForms) {
2788 $this->mpdf->mpdfform->SetFormText(0, 0, $objattr['fieldname'], $objattr['value'], $objattr['value'], '', 0, '', true);
2789 }
2790 if ($this->mpdf->InlineProperties[$tag]) {
2791 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
2792 }
2793 unset($this->mpdf->InlineProperties[$tag]);
2794 break 2;
2795 case 'CHECKBOX': //Draw Checkbox
2796 $type = 'CHECKBOX';
2797 if (isset($attr['CHECKED'])) {
2798 $objattr['checked'] = true;
2799 } else {
2800 $objattr['checked'] = false;
2801 }
2802 $width = $this->mpdf->FontSize;
2803 $height = $this->mpdf->FontSize;
2804 break;
2805
2806 case 'RADIO': //Draw Radio button
2807 $type = 'RADIO';
2808 if (isset($attr['CHECKED']))
2809 $objattr['checked'] = true;
2810 $width = $this->mpdf->FontSize;
2811 $height = $this->mpdf->FontSize;
2812 break;
2813
2814 /* -- IMAGES-CORE -- */
2815 case 'IMAGE': // Draw an Image button
2816 if (isset($attr['SRC'])) {
2817 $type = 'IMAGE';
2818 $srcpath = $attr['SRC'];
2819 $orig_srcpath = $attr['ORIG_SRC'];
2820 // VSPACE and HSPACE converted to margins in MergeCSS
2821 if (isset($properties['MARGIN-TOP'])) {
2822 $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2823 }
2824 if (isset($properties['MARGIN-BOTTOM'])) {
2825 $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2826 }
2827 if (isset($properties['MARGIN-LEFT'])) {
2828 $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2829 }
2830 if (isset($properties['MARGIN-RIGHT'])) {
2831 $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
2832 }
2833
2834
2835 if (isset($properties['BORDER-TOP'])) {
2836 $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
2837 }
2838 if (isset($properties['BORDER-BOTTOM'])) {
2839 $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
2840 }
2841 if (isset($properties['BORDER-LEFT'])) {
2842 $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
2843 }
2844 if (isset($properties['BORDER-RIGHT'])) {
2845 $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
2846 }
2847
2848 $objattr['padding_top'] = 0;
2849 $objattr['padding_bottom'] = 0;
2850 $objattr['padding_left'] = 0;
2851 $objattr['padding_right'] = 0;
2852
2853 if (isset($properties['VERTICAL-ALIGN'])) {
2854 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
2855 }
2856
2857 $w = 0;
2858 $h = 0;
2859 if (isset($properties['WIDTH']))
2860 $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
2861 if (isset($properties['HEIGHT']))
2862 $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
2863
2864 $extraheight = $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
2865 $extrawidth = $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
2866
2867 // Image file
2868 $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath);
2869 if (!$info) {
2870 $info = $this->mpdf->_getImage($this->mpdf->noImageFile);
2871 if ($info) {
2872 $srcpath = $this->mpdf->noImageFile;
2873 $w = ($info['w'] * (25.4 / $this->mpdf->dpi));
2874 $h = ($info['h'] * (25.4 / $this->mpdf->dpi));
2875 }
2876 }
2877 if (!$info)
2878 break;
2879 if ($info['cs'] == 'Indexed') {
2880 $objattr['Indexed'] = true;
2881 }
2882 $objattr['file'] = $srcpath;
2883 //Default width and height calculation if needed
2884 if ($w == 0 and $h == 0) {
2885 /* -- IMAGES-WMF -- */
2886 if ($info['type'] == 'wmf') {
2887 // WMF units are twips (1/20pt)
2888 // divide by 20 to get points
2889 // divide by k to get user units
2890 $w = abs($info['w']) / (20 * _MPDFK);
2891 $h = abs($info['h']) / (20 * _MPDFK);
2892 } else
2893 /* -- END IMAGES-WMF -- */
2894 if ($info['type'] == 'svg') {
2895 // SVG units are pixels
2896 $w = abs($info['w']) / _MPDFK;
2897 $h = abs($info['h']) / _MPDFK;
2898 } else {
2899 //Put image at default image dpi
2900 $w = ($info['w'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
2901 $h = ($info['h'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
2902 }
2903 if (isset($properties['IMAGE-RESOLUTION'])) {
2904 if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi'] > 0) {
2905 $w *= $this->mpdf->img_dpi / $info['set-dpi'];
2906 $h *= $this->mpdf->img_dpi / $info['set-dpi'];
2907 } else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
2908 $dpi = $m[1];
2909 if ($dpi > 0) {
2910 $w *= $this->mpdf->img_dpi / $dpi;
2911 $h *= $this->mpdf->img_dpi / $dpi;
2912 }
2913 }
2914 }
2915 }
2916 // IF WIDTH OR HEIGHT SPECIFIED
2917 if ($w == 0)
2918 $w = $h * $info['w'] / $info['h'];
2919 if ($h == 0)
2920 $h = $w * $info['h'] / $info['w'];
2921 // Resize to maximum dimensions of page
2922 $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
2923 $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 10);
2924 if ($this->mpdf->fullImageHeight) {
2925 $maxHeight = $this->mpdf->fullImageHeight;
2926 }
2927 if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth
2928 $w = $maxWidth - $extrawidth;
2929 $h = $w * $info['h'] / $info['w'];
2930 }
2931 if ($h + $extraheight > $maxHeight) {
2932 $h = $maxHeight - $extraheight;
2933 $w = $h * $info['w'] / $info['h'];
2934 }
2935 $height = $h + $extraheight;
2936 $width = $w + $extrawidth;
2937 $objattr['type'] = 'image';
2938 $objattr['itype'] = $info['type'];
2939 $objattr['orig_h'] = $info['h'];
2940 $objattr['orig_w'] = $info['w'];
2941 /* -- IMAGES-WMF -- */
2942 if ($info['type'] == 'wmf') {
2943 $objattr['wmf_x'] = $info['x'];
2944 $objattr['wmf_y'] = $info['y'];
2945 } else
2946 /* -- END IMAGES-WMF -- */
2947 if ($info['type'] == 'svg') {
2948 $objattr['wmf_x'] = $info['x'];
2949 $objattr['wmf_y'] = $info['y'];
2950 }
2951 $objattr['height'] = $h + $extraheight;
2952 $objattr['width'] = $w + $extrawidth;
2953
2954 $objattr['image_height'] = $h;
2955 $objattr['image_width'] = $w;
2956 $objattr['ID'] = $info['i'];
2957 $texto = 'X';
2958 if ($this->mpdf->useActiveForms) {
2959 if (isset($attr['ONCLICK'])) {
2960 $objattr['onClick'] = $attr['ONCLICK'];
2961 }
2962 $objattr['type'] = 'input';
2963 $type = 'IMAGE';
2964 }
2965 break;
2966 }
2967 /* -- END IMAGES-CORE -- */
2968
2969 case 'BUTTON': // Draw a button
2970 case 'SUBMIT':
2971 case 'RESET':
2972 $type = strtoupper($attr['TYPE']);
2973 if ($type == 'IMAGE') {
2974 $type = 'BUTTON';
2975 } // src path not found
2976 if (isset($attr['NOPRINT'])) {
2977 $objattr['noprint'] = true;
2978 }
2979 if (!isset($attr['VALUE'])) {
2980 $objattr['value'] = ucfirst(strtolower($type));
2981 }
2982
2983 $texto = " " . $objattr['value'] . " ";
2984 $width = $this->mpdf->GetStringWidth($texto) + ($this->mpdf->mpdfform->form_element_spacing['button']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['button']['inner']['h'] * 2);
2985 $height = $this->mpdf->FontSize + ($this->mpdf->mpdfform->form_element_spacing['button']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['button']['inner']['v'] * 2);
2986 if ($this->mpdf->useActiveForms) {
2987 if (isset($attr['ONCLICK'])) {
2988 $objattr['onClick'] = $attr['ONCLICK'];
2989 }
2990 }
2991 break;
2992
2993 case 'PASSWORD':
2994 case 'TEXT':
2995 default:
2996 if ($type == '') {
2997 $type = 'TEXT';
2998 }
2999 if (strtoupper($attr['TYPE']) == 'PASSWORD') {
3000 $type = 'PASSWORD';
3001 }
3002 if (isset($attr['VALUE'])) {
3003 if ($type == 'PASSWORD') {
3004 $num_stars = mb_strlen($attr['VALUE'], $this->mpdf->mb_enc);
3005 $texto = str_repeat('*', $num_stars);
3006 } else {
3007 $texto = $attr['VALUE'];
3008 }
3009 }
3010 $xw = ($this->mpdf->mpdfform->form_element_spacing['input']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['input']['inner']['h'] * 2);
3011 $xh = ($this->mpdf->mpdfform->form_element_spacing['input']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['input']['inner']['v'] * 2);
3012 if ($w) {
3013 $width = $w + $xw;
3014 } else {
3015 $width = (20 * $spacesize) + $xw;
3016 } // Default width in chars
3017 if (isset($attr['SIZE']) and ctype_digit($attr['SIZE']))
3018 $width = ($attr['SIZE'] * $spacesize) + $xw;
3019 $height = $this->mpdf->FontSize + $xh;
3020 if (isset($attr['MAXLENGTH']) and ctype_digit($attr['MAXLENGTH']))
3021 $objattr['maxlength'] = $attr['MAXLENGTH'];
3022 if ($this->mpdf->useActiveForms) {
3023 if (isset($attr['ONCALCULATE'])) {
3024 $objattr['onCalculate'] = $attr['ONCALCULATE'];
3025 } else if (isset($attr['ONCHANGE'])) {
3026 $objattr['onCalculate'] = $attr['ONCHANGE'];
3027 }
3028 if (isset($attr['ONVALIDATE'])) {
3029 $objattr['onValidate'] = $attr['ONVALIDATE'];
3030 }
3031 if (isset($attr['ONKEYSTROKE'])) {
3032 $objattr['onKeystroke'] = $attr['ONKEYSTROKE'];
3033 }
3034 if (isset($attr['ONFORMAT'])) {
3035 $objattr['onFormat'] = $attr['ONFORMAT'];
3036 }
3037 }
3038 break;
3039 }
3040
3041 $objattr['subtype'] = $type;
3042 $objattr['text'] = $texto;
3043 $objattr['width'] = $width;
3044 $objattr['height'] = $height;
3045 $e = "\xbb\xa4\xactype=input,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
3046
3047 // Clear properties - tidy up
3048 $properties = array();
3049
3050 /* -- TABLES -- */
3051 // Output it to buffers
3052 if ($this->mpdf->tableLevel) {
3053 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
3054 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
3055 } else {
3056 /* -- END TABLES -- */
3057 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
3058 } // *TABLES*
3059
3060 if ($this->mpdf->InlineProperties[$tag]) {
3061 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
3062 }
3063 unset($this->mpdf->InlineProperties[$tag]);
3064
3065 break; // END of INPUT
3066 /* -- END FORMS -- */
3067
3068
3069 // *********** GRAPH ********************
3070 case 'JPGRAPH':
3071 if (!$this->mpdf->useGraphs) {
3072 break;
3073 }
3074 if ($attr['TABLE']) {
3075 $gid = strtoupper($attr['TABLE']);
3076 } else {
3077 $gid = '0';
3078 }
3079 if (!is_array($this->mpdf->graphs[$gid]) || count($this->mpdf->graphs[$gid]) == 0) {
3080 break;
3081 }
3082 $this->mpdf->ignorefollowingspaces = false;
3083 include_once(_MPDF_PATH . 'graph.php');
3084 $this->mpdf->graphs[$gid]['attr'] = $attr;
3085
3086
3087 if (isset($this->mpdf->graphs[$gid]['attr']['WIDTH']) && $this->mpdf->graphs[$gid]['attr']['WIDTH']) {
3088 $this->mpdf->graphs[$gid]['attr']['cWIDTH'] = $this->mpdf->ConvertSize($this->mpdf->graphs[$gid]['attr']['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
3089 } // mm
3090 if (isset($this->mpdf->graphs[$gid]['attr']['HEIGHT']) && $this->mpdf->graphs[$gid]['attr']['HEIGHT']) {
3091 $this->mpdf->graphs[$gid]['attr']['cHEIGHT'] = $this->mpdf->ConvertSize($this->mpdf->graphs[$gid]['attr']['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
3092 }
3093
3094 $graph_img = print_graph($this->mpdf->graphs[$gid], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
3095 if ($graph_img) {
3096 if (isset($attr['ROTATE'])) {
3097 if ($attr['ROTATE'] == 90 || $attr['ROTATE'] == -90) {
3098 $tmpw = $graph_img['w'];
3099 $graph_img['w'] = $graph_img['h'];
3100 $graph_img['h'] = $tmpw;
3101 }
3102 }
3103 $attr['SRC'] = $graph_img['file'];
3104 $attr['WIDTH'] = $graph_img['w'];
3105 $attr['HEIGHT'] = $graph_img['h'];
3106 } else {
3107 break;
3108 }
3109
3110 // *********** IMAGE ********************
3111 /* -- IMAGES-CORE -- */
3112 case 'IMG':
3113 $this->mpdf->ignorefollowingspaces = false;
3114 if ($this->mpdf->progressBar) {
3115 $this->mpdf->UpdateProgressBar(1, '', 'IMG');
3116 } // *PROGRESS-BAR*
3117 $objattr = array();
3118 $objattr['margin_top'] = 0;
3119 $objattr['margin_bottom'] = 0;
3120 $objattr['margin_left'] = 0;
3121 $objattr['margin_right'] = 0;
3122 $objattr['padding_top'] = 0;
3123 $objattr['padding_bottom'] = 0;
3124 $objattr['padding_left'] = 0;
3125 $objattr['padding_right'] = 0;
3126 $objattr['width'] = 0;
3127 $objattr['height'] = 0;
3128 $objattr['border_top']['w'] = 0;
3129 $objattr['border_bottom']['w'] = 0;
3130 $objattr['border_left']['w'] = 0;
3131 $objattr['border_right']['w'] = 0;
3132 if (isset($attr['SRC'])) {
3133 $srcpath = $attr['SRC'];
3134 $orig_srcpath = (isset($attr['ORIG_SRC']) ? $attr['ORIG_SRC'] : '');
3135 $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr);
3136 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
3137 return;
3138 }
3139 if (isset($properties['Z-INDEX']) && $this->mpdf->current_layer == 0) {
3140 $v = intval($properties['Z-INDEX']);
3141 if ($v > 0) {
3142 $objattr['z-index'] = $v;
3143 }
3144 }
3145
3146 $objattr['visibility'] = 'visible';
3147 if (isset($properties['VISIBILITY'])) {
3148 $v = strtolower($properties['VISIBILITY']);
3149 if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') {
3150 $objattr['visibility'] = $v;
3151 }
3152 }
3153
3154 // VSPACE and HSPACE converted to margins in MergeCSS
3155 if (isset($properties['MARGIN-TOP'])) {
3156 $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3157 }
3158 if (isset($properties['MARGIN-BOTTOM'])) {
3159 $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3160 }
3161 if (isset($properties['MARGIN-LEFT'])) {
3162 $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3163 }
3164 if (isset($properties['MARGIN-RIGHT'])) {
3165 $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3166 }
3167
3168 if (isset($properties['PADDING-TOP'])) {
3169 $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3170 }
3171 if (isset($properties['PADDING-BOTTOM'])) {
3172 $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3173 }
3174 if (isset($properties['PADDING-LEFT'])) {
3175 $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3176 }
3177 if (isset($properties['PADDING-RIGHT'])) {
3178 $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3179 }
3180
3181 if (isset($properties['BORDER-TOP'])) {
3182 $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
3183 }
3184 if (isset($properties['BORDER-BOTTOM'])) {
3185 $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
3186 }
3187 if (isset($properties['BORDER-LEFT'])) {
3188 $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
3189 }
3190 if (isset($properties['BORDER-RIGHT'])) {
3191 $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
3192 }
3193
3194 if (isset($properties['VERTICAL-ALIGN'])) {
3195 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
3196 }
3197 $w = 0;
3198 $h = 0;
3199 if (isset($properties['WIDTH']))
3200 $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3201 else if (isset($attr['WIDTH']))
3202 $w = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3203 if (isset($properties['HEIGHT']))
3204 $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3205 else if (isset($attr['HEIGHT']))
3206 $h = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3207 $maxw = $maxh = $minw = $minh = false;
3208 if (isset($properties['MAX-WIDTH']))
3209 $maxw = $this->mpdf->ConvertSize($properties['MAX-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3210 else if (isset($attr['MAX-WIDTH']))
3211 $maxw = $this->mpdf->ConvertSize($attr['MAX-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3212 if (isset($properties['MAX-HEIGHT']))
3213 $maxh = $this->mpdf->ConvertSize($properties['MAX-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3214 else if (isset($attr['MAX-HEIGHT']))
3215 $maxh = $this->mpdf->ConvertSize($attr['MAX-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3216 if (isset($properties['MIN-WIDTH']))
3217 $minw = $this->mpdf->ConvertSize($properties['MIN-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3218 else if (isset($attr['MIN-WIDTH']))
3219 $minw = $this->mpdf->ConvertSize($attr['MIN-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3220 if (isset($properties['MIN-HEIGHT']))
3221 $minh = $this->mpdf->ConvertSize($properties['MIN-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3222 else if (isset($attr['MIN-HEIGHT']))
3223 $minh = $this->mpdf->ConvertSize($attr['MIN-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3224
3225 if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
3226 $objattr['opacity'] = $properties['OPACITY'];
3227 }
3228 if ($this->mpdf->HREF) {
3229 if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) {
3230 $href = $this->mpdf->HREF;
3231 while (array_key_exists($href, $this->mpdf->internallink))
3232 $href = "#" . $href;
3233 $this->mpdf->internallink[$href] = $this->mpdf->AddLink();
3234 $objattr['link'] = $this->mpdf->internallink[$href];
3235 } else {
3236 $objattr['link'] = $this->mpdf->HREF;
3237 }
3238 }
3239 $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
3240 $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
3241
3242 // mPDF 5.7.3 TRANSFORMS
3243 if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
3244 $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
3245 }
3246
3247 /* -- BACKGROUNDS -- */
3248 if (isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $properties['GRADIENT-MASK'])) {
3249 $objattr['GRADIENT-MASK'] = $properties['GRADIENT-MASK'];
3250 }
3251 /* -- END BACKGROUNDS -- */
3252
3253 // mPDF 6
3254 $interpolation = false;
3255 if (isset($properties['IMAGE-RENDERING']) && $properties['IMAGE-RENDERING']) {
3256 if (strtolower($properties['IMAGE-RENDERING']) == 'crisp-edges') {
3257 $interpolation = false;
3258 } else if (strtolower($properties['IMAGE-RENDERING']) == 'optimizequality') {
3259 $interpolation = true;
3260 } else if (strtolower($properties['IMAGE-RENDERING']) == 'smooth') {
3261 $interpolation = true;
3262 } else if (strtolower($properties['IMAGE-RENDERING']) == 'auto') {
3263 $interpolation = $this->mpdf->interpolateImages;
3264 } else {
3265 $interpolation = false;
3266 }
3267 $info['interpolation'] = $interpolation;
3268 }
3269
3270 // Image file
3271 $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath, $interpolation); // mPDF 6
3272 if (!$info) {
3273 $info = $this->mpdf->_getImage($this->mpdf->noImageFile);
3274 if ($info) {
3275 $srcpath = $this->mpdf->noImageFile;
3276 $w = ($info['w'] * (25.4 / $this->mpdf->dpi));
3277 $h = ($info['h'] * (25.4 / $this->mpdf->dpi));
3278 }
3279 }
3280 if (!$info)
3281 break;
3282
3283 if (isset($attr['ROTATE'])) {
3284 $image_orientation = $attr['ROTATE'];
3285 } else if (isset($properties['IMAGE-ORIENTATION'])) {
3286 $image_orientation = $properties['IMAGE-ORIENTATION'];
3287 } else {
3288 $image_orientation = 0;
3289 }
3290 if ($image_orientation) {
3291 if ($image_orientation == 90 || $image_orientation == -90 || $image_orientation == 270) {
3292 $tmpw = $info['w'];
3293 $info['w'] = $info['h'];
3294 $info['h'] = $tmpw;
3295 }
3296 $objattr['ROTATE'] = $image_orientation;
3297 }
3298
3299 $objattr['file'] = $srcpath;
3300 //Default width and height calculation if needed
3301 if ($w == 0 and $h == 0) {
3302 /* -- IMAGES-WMF -- */
3303 if ($info['type'] == 'wmf') {
3304 // WMF units are twips (1/20pt)
3305 // divide by 20 to get points
3306 // divide by k to get user units
3307 $w = abs($info['w']) / (20 * _MPDFK);
3308 $h = abs($info['h']) / (20 * _MPDFK);
3309 } else
3310 /* -- END IMAGES-WMF -- */
3311 if ($info['type'] == 'svg') {
3312 // SVG units are pixels
3313 $w = abs($info['w']) / _MPDFK;
3314 $h = abs($info['h']) / _MPDFK;
3315 } else {
3316 //Put image at default image dpi
3317 $w = ($info['w'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
3318 $h = ($info['h'] / _MPDFK) * (72 / $this->mpdf->img_dpi);
3319 }
3320 if (isset($properties['IMAGE-RESOLUTION'])) {
3321 if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi'] > 0) {
3322 $w *= $this->mpdf->img_dpi / $info['set-dpi'];
3323 $h *= $this->mpdf->img_dpi / $info['set-dpi'];
3324 } else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
3325 $dpi = $m[1];
3326 if ($dpi > 0) {
3327 $w *= $this->mpdf->img_dpi / $dpi;
3328 $h *= $this->mpdf->img_dpi / $dpi;
3329 }
3330 }
3331 }
3332 }
3333 // IF WIDTH OR HEIGHT SPECIFIED
3334 if ($w == 0)
3335 $w = abs($h * $info['w'] / $info['h']);
3336 if ($h == 0)
3337 $h = abs($w * $info['h'] / $info['w']);
3338
3339 if ($minw && $w < $minw) {
3340 $w = $minw;
3341 $h = abs($w * $info['h'] / $info['w']);
3342 }
3343 if ($maxw && $w > $maxw) {
3344 $w = $maxw;
3345 $h = abs($w * $info['h'] / $info['w']);
3346 }
3347 if ($minh && $h < $minh) {
3348 $h = $minh;
3349 $w = abs($h * $info['w'] / $info['h']);
3350 }
3351 if ($maxh && $h > $maxh) {
3352 $h = $maxh;
3353 $w = abs($h * $info['w'] / $info['h']);
3354 }
3355
3356 // Resize to maximum dimensions of page
3357 $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
3358 $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 1);
3359 if ($this->mpdf->fullImageHeight) {
3360 $maxHeight = $this->mpdf->fullImageHeight;
3361 }
3362 if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth
3363 $w = $maxWidth - $extrawidth;
3364 $h = abs($w * $info['h'] / $info['w']);
3365 }
3366
3367 if ($h + $extraheight > $maxHeight) {
3368 $h = $maxHeight - $extraheight;
3369 $w = abs($h * $info['w'] / $info['h']);
3370 }
3371 $objattr['type'] = 'image';
3372 $objattr['itype'] = $info['type'];
3373
3374 $objattr['orig_h'] = $info['h'];
3375 $objattr['orig_w'] = $info['w'];
3376 /* -- IMAGES-WMF -- */
3377 if ($info['type'] == 'wmf') {
3378 $objattr['wmf_x'] = $info['x'];
3379 $objattr['wmf_y'] = $info['y'];
3380 } else
3381 /* -- END IMAGES-WMF -- */
3382 if ($info['type'] == 'svg') {
3383 $objattr['wmf_x'] = $info['x'];
3384 $objattr['wmf_y'] = $info['y'];
3385 }
3386 $objattr['height'] = $h + $extraheight;
3387 $objattr['width'] = $w + $extrawidth;
3388 $objattr['image_height'] = $h;
3389 $objattr['image_width'] = $w;
3390 /* -- CSS-IMAGE-FLOAT -- */
3391 if (!$this->mpdf->ColActive && !$this->mpdf->tableLevel && !$this->mpdf->listlvl && !$this->mpdf->kwt) {
3392 if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) {
3393 $objattr['float'] = substr(strtoupper($properties['FLOAT']), 0, 1);
3394 }
3395 }
3396 /* -- END CSS-IMAGE-FLOAT -- */
3397 // mPDF 5.7.3 TRANSFORMS
3398 if (isset($properties['TRANSFORM']) && !$this->mpdf->ColActive && !$this->mpdf->kwt) {
3399 $objattr['transform'] = $properties['TRANSFORM'];
3400 }
3401
3402 $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
3403
3404 // Clear properties - tidy up
3405 $properties = array();
3406
3407 /* -- TABLES -- */
3408 // Output it to buffers
3409 if ($this->mpdf->tableLevel) {
3410 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
3411 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
3412 } else {
3413 /* -- END TABLES -- */
3414 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
3415 } // *TABLES*
3416 /* -- ANNOTATIONS -- */
3417 if ($this->mpdf->title2annots && isset($attr['TITLE'])) {
3418 $objattr = array();
3419 $objattr['margin_top'] = 0;
3420 $objattr['margin_bottom'] = 0;
3421 $objattr['margin_left'] = 0;
3422 $objattr['margin_right'] = 0;
3423 $objattr['width'] = 0;
3424 $objattr['height'] = 0;
3425 $objattr['border_top']['w'] = 0;
3426 $objattr['border_bottom']['w'] = 0;
3427 $objattr['border_left']['w'] = 0;
3428 $objattr['border_right']['w'] = 0;
3429 $objattr['CONTENT'] = $attr['TITLE'];
3430 $objattr['type'] = 'annot';
3431 $objattr['POS-X'] = 0;
3432 $objattr['POS-Y'] = 0;
3433 $objattr['ICON'] = 'Comment';
3434 $objattr['AUTHOR'] = '';
3435 $objattr['SUBJECT'] = '';
3436 $objattr['OPACITY'] = $this->mpdf->annotOpacity;
3437 $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow');
3438 $e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
3439 if ($this->mpdf->tableLevel) { // *TABLES*
3440 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); // *TABLES*
3441 } // *TABLES*
3442 else { // *TABLES*
3443 $this->mpdf->textbuffer[] = array($e);
3444 } // *TABLES*
3445 }
3446 /* -- END ANNOTATIONS -- */
3447 }
3448 break;
3449 /* -- END IMAGES-CORE -- */
3450
3451
3452 // *********** CIRCULAR TEXT = TEXTCIRCLE ********************
3453 case 'TEXTCIRCLE':
3454 $objattr = array();
3455 $objattr['margin_top'] = 0;
3456 $objattr['margin_bottom'] = 0;
3457 $objattr['margin_left'] = 0;
3458 $objattr['margin_right'] = 0;
3459 $objattr['padding_top'] = 0;
3460 $objattr['padding_bottom'] = 0;
3461 $objattr['padding_left'] = 0;
3462 $objattr['padding_right'] = 0;
3463 $objattr['width'] = 0;
3464 $objattr['height'] = 0;
3465 $objattr['border_top']['w'] = 0;
3466 $objattr['border_bottom']['w'] = 0;
3467 $objattr['border_left']['w'] = 0;
3468 $objattr['border_right']['w'] = 0;
3469 $objattr['top-text'] = '';
3470 $objattr['bottom-text'] = '';
3471 $objattr['r'] = 20; // radius (default value here for safety)
3472 $objattr['space-width'] = 120;
3473 $objattr['char-width'] = 100;
3474
3475 $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties();
3476 $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr);
3477
3478 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
3479 return;
3480 }
3481 if (isset($attr['R'])) {
3482 $objattr['r'] = $this->mpdf->ConvertSize($attr['R'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3483 }
3484 if (isset($attr['TOP-TEXT'])) {
3485 $objattr['top-text'] = strcode2utf($attr['TOP-TEXT']);
3486 $objattr['top-text'] = $this->mpdf->lesser_entity_decode($objattr['top-text']);
3487 if ($this->mpdf->onlyCoreFonts)
3488 $objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mpdf->mb_enc, 'UTF-8');
3489 }
3490 if (isset($attr['BOTTOM-TEXT'])) {
3491 $objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']);
3492 $objattr['bottom-text'] = $this->mpdf->lesser_entity_decode($objattr['bottom-text']);
3493 if ($this->mpdf->onlyCoreFonts)
3494 $objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->mpdf->mb_enc, 'UTF-8');
3495 }
3496 if (isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) {
3497 $objattr['space-width'] = $attr['SPACE-WIDTH'];
3498 }
3499 if (isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) {
3500 $objattr['char-width'] = $attr['CHAR-WIDTH'];
3501 }
3502
3503 // VISIBILITY
3504 $objattr['visibility'] = 'visible';
3505 if (isset($properties['VISIBILITY'])) {
3506 $v = strtolower($properties['VISIBILITY']);
3507 if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') {
3508 $objattr['visibility'] = $v;
3509 }
3510 }
3511 if (isset($properties['FONT-SIZE'])) {
3512 if (strtolower($properties['FONT-SIZE']) == 'auto') {
3513 if ($objattr['top-text'] && $objattr['bottom-text']) {
3514 $objattr['fontsize'] = -2;
3515 } else {
3516 $objattr['fontsize'] = -1;
3517 }
3518 } else {
3519 $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], ($this->mpdf->default_font_size / _MPDFK));
3520 $this->mpdf->SetFontSize($mmsize * _MPDFK, false);
3521 $objattr['fontsize'] = $this->mpdf->FontSizePt;
3522 }
3523 }
3524 if (isset($attr['DIVIDER'])) {
3525 $objattr['divider'] = strcode2utf($attr['DIVIDER']);
3526 $objattr['divider'] = $this->mpdf->lesser_entity_decode($objattr['divider']);
3527 if ($this->mpdf->onlyCoreFonts)
3528 $objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mpdf->mb_enc, 'UTF-8');
3529 }
3530
3531 if (isset($properties['COLOR'])) {
3532 $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']);
3533 }
3534
3535 $objattr['fontstyle'] = '';
3536 if (isset($properties['FONT-WEIGHT'])) {
3537 if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
3538 $objattr['fontstyle'] .= 'B';
3539 }
3540 }
3541 if (isset($properties['FONT-STYLE'])) {
3542 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
3543 $objattr['fontstyle'] .= 'I';
3544 }
3545 }
3546
3547 if (isset($properties['FONT-FAMILY'])) {
3548 $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false);
3549 }
3550 $objattr['fontfamily'] = $this->mpdf->FontFamily;
3551
3552 // VSPACE and HSPACE converted to margins in MergeCSS
3553 if (isset($properties['MARGIN-TOP'])) {
3554 $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3555 }
3556 if (isset($properties['MARGIN-BOTTOM'])) {
3557 $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3558 }
3559 if (isset($properties['MARGIN-LEFT'])) {
3560 $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3561 }
3562 if (isset($properties['MARGIN-RIGHT'])) {
3563 $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3564 }
3565
3566 if (isset($properties['PADDING-TOP'])) {
3567 $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3568 }
3569 if (isset($properties['PADDING-BOTTOM'])) {
3570 $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3571 }
3572 if (isset($properties['PADDING-LEFT'])) {
3573 $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3574 }
3575 if (isset($properties['PADDING-RIGHT'])) {
3576 $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3577 }
3578
3579 if (isset($properties['BORDER-TOP'])) {
3580 $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']);
3581 }
3582 if (isset($properties['BORDER-BOTTOM'])) {
3583 $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
3584 }
3585 if (isset($properties['BORDER-LEFT'])) {
3586 $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
3587 }
3588 if (isset($properties['BORDER-RIGHT'])) {
3589 $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
3590 }
3591
3592 if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
3593 $objattr['opacity'] = $properties['OPACITY'];
3594 }
3595 if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
3596 $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']);
3597 } else {
3598 $objattr['bgcolor'] = false;
3599 }
3600 if ($this->mpdf->HREF) {
3601 if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) {
3602 $href = $this->mpdf->HREF;
3603 while (array_key_exists($href, $this->mpdf->internallink))
3604 $href = "#" . $href;
3605 $this->mpdf->internallink[$href] = $this->mpdf->AddLink();
3606 $objattr['link'] = $this->mpdf->internallink[$href];
3607 } else {
3608 $objattr['link'] = $this->mpdf->HREF;
3609 }
3610 }
3611 $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
3612 $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
3613
3614
3615 $w = $objattr['r'] * 2;
3616 $h = $w;
3617 $objattr['height'] = $h + $extraheight;
3618 $objattr['width'] = $w + $extrawidth;
3619 $objattr['type'] = 'textcircle';
3620
3621 $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
3622
3623 // Clear properties - tidy up
3624 $properties = array();
3625
3626 /* -- TABLES -- */
3627 // Output it to buffers
3628 if ($this->mpdf->tableLevel) {
3629 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
3630 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width'];
3631 } else {
3632 /* -- END TABLES -- */
3633 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
3634 } // *TABLES*
3635
3636 if ($this->mpdf->InlineProperties[$tag]) {
3637 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
3638 }
3639 unset($this->mpdf->InlineProperties[$tag]);
3640
3641 break;
3642
3643
3644 /* -- TABLES -- */
3645
3646 case 'TABLE': // TABLE-BEGIN
3647 $this->mpdf->tdbegin = false;
3648 $this->mpdf->lastoptionaltag = '';
3649 // Disable vertical justification in columns
3650 if ($this->mpdf->ColActive) {
3651 $this->mpdf->colvAlign = '';
3652 } // *COLUMNS*
3653 if ($this->mpdf->lastblocklevelchange == 1) {
3654 $blockstate = 1;
3655 } // Top margins/padding only
3656 else if ($this->mpdf->lastblocklevelchange < 1) {
3657 $blockstate = 0;
3658 } // NO margins/padding
3659 // called from block after new div e.g. <div> ... <table> ... Outputs block top margin/border and padding
3660 if (count($this->mpdf->textbuffer) == 0 && $this->mpdf->lastblocklevelchange == 1 && !$this->mpdf->tableLevel && !$this->mpdf->kwt) {
3661 $this->mpdf->newFlowingBlock($this->mpdf->blk[$this->mpdf->blklvl]['width'], $this->mpdf->lineheight, '', false, 1, true, $this->mpdf->blk[$this->mpdf->blklvl]['direction']);
3662 $this->mpdf->finishFlowingBlock(true); // true = END of flowing block
3663 } else if (!$this->mpdf->tableLevel && count($this->mpdf->textbuffer)) {
3664 $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
3665 }
3666
3667 $this->mpdf->textbuffer = array();
3668 $this->mpdf->lastblocklevelchange = -1;
3669
3670
3671
3672 if ($this->mpdf->tableLevel) { // i.e. now a nested table coming...
3673 // Save current level table
3674 $this->mpdf->cell['PARENTCELL'] = $this->mpdf->saveInlineProperties();
3675 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['baseProperties'] = $this->mpdf->base_table_properties;
3676 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] = $this->mpdf->cell;
3677 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currrow'] = $this->mpdf->row;
3678 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currcol'] = $this->mpdf->col;
3679 }
3680 $this->mpdf->tableLevel++;
3681 $this->mpdf->cssmgr->tbCSSlvl++;
3682
3683 if ($this->mpdf->tableLevel > 1) { // inherit table properties from cell in which nested
3684 //$this->mpdf->base_table_properties['FONT-KERNING'] = ($this->mpdf->textvar & FC_KERNING); // mPDF 6
3685 $this->mpdf->base_table_properties['LETTER-SPACING'] = $this->mpdf->lSpacingCSS;
3686 $this->mpdf->base_table_properties['WORD-SPACING'] = $this->mpdf->wSpacingCSS;
3687 // mPDF 6
3688 $direction = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['direction'];
3689 $txta = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'];
3690 $cellLineHeight = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['cellLineHeight'];
3691 $cellLineStackingStrategy = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['cellLineStackingStrategy'];
3692 $cellLineStackingShift = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['cellLineStackingShift'];
3693 }
3694
3695 if (isset($this->mpdf->tbctr[$this->mpdf->tableLevel])) {
3696 $this->mpdf->tbctr[$this->mpdf->tableLevel] ++;
3697 } else {
3698 $this->mpdf->tbctr[$this->mpdf->tableLevel] = 1;
3699 }
3700
3701 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['level'] = $this->mpdf->tableLevel;
3702 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['levelid'] = $this->mpdf->tbctr[$this->mpdf->tableLevel];
3703
3704 if ($this->mpdf->tableLevel > $this->mpdf->innermostTableLevel) {
3705 $this->mpdf->innermostTableLevel = $this->mpdf->tableLevel;
3706 }
3707 if ($this->mpdf->tableLevel > 1) {
3708 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nestedpos'] = array($this->mpdf->row, $this->mpdf->col, $this->mpdf->tbctr[($this->mpdf->tableLevel - 1)]);
3709 }
3710 //++++++++++++++++++++++++++++
3711
3712 $this->mpdf->cell = array();
3713 $this->mpdf->col = -1; //int
3714 $this->mpdf->row = -1; //int
3715 $table = &$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]];
3716
3717 // New table - any level
3718 $table['direction'] = $this->mpdf->directionality;
3719 $table['bgcolor'] = false;
3720 $table['va'] = false;
3721 $table['txta'] = false;
3722 $table['topntail'] = false;
3723 $table['thead-underline'] = false;
3724 $table['border'] = false;
3725 $table['border_details']['R']['w'] = 0;
3726 $table['border_details']['L']['w'] = 0;
3727 $table['border_details']['T']['w'] = 0;
3728 $table['border_details']['B']['w'] = 0;
3729 $table['border_details']['R']['style'] = '';
3730 $table['border_details']['L']['style'] = '';
3731 $table['border_details']['T']['style'] = '';
3732 $table['border_details']['B']['style'] = '';
3733 $table['max_cell_border_width']['R'] = 0;
3734 $table['max_cell_border_width']['L'] = 0;
3735 $table['max_cell_border_width']['T'] = 0;
3736 $table['max_cell_border_width']['B'] = 0;
3737 $table['padding']['L'] = false;
3738 $table['padding']['R'] = false;
3739 $table['padding']['T'] = false;
3740 $table['padding']['B'] = false;
3741 $table['margin']['L'] = false;
3742 $table['margin']['R'] = false;
3743 $table['margin']['T'] = false;
3744 $table['margin']['B'] = false;
3745 $table['a'] = false;
3746 $table['border_spacing_H'] = false;
3747 $table['border_spacing_V'] = false;
3748 $table['decimal_align'] = false;
3749 $this->mpdf->Reset();
3750 $this->mpdf->InlineProperties = array();
3751 $this->mpdf->InlineBDF = array(); // mPDF 6
3752 $this->mpdf->InlineBDFctr = 0; // mPDF 6
3753 $table['nc'] = $table['nr'] = 0;
3754 $this->mpdf->tablethead = 0;
3755 $this->mpdf->tabletfoot = 0;
3756 $this->mpdf->tabletheadjustfinished = false;
3757
3758 // mPDF 6
3759 if ($this->mpdf->tableLevel > 1) { // inherit table properties from cell in which nested
3760 $table['direction'] = $direction;
3761 $table['txta'] = $txta;
3762 $table['cellLineHeight'] = $cellLineHeight;
3763 $table['cellLineStackingStrategy'] = $cellLineStackingStrategy;
3764 $table['cellLineStackingShift'] = $cellLineStackingShift;
3765 }
3766
3767
3768 if ($this->mpdf->blockjustfinished && !count($this->mpdf->textbuffer) && $this->mpdf->y != $this->mpdf->tMargin && $this->mpdf->collapseBlockMargins && $this->mpdf->tableLevel == 1) {
3769 $lastbottommargin = $this->mpdf->lastblockbottommargin;
3770 } else {
3771 $lastbottommargin = 0;
3772 }
3773 $this->mpdf->lastblockbottommargin = 0;
3774 $this->mpdf->blockjustfinished = false;
3775
3776 if ($this->mpdf->tableLevel == 1) {
3777 $table['headernrows'] = 0;
3778 $table['footernrows'] = 0;
3779 $this->mpdf->base_table_properties = array();
3780 }
3781
3782 // ADDED CSS FUNCIONS FOR TABLE
3783 if ($this->mpdf->cssmgr->tbCSSlvl == 1) {
3784 $properties = $this->mpdf->cssmgr->MergeCSS('TOPTABLE', $tag, $attr);
3785 } else {
3786 $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
3787 }
3788
3789 $w = '';
3790 if (isset($properties['WIDTH'])) {
3791 $w = $properties['WIDTH'];
3792 } else if (isset($attr['WIDTH']) && $attr['WIDTH']) {
3793 $w = $attr['WIDTH'];
3794 }
3795
3796 if (isset($attr['ALIGN']) && isset($align[strtolower($attr['ALIGN'])])) {
3797 $table['a'] = $align[strtolower($attr['ALIGN'])];
3798 }
3799 if (!$table['a']) {
3800 if ($table['direction'] == 'rtl') {
3801 $table['a'] = 'R';
3802 } else {
3803 $table['a'] = 'L';
3804 }
3805 }
3806
3807 if (isset($properties['DIRECTION']) && $properties['DIRECTION']) {
3808 $table['direction'] = strtolower($properties['DIRECTION']);
3809 } else if (isset($attr['DIR']) && $attr['DIR']) {
3810 $table['direction'] = strtolower($attr['DIR']);
3811 } else if ($this->mpdf->tableLevel == 1) {
3812 $table['direction'] = $this->mpdf->blk[$this->mpdf->blklvl]['direction'];
3813 }
3814
3815 if (isset($properties['BACKGROUND-COLOR'])) {
3816 $table['bgcolor'][-1] = $properties['BACKGROUND-COLOR'];
3817 } else if (isset($properties['BACKGROUND'])) {
3818 $table['bgcolor'][-1] = $properties['BACKGROUND'];
3819 } else if (isset($attr['BGCOLOR'])) {
3820 $table['bgcolor'][-1] = $attr['BGCOLOR'];
3821 }
3822
3823 if (isset($properties['VERTICAL-ALIGN']) && isset($align[strtolower($properties['VERTICAL-ALIGN'])])) {
3824 $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
3825 }
3826 if (isset($properties['TEXT-ALIGN']) && isset($align[strtolower($properties['TEXT-ALIGN'])])) {
3827 $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])];
3828 }
3829
3830 if (isset($properties['AUTOSIZE']) && $properties['AUTOSIZE'] && $this->mpdf->tableLevel == 1) {
3831 $this->mpdf->shrink_this_table_to_fit = $properties['AUTOSIZE'];
3832 if ($this->mpdf->shrink_this_table_to_fit < 1) {
3833 $this->mpdf->shrink_this_table_to_fit = 0;
3834 }
3835 }
3836 if (isset($properties['ROTATE']) && $properties['ROTATE'] && $this->mpdf->tableLevel == 1) {
3837 $this->mpdf->table_rotate = $properties['ROTATE'];
3838 }
3839 if (isset($properties['TOPNTAIL'])) {
3840 $table['topntail'] = $properties['TOPNTAIL'];
3841 }
3842 if (isset($properties['THEAD-UNDERLINE'])) {
3843 $table['thead-underline'] = $properties['THEAD-UNDERLINE'];
3844 }
3845
3846 if (isset($properties['BORDER'])) {
3847 $bord = $this->mpdf->border_details($properties['BORDER']);
3848 if ($bord['s']) {
3849 $table['border'] = _BORDER_ALL;
3850 $table['border_details']['R'] = $bord;
3851 $table['border_details']['L'] = $bord;
3852 $table['border_details']['T'] = $bord;
3853 $table['border_details']['B'] = $bord;
3854 }
3855 }
3856 if (isset($properties['BORDER-RIGHT'])) {
3857 if ($table['direction'] == 'rtl') { // *OTL*
3858 $table['border_details']['R'] = $this->mpdf->border_details($properties['BORDER-LEFT']); // *OTL*
3859 } // *OTL*
3860 else { // *OTL*
3861 $table['border_details']['R'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
3862 } // *OTL*
3863 $this->mpdf->setBorder($table['border'], _BORDER_RIGHT, $table['border_details']['R']['s']);
3864 }
3865 if (isset($properties['BORDER-LEFT'])) {
3866 if ($table['direction'] == 'rtl') { // *OTL*
3867 $table['border_details']['L'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); // *OTL*
3868 } // *OTL*
3869 else { // *OTL*
3870 $table['border_details']['L'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
3871 } // *OTL*
3872 $this->mpdf->setBorder($table['border'], _BORDER_LEFT, $table['border_details']['L']['s']);
3873 }
3874 if (isset($properties['BORDER-BOTTOM'])) {
3875 $table['border_details']['B'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
3876 $this->mpdf->setBorder($table['border'], _BORDER_BOTTOM, $table['border_details']['B']['s']);
3877 }
3878 if (isset($properties['BORDER-TOP'])) {
3879 $table['border_details']['T'] = $this->mpdf->border_details($properties['BORDER-TOP']);
3880 $this->mpdf->setBorder($table['border'], _BORDER_TOP, $table['border_details']['T']['s']);
3881 }
3882 if ($table['border']) {
3883 $this->mpdf->table_border_css_set = 1;
3884 } else {
3885 $this->mpdf->table_border_css_set = 0;
3886 }
3887
3888 // mPDF 6
3889 if (isset($properties['LANG']) && $properties['LANG']) {
3890 if ($this->mpdf->autoLangToFont && !$this->mpdf->usingCoreFont) {
3891 if ($properties['LANG'] != $this->mpdf->default_lang && $properties['LANG'] != 'UTF-8') {
3892 list ($coreSuitable, $mpdf_pdf_unifont) = GetLangOpts($properties['LANG'], $this->mpdf->useAdobeCJK, $this->mpdf->fontdata);
3893 if ($mpdf_pdf_unifont) {
3894 $properties['FONT-FAMILY'] = $mpdf_pdf_unifont;
3895 }
3896 }
3897 }
3898 $this->mpdf->currentLang = $properties['LANG'];
3899 }
3900
3901
3902 if (isset($properties['FONT-FAMILY'])) {
3903 $this->mpdf->default_font = $properties['FONT-FAMILY'];
3904 $this->mpdf->SetFont($this->mpdf->default_font, '', 0, false);
3905 }
3906 $this->mpdf->base_table_properties['FONT-FAMILY'] = $this->mpdf->FontFamily;
3907
3908 if (isset($properties['FONT-SIZE'])) {
3909 if ($this->mpdf->tableLevel > 1) {
3910 $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->base_table_properties['FONT-SIZE']);
3911 } else {
3912 $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK);
3913 }
3914 if ($mmsize) {
3915 $this->mpdf->default_font_size = $mmsize * (_MPDFK);
3916 $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
3917 }
3918 }
3919 $this->mpdf->base_table_properties['FONT-SIZE'] = $this->mpdf->FontSize . 'mm';
3920
3921 if (isset($properties['FONT-WEIGHT'])) {
3922 if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
3923 $this->mpdf->base_table_properties['FONT-WEIGHT'] = 'BOLD';
3924 }
3925 }
3926 if (isset($properties['FONT-STYLE'])) {
3927 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
3928 $this->mpdf->base_table_properties['FONT-STYLE'] = 'ITALIC';
3929 }
3930 }
3931 if (isset($properties['COLOR'])) {
3932 $this->mpdf->base_table_properties['COLOR'] = $properties['COLOR'];
3933 }
3934 if (isset($properties['FONT-KERNING'])) {
3935 $this->mpdf->base_table_properties['FONT-KERNING'] = $properties['FONT-KERNING'];
3936 }
3937 if (isset($properties['LETTER-SPACING'])) {
3938 $this->mpdf->base_table_properties['LETTER-SPACING'] = $properties['LETTER-SPACING'];
3939 }
3940 if (isset($properties['WORD-SPACING'])) {
3941 $this->mpdf->base_table_properties['WORD-SPACING'] = $properties['WORD-SPACING'];
3942 }
3943 // mPDF 6
3944 if (isset($properties['HYPHENS'])) {
3945 $this->mpdf->base_table_properties['HYPHENS'] = $properties['HYPHENS'];
3946 }
3947 if (isset($properties['LINE-HEIGHT']) && $properties['LINE-HEIGHT']) {
3948 $table['cellLineHeight'] = $this->mpdf->fixLineheight($properties['LINE-HEIGHT']);
3949 } else if ($this->mpdf->tableLevel == 1) {
3950 $table['cellLineHeight'] = $this->mpdf->blk[$this->mpdf->blklvl]['line_height'];
3951 }
3952
3953 if (isset($properties['LINE-STACKING-STRATEGY']) && $properties['LINE-STACKING-STRATEGY']) {
3954 $table['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']);
3955 } else if ($this->mpdf->tableLevel == 1 && isset($this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_strategy'])) {
3956 $table['cellLineStackingStrategy'] = $this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_strategy'];
3957 } else {
3958 $table['cellLineStackingStrategy'] = 'inline-line-height';
3959 }
3960
3961 if (isset($properties['LINE-STACKING-SHIFT']) && $properties['LINE-STACKING-SHIFT']) {
3962 $table['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']);
3963 } else if ($this->mpdf->tableLevel == 1 && isset($this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_shift'])) {
3964 $table['cellLineStackingShift'] = $this->mpdf->blk[$this->mpdf->blklvl]['line_stacking_shift'];
3965 } else {
3966 $table['cellLineStackingShift'] = 'consider-shifts';
3967 }
3968
3969 if (isset($properties['PADDING-LEFT'])) {
3970 $table['padding']['L'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3971 }
3972 if (isset($properties['PADDING-RIGHT'])) {
3973 $table['padding']['R'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3974 }
3975 if (isset($properties['PADDING-TOP'])) {
3976 $table['padding']['T'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3977 }
3978 if (isset($properties['PADDING-BOTTOM'])) {
3979 $table['padding']['B'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3980 }
3981
3982 if (isset($properties['MARGIN-TOP'])) {
3983 if ($lastbottommargin) {
3984 $tmp = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3985 if ($tmp > $lastbottommargin) {
3986 $properties['MARGIN-TOP'] -= $lastbottommargin;
3987 } else {
3988 $properties['MARGIN-TOP'] = 0;
3989 }
3990 }
3991 $table['margin']['T'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3992 }
3993
3994 if (isset($properties['MARGIN-BOTTOM'])) {
3995 $table['margin']['B'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3996 }
3997 if (isset($properties['MARGIN-LEFT'])) {
3998 $table['margin']['L'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
3999 }
4000
4001 if (isset($properties['MARGIN-RIGHT'])) {
4002 $table['margin']['R'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4003 }
4004 if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT']) == 'auto' && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
4005 $table['a'] = 'C';
4006 } else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
4007 $table['a'] = 'R';
4008 } else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
4009 $table['a'] = 'L';
4010 }
4011
4012 if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE']) == 'SEPARATE') {
4013 $table['borders_separate'] = true;
4014 } else {
4015 $table['borders_separate'] = false;
4016 }
4017
4018 // mPDF 5.7.3
4019
4020 if (isset($properties['BORDER-SPACING-H'])) {
4021 $table['border_spacing_H'] = $this->mpdf->ConvertSize($properties['BORDER-SPACING-H'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4022 }
4023 if (isset($properties['BORDER-SPACING-V'])) {
4024 $table['border_spacing_V'] = $this->mpdf->ConvertSize($properties['BORDER-SPACING-V'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4025 }
4026 // mPDF 5.7.3
4027 if (!$table['borders_separate']) {
4028 $table['border_spacing_H'] = $table['border_spacing_V'] = 0;
4029 }
4030
4031 if (isset($properties['EMPTY-CELLS'])) {
4032 $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show'
4033 } else {
4034 $table['empty_cells'] = '';
4035 }
4036
4037 if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && $this->mpdf->tableLevel == 1 && !$this->mpdf->writingHTMLfooter) {
4038 $this->mpdf->table_keep_together = true;
4039 } else if ($this->mpdf->tableLevel == 1) {
4040 $this->mpdf->table_keep_together = false;
4041 }
4042 if (isset($properties['PAGE-BREAK-AFTER']) && $this->mpdf->tableLevel == 1) {
4043 $table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
4044 }
4045
4046 /* -- BACKGROUNDS -- */
4047 if (isset($properties['BACKGROUND-GRADIENT']) && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
4048 $table['gradient'] = $properties['BACKGROUND-GRADIENT'];
4049 }
4050
4051 if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
4052 $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']);
4053 if ($ret) {
4054 $table['background-image'] = $ret;
4055 }
4056 }
4057 /* -- END BACKGROUNDS -- */
4058
4059 if (isset($properties['OVERFLOW'])) {
4060 $table['overflow'] = strtolower($properties['OVERFLOW']); // 'hidden' 'wrap' or 'visible' or 'auto'
4061 if (($this->mpdf->ColActive || $this->mpdf->tableLevel > 1) && $table['overflow'] == 'visible') {
4062 unset($table['overflow']);
4063 }
4064 }
4065
4066 $properties = array();
4067
4068
4069 if (isset($attr['CELLPADDING'])) {
4070 $table['cell_padding'] = $attr['CELLPADDING'];
4071 } else {
4072 $table['cell_padding'] = false;
4073 }
4074
4075 if (isset($attr['BORDER']) && $attr['BORDER'] == '1') {
4076 $this->mpdf->table_border_attr_set = 1;
4077 $bord = $this->mpdf->border_details('#000000 1px solid');
4078 if ($bord['s']) {
4079 $table['border'] = _BORDER_ALL;
4080 $table['border_details']['R'] = $bord;
4081 $table['border_details']['L'] = $bord;
4082 $table['border_details']['T'] = $bord;
4083 $table['border_details']['B'] = $bord;
4084 }
4085 } else {
4086 $this->mpdf->table_border_attr_set = 0;
4087 }
4088
4089 if ($w) {
4090 $maxwidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
4091 if ($table['borders_separate']) {
4092 $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['border_details']['L']['w'] / 2 + $table['border_details']['R']['w'] / 2;
4093 } else {
4094 $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['max_cell_border_width']['L'] / 2 + $table['max_cell_border_width']['R'] / 2;
4095 }
4096 if (strpos($w, '%') && $this->mpdf->tableLevel == 1 && !$this->mpdf->ignore_table_percents) {
4097 // % needs to be of inner box without table margins etc.
4098 $maxwidth -= $tblblw;
4099 $wmm = $this->mpdf->ConvertSize($w, $maxwidth, $this->mpdf->FontSize, false);
4100 $table['w'] = $wmm + $tblblw;
4101 }
4102 if (strpos($w, '%') && $this->mpdf->tableLevel > 1 && !$this->mpdf->ignore_table_percents && $this->mpdf->keep_table_proportions) {
4103 $table['wpercent'] = $w + 0; // makes 80% -> 80
4104 }
4105 if (!strpos($w, '%') && !$this->mpdf->ignore_table_widths) {
4106 $wmm = $this->mpdf->ConvertSize($w, $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4107 $table['w'] = $wmm + $tblblw;
4108 }
4109 if (!$this->mpdf->keep_table_proportions) {
4110 if (isset($table['w']) && $table['w'] > $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']) {
4111 $table['w'] = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'];
4112 }
4113 }
4114 }
4115
4116 if (isset($attr['AUTOSIZE']) && $this->mpdf->tableLevel == 1) {
4117 $this->mpdf->shrink_this_table_to_fit = $attr['AUTOSIZE'];
4118 if ($this->mpdf->shrink_this_table_to_fit < 1) {
4119 $this->mpdf->shrink_this_table_to_fit = 1;
4120 }
4121 }
4122 if (isset($attr['ROTATE']) && $this->mpdf->tableLevel == 1) {
4123 $this->mpdf->table_rotate = $attr['ROTATE'];
4124 }
4125
4126 //++++++++++++++++++++++++++++
4127 if ($this->mpdf->table_rotate) {
4128 $this->mpdf->tbrot_Links = array();
4129 $this->mpdf->tbrot_Annots = array();
4130 $this->mpdf->tbrotForms = array();
4131 $this->mpdf->tbrot_BMoutlines = array();
4132 $this->mpdf->tbrot_toc = array();
4133 }
4134
4135 if ($this->mpdf->kwt) {
4136 if ($this->mpdf->table_rotate) {
4137 $this->mpdf->table_keep_together = true;
4138 }
4139 $this->mpdf->kwt = false;
4140 $this->mpdf->kwt_saved = true;
4141 }
4142
4143 if ($this->mpdf->tableLevel == 1 && $this->mpdf->useGraphs) {
4144 if (isset($attr['ID']) && $attr['ID']) {
4145 $this->mpdf->currentGraphId = strtoupper($attr['ID']);
4146 } else {
4147 $this->mpdf->currentGraphId = '0';
4148 }
4149 $this->mpdf->graphs[$this->mpdf->currentGraphId] = array();
4150 }
4151 //++++++++++++++++++++++++++++
4152 $this->mpdf->plainCell_properties = array();
4153 unset($table);
4154 break;
4155
4156 case 'THEAD':
4157 $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
4158 $this->mpdf->cssmgr->tbCSSlvl++;
4159 $this->mpdf->tablethead = 1;
4160 $this->mpdf->tabletfoot = 0;
4161 $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
4162 if (isset($properties['FONT-WEIGHT'])) {
4163 if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
4164 $this->mpdf->thead_font_weight = 'B';
4165 } else {
4166 $this->mpdf->thead_font_weight = '';
4167 }
4168 }
4169
4170 if (isset($properties['FONT-STYLE'])) {
4171 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
4172 $this->mpdf->thead_font_style = 'I';
4173 } else {
4174 $this->mpdf->thead_font_style = '';
4175 }
4176 }
4177 if (isset($properties['FONT-VARIANT'])) {
4178 if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') {
4179 $this->mpdf->thead_font_smCaps = 'S';
4180 } else {
4181 $this->mpdf->thead_font_smCaps = '';
4182 }
4183 }
4184
4185 if (isset($properties['VERTICAL-ALIGN'])) {
4186 $this->mpdf->thead_valign_default = $properties['VERTICAL-ALIGN'];
4187 }
4188 if (isset($properties['TEXT-ALIGN'])) {
4189 $this->mpdf->thead_textalign_default = $properties['TEXT-ALIGN'];
4190 }
4191 $properties = array();
4192 break;
4193
4194 case 'TFOOT':
4195 $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
4196 $this->mpdf->cssmgr->tbCSSlvl++;
4197 $this->mpdf->tabletfoot = 1;
4198 $this->mpdf->tablethead = 0;
4199 $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
4200 if (isset($properties['FONT-WEIGHT'])) {
4201 if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
4202 $this->mpdf->tfoot_font_weight = 'B';
4203 } else {
4204 $this->mpdf->tfoot_font_weight = '';
4205 }
4206 }
4207
4208 if (isset($properties['FONT-STYLE'])) {
4209 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
4210 $this->mpdf->tfoot_font_style = 'I';
4211 } else {
4212 $this->mpdf->tfoot_font_style = '';
4213 }
4214 }
4215 if (isset($properties['FONT-VARIANT'])) {
4216 if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') {
4217 $this->mpdf->tfoot_font_smCaps = 'S';
4218 } else {
4219 $this->mpdf->tfoot_font_smCaps = '';
4220 }
4221 }
4222
4223 if (isset($properties['VERTICAL-ALIGN'])) {
4224 $this->mpdf->tfoot_valign_default = $properties['VERTICAL-ALIGN'];
4225 }
4226 if (isset($properties['TEXT-ALIGN'])) {
4227 $this->mpdf->tfoot_textalign_default = $properties['TEXT-ALIGN'];
4228 }
4229 $properties = array();
4230 break;
4231
4232
4233 case 'TBODY':
4234 $this->mpdf->tablethead = 0;
4235 $this->mpdf->tabletfoot = 0;
4236 $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
4237 $this->mpdf->cssmgr->tbCSSlvl++;
4238 $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
4239 break;
4240
4241
4242 case 'TR':
4243 $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
4244 $this->mpdf->cssmgr->tbCSSlvl++;
4245 $this->mpdf->row++;
4246 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr'] ++;
4247 $this->mpdf->col = -1;
4248 $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
4249
4250 if (!$this->mpdf->simpleTables && (!isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate']) || !$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['borders_separate'])) {
4251 if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
4252 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-left'][$this->mpdf->row] = $properties['BORDER-LEFT'];
4253 }
4254 if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
4255 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-right'][$this->mpdf->row] = $properties['BORDER-RIGHT'];
4256 }
4257 if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
4258 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-top'][$this->mpdf->row] = $properties['BORDER-TOP'];
4259 }
4260 if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
4261 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-bottom'][$this->mpdf->row] = $properties['BORDER-BOTTOM'];
4262 }
4263 }
4264
4265 if (isset($properties['BACKGROUND-COLOR'])) {
4266 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$this->mpdf->row] = $properties['BACKGROUND-COLOR'];
4267 } else if (isset($attr['BGCOLOR']))
4268 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$this->mpdf->row] = $attr['BGCOLOR'];
4269
4270 /* -- BACKGROUNDS -- */
4271 if (isset($properties['BACKGROUND-GRADIENT']) && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
4272 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$this->mpdf->row] = $properties['BACKGROUND-GRADIENT'];
4273 }
4274
4275 if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive) {
4276 $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']);
4277 if ($ret) {
4278 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$this->mpdf->row] = $ret;
4279 }
4280 }
4281 /* -- END BACKGROUNDS -- */
4282
4283
4284
4285
4286 if (isset($properties['TEXT-ROTATE'])) {
4287 $this->mpdf->trow_text_rotate = $properties['TEXT-ROTATE'];
4288 }
4289 if (isset($attr['TEXT-ROTATE']))
4290 $this->mpdf->trow_text_rotate = $attr['TEXT-ROTATE'];
4291
4292 if ($this->mpdf->tablethead) {
4293 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'][$this->mpdf->row] = true;
4294 }
4295 if ($this->mpdf->tabletfoot) {
4296 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$this->mpdf->row] = true;
4297 }
4298 $properties = array();
4299 break;
4300
4301
4302 case 'TH':
4303 case 'TD':
4304 $this->mpdf->ignorefollowingspaces = true;
4305 $this->mpdf->lastoptionaltag = $tag; // Save current HTML specified optional endtag
4306 $this->mpdf->cssmgr->tbCSSlvl++;
4307 $this->mpdf->InlineProperties = array();
4308 $this->mpdf->InlineBDF = array(); // mPDF 6
4309 $this->mpdf->InlineBDFctr = 0; // mPDF 6
4310 $this->mpdf->tdbegin = true;
4311 $this->mpdf->col++;
4312 while (isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col])) {
4313 $this->mpdf->col++;
4314 }
4315
4316 //Update number column
4317 if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] < $this->mpdf->col + 1) {
4318 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] = $this->mpdf->col + 1;
4319 }
4320
4321 $table = &$this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]];
4322
4323 $c = array('a' => false,
4324 'R' => false,
4325 'nowrap' => false,
4326 'bgcolor' => false,
4327 'padding' => array('L' => false,
4328 'R' => false,
4329 'T' => false,
4330 'B' => false
4331 )
4332 );
4333
4334 if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
4335 $table['simple']['border'] = false;
4336 $table['simple']['border_details']['R']['w'] = 0;
4337 $table['simple']['border_details']['L']['w'] = 0;
4338 $table['simple']['border_details']['T']['w'] = 0;
4339 $table['simple']['border_details']['B']['w'] = 0;
4340 $table['simple']['border_details']['R']['style'] = '';
4341 $table['simple']['border_details']['L']['style'] = '';
4342 $table['simple']['border_details']['T']['style'] = '';
4343 $table['simple']['border_details']['B']['style'] = '';
4344 } else if (!$this->mpdf->simpleTables) {
4345 $c['border'] = false;
4346 $c['border_details']['R']['w'] = 0;
4347 $c['border_details']['L']['w'] = 0;
4348 $c['border_details']['T']['w'] = 0;
4349 $c['border_details']['B']['w'] = 0;
4350 $c['border_details']['mbw']['BL'] = 0;
4351 $c['border_details']['mbw']['BR'] = 0;
4352 $c['border_details']['mbw']['RT'] = 0;
4353 $c['border_details']['mbw']['RB'] = 0;
4354 $c['border_details']['mbw']['TL'] = 0;
4355 $c['border_details']['mbw']['TR'] = 0;
4356 $c['border_details']['mbw']['LT'] = 0;
4357 $c['border_details']['mbw']['LB'] = 0;
4358 $c['border_details']['R']['style'] = '';
4359 $c['border_details']['L']['style'] = '';
4360 $c['border_details']['T']['style'] = '';
4361 $c['border_details']['B']['style'] = '';
4362 $c['border_details']['R']['s'] = 0;
4363 $c['border_details']['L']['s'] = 0;
4364 $c['border_details']['T']['s'] = 0;
4365 $c['border_details']['B']['s'] = 0;
4366 $c['border_details']['R']['c'] = $this->mpdf->ConvertColor(0);
4367 $c['border_details']['L']['c'] = $this->mpdf->ConvertColor(0);
4368 $c['border_details']['T']['c'] = $this->mpdf->ConvertColor(0);
4369 $c['border_details']['B']['c'] = $this->mpdf->ConvertColor(0);
4370 $c['border_details']['R']['dom'] = 0;
4371 $c['border_details']['L']['dom'] = 0;
4372 $c['border_details']['T']['dom'] = 0;
4373 $c['border_details']['B']['dom'] = 0;
4374 $c['border_details']['cellposdom'] = 0;
4375 }
4376
4377
4378 if ($table['va']) {
4379 $c['va'] = $table['va'];
4380 }
4381 if ($table['txta']) {
4382 $c['a'] = $table['txta'];
4383 }
4384 if ($this->mpdf->table_border_attr_set) {
4385 if ($table['border_details']) {
4386 if (!$this->mpdf->simpleTables) {
4387 $c['border_details']['R'] = $table['border_details']['R'];
4388 $c['border_details']['L'] = $table['border_details']['L'];
4389 $c['border_details']['T'] = $table['border_details']['T'];
4390 $c['border_details']['B'] = $table['border_details']['B'];
4391 $c['border'] = $table['border'];
4392 $c['border_details']['L']['dom'] = 1;
4393 $c['border_details']['R']['dom'] = 1;
4394 $c['border_details']['T']['dom'] = 1;
4395 $c['border_details']['B']['dom'] = 1;
4396 } else if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
4397 $table['simple']['border_details']['R'] = $table['border_details']['R'];
4398 $table['simple']['border_details']['L'] = $table['border_details']['L'];
4399 $table['simple']['border_details']['T'] = $table['border_details']['T'];
4400 $table['simple']['border_details']['B'] = $table['border_details']['B'];
4401 $table['simple']['border'] = $table['border'];
4402 }
4403 }
4404 }
4405 // INHERITED THEAD CSS Properties
4406 if ($this->mpdf->tablethead) {
4407 if ($this->mpdf->thead_valign_default)
4408 $c['va'] = $align[strtolower($this->mpdf->thead_valign_default)];
4409 if ($this->mpdf->thead_textalign_default)
4410 $c['a'] = $align[strtolower($this->mpdf->thead_textalign_default)];
4411 if ($this->mpdf->thead_font_weight == 'B') {
4412 $this->mpdf->SetStyle('B', true);
4413 }
4414 if ($this->mpdf->thead_font_style == 'I') {
4415 $this->mpdf->SetStyle('I', true);
4416 }
4417 if ($this->mpdf->thead_font_smCaps == 'S') {
4418 $this->mpdf->textvar = ($this->mpdf->textvar | FC_SMALLCAPS);
4419 } // mPDF 5.7.1
4420 }
4421
4422 // INHERITED TFOOT CSS Properties
4423 if ($this->mpdf->tabletfoot) {
4424 if ($this->mpdf->tfoot_valign_default)
4425 $c['va'] = $align[strtolower($this->mpdf->tfoot_valign_default)];
4426 if ($this->mpdf->tfoot_textalign_default)
4427 $c['a'] = $align[strtolower($this->mpdf->tfoot_textalign_default)];
4428 if ($this->mpdf->tfoot_font_weight == 'B') {
4429 $this->mpdf->SetStyle('B', true);
4430 }
4431 if ($this->mpdf->tfoot_font_style == 'I') {
4432 $this->mpdf->SetStyle('I', true);
4433 }
4434 if ($this->mpdf->tfoot_font_style == 'S') {
4435 $this->mpdf->textvar = ($this->mpdf->textvar | FC_SMALLCAPS);
4436 } // mPDF 5.7.1
4437 }
4438
4439
4440 if ($this->mpdf->trow_text_rotate) {
4441 $c['R'] = $this->mpdf->trow_text_rotate;
4442 }
4443
4444 $this->mpdf->cell_border_dominance_L = 0;
4445 $this->mpdf->cell_border_dominance_R = 0;
4446 $this->mpdf->cell_border_dominance_T = 0;
4447 $this->mpdf->cell_border_dominance_B = 0;
4448
4449 $properties = $this->mpdf->cssmgr->MergeCSS('TABLE', $tag, $attr);
4450
4451 $properties = $this->mpdf->cssmgr->array_merge_recursive_unique($this->mpdf->base_table_properties, $properties);
4452
4453 $this->mpdf->Reset(); // mPDF 6 ?????????????????????
4454
4455 $this->mpdf->setCSS($properties, 'TABLECELL', $tag);
4456
4457 $c['dfs'] = $this->mpdf->FontSize; // Default Font size
4458
4459
4460 if (isset($properties['BACKGROUND-COLOR'])) {
4461 $c['bgcolor'] = $properties['BACKGROUND-COLOR'];
4462 } else if (isset($properties['BACKGROUND'])) {
4463 $c['bgcolor'] = $properties['BACKGROUND'];
4464 } else if (isset($attr['BGCOLOR']))
4465 $c['bgcolor'] = $attr['BGCOLOR'];
4466
4467
4468
4469 /* -- BACKGROUNDS -- */
4470 if (isset($properties['BACKGROUND-GRADIENT'])) {
4471 $c['gradient'] = $properties['BACKGROUND-GRADIENT'];
4472 } else {
4473 $c['gradient'] = false;
4474 }
4475
4476 if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->keep_block_together) {
4477 $ret = $this->mpdf->SetBackground($properties, $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']);
4478 if ($ret) {
4479 $c['background-image'] = $ret;
4480 }
4481 }
4482 /* -- END BACKGROUNDS -- */
4483 if (isset($properties['VERTICAL-ALIGN'])) {
4484 $c['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
4485 } else if (isset($attr['VALIGN']))
4486 $c['va'] = $align[strtolower($attr['VALIGN'])];
4487
4488
4489 if (isset($properties['TEXT-ALIGN']) && $properties['TEXT-ALIGN']) {
4490 if (substr($properties['TEXT-ALIGN'], 0, 1) == 'D') {
4491 $c['a'] = $properties['TEXT-ALIGN'];
4492 } else {
4493 $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])];
4494 }
4495 }
4496 if (isset($attr['ALIGN']) && $attr['ALIGN']) {
4497 if (strtolower($attr['ALIGN']) == 'char') {
4498 if (isset($attr['CHAR']) && $attr['CHAR']) {
4499 $char = html_entity_decode($attr['CHAR']);
4500 $char = strcode2utf($char);
4501 $d = array_search($char, $this->mpdf->decimal_align);
4502 if ($d !== false) {
4503 $c['a'] = $d . 'R';
4504 }
4505 } else {
4506 $c['a'] = 'DPR';
4507 }
4508 } else {
4509 $c['a'] = $align[strtolower($attr['ALIGN'])];
4510 }
4511 }
4512
4513 // mPDF 6
4514 $c['direction'] = $table['direction'];
4515 if (isset($attr['DIR']) and $attr['DIR'] != '') {
4516 $c['direction'] = strtolower($attr['DIR']);
4517 }
4518 if (isset($properties['DIRECTION'])) {
4519 $c['direction'] = strtolower($properties['DIRECTION']);
4520 }
4521
4522 if (!$c['a']) {
4523 if (isset($c['direction']) && $c['direction'] == 'rtl') {
4524 $c['a'] = 'R';
4525 } else {
4526 $c['a'] = 'L';
4527 }
4528 }
4529
4530 $c['cellLineHeight'] = $table['cellLineHeight'];
4531 if (isset($properties['LINE-HEIGHT'])) {
4532 $c['cellLineHeight'] = $this->mpdf->fixLineheight($properties['LINE-HEIGHT']);
4533 }
4534
4535 $c['cellLineStackingStrategy'] = $table['cellLineStackingStrategy'];
4536 if (isset($properties['LINE-STACKING-STRATEGY'])) {
4537 $c['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']);
4538 }
4539
4540 $c['cellLineStackingShift'] = $table['cellLineStackingShift'];
4541 if (isset($properties['LINE-STACKING-SHIFT'])) {
4542 $c['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']);
4543 }
4544
4545 if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] || $properties['TEXT-ROTATE'] === "0")) {
4546 $c['R'] = $properties['TEXT-ROTATE'];
4547 }
4548 if (isset($properties['BORDER'])) {
4549 $bord = $this->mpdf->border_details($properties['BORDER']);
4550 if ($bord['s']) {
4551 if (!$this->mpdf->simpleTables) {
4552 $c['border'] = _BORDER_ALL;
4553 $c['border_details']['R'] = $bord;
4554 $c['border_details']['L'] = $bord;
4555 $c['border_details']['T'] = $bord;
4556 $c['border_details']['B'] = $bord;
4557 $c['border_details']['L']['dom'] = $this->mpdf->cell_border_dominance_L;
4558 $c['border_details']['R']['dom'] = $this->mpdf->cell_border_dominance_R;
4559 $c['border_details']['T']['dom'] = $this->mpdf->cell_border_dominance_T;
4560 $c['border_details']['B']['dom'] = $this->mpdf->cell_border_dominance_B;
4561 } else if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
4562 $table['simple']['border'] = _BORDER_ALL;
4563 $table['simple']['border_details']['R'] = $bord;
4564 $table['simple']['border_details']['L'] = $bord;
4565 $table['simple']['border_details']['T'] = $bord;
4566 $table['simple']['border_details']['B'] = $bord;
4567 }
4568 }
4569 }
4570 if (!$this->mpdf->simpleTables) {
4571 if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
4572 $c['border_details']['R'] = $this->mpdf->border_details($properties['BORDER-RIGHT']);
4573 $this->mpdf->setBorder($c['border'], _BORDER_RIGHT, $c['border_details']['R']['s']);
4574 $c['border_details']['R']['dom'] = $this->mpdf->cell_border_dominance_R;
4575 }
4576 if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
4577 $c['border_details']['L'] = $this->mpdf->border_details($properties['BORDER-LEFT']);
4578 $this->mpdf->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
4579 $c['border_details']['L']['dom'] = $this->mpdf->cell_border_dominance_L;
4580 }
4581 if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
4582 $c['border_details']['B'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']);
4583 $this->mpdf->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
4584 $c['border_details']['B']['dom'] = $this->mpdf->cell_border_dominance_B;
4585 }
4586 if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
4587 $c['border_details']['T'] = $this->mpdf->border_details($properties['BORDER-TOP']);
4588 $this->mpdf->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
4589 $c['border_details']['T']['dom'] = $this->mpdf->cell_border_dominance_T;
4590 }
4591 } else if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0) {
4592 if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
4593 $bord = $this->mpdf->border_details($properties['BORDER-LEFT']);
4594 if ($bord['s']) {
4595 $table['simple']['border'] = _BORDER_ALL;
4596 } else {
4597 $table['simple']['border'] = 0;
4598 }
4599 $table['simple']['border_details']['R'] = $bord;
4600 $table['simple']['border_details']['L'] = $bord;
4601 $table['simple']['border_details']['T'] = $bord;
4602 $table['simple']['border_details']['B'] = $bord;
4603 }
4604 }
4605
4606 if ($this->mpdf->simpleTables && $this->mpdf->row == 0 && $this->mpdf->col == 0 && !$table['borders_separate'] && $table['simple']['border']) {
4607 $table['border_details'] = $table['simple']['border_details'];
4608 $table['border'] = $table['simple']['border'];
4609 }
4610
4611 // Border set on TR (if collapsed only)
4612 if (!$table['borders_separate'] && !$this->mpdf->simpleTables && isset($table['trborder-left'][$this->mpdf->row])) {
4613 if ($this->mpdf->col == 0) {
4614 $left = $this->mpdf->border_details($table['trborder-left'][$this->mpdf->row]);
4615 $c['border_details']['L'] = $left;
4616 $this->mpdf->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
4617 }
4618 $c['border_details']['B'] = $this->mpdf->border_details($table['trborder-bottom'][$this->mpdf->row]);
4619 $this->mpdf->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
4620 $c['border_details']['T'] = $this->mpdf->border_details($table['trborder-top'][$this->mpdf->row]);
4621 $this->mpdf->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
4622 }
4623
4624 if ($this->mpdf->packTableData && !$this->mpdf->simpleTables) {
4625 $c['borderbin'] = $this->mpdf->_packCellBorder($c);
4626 unset($c['border']);
4627 unset($c['border_details']);
4628 }
4629
4630 if (isset($properties['PADDING-LEFT'])) {
4631 $c['padding']['L'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4632 }
4633 if (isset($properties['PADDING-RIGHT'])) {
4634 $c['padding']['R'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4635 }
4636 if (isset($properties['PADDING-BOTTOM'])) {
4637 $c['padding']['B'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4638 }
4639 if (isset($properties['PADDING-TOP'])) {
4640 $c['padding']['T'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4641 }
4642
4643 $w = '';
4644 if (isset($properties['WIDTH'])) {
4645 $w = $properties['WIDTH'];
4646 } else if (isset($attr['WIDTH'])) {
4647 $w = $attr['WIDTH'];
4648 }
4649 if ($w) {
4650 if (strpos($w, '%') && !$this->mpdf->ignore_table_percents) {
4651 $c['wpercent'] = $w + 0;
4652 } // makes 80% -> 80
4653 else if (!strpos($w, '%') && !$this->mpdf->ignore_table_widths) {
4654 $c['w'] = $this->mpdf->ConvertSize($w, $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4655 }
4656 }
4657
4658 if (isset($properties['HEIGHT']) && !strpos($properties['HEIGHT'], '%')) {
4659 $c['h'] = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4660 } else if (isset($attr['HEIGHT']) && !strpos($attr['HEIGHT'], '%'))
4661 $c['h'] = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false);
4662
4663 if (isset($properties['WHITE-SPACE'])) {
4664 if (strtoupper($properties['WHITE-SPACE']) == 'NOWRAP') {
4665 $c['nowrap'] = 1;
4666 }
4667 }
4668 $properties = array();
4669
4670
4671 if (isset($attr['TEXT-ROTATE'])) {
4672 $c['R'] = $attr['TEXT-ROTATE'];
4673 }
4674 if (isset($attr['NOWRAP']) && $attr['NOWRAP'])
4675 $c['nowrap'] = 1;
4676
4677 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col] = $c;
4678 unset($c);
4679 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0;
4680
4681 $cs = $rs = 1;
4682 if (isset($attr['COLSPAN']) && $attr['COLSPAN'] > 1)
4683 $cs = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['colspan'] = $attr['COLSPAN'];
4684 if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] < $this->mpdf->col + $cs) {
4685 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'] = $this->mpdf->col + $cs;
4686 } // following code moved outside if...
4687 for ($l = $this->mpdf->col; $l < $this->mpdf->col + $cs; $l++) {
4688 if ($l - $this->mpdf->col)
4689 $this->mpdf->cell[$this->mpdf->row][$l] = 0;
4690 }
4691 if (isset($attr['ROWSPAN']) && $attr['ROWSPAN'] > 1)
4692 $rs = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['rowspan'] = $attr['ROWSPAN'];
4693 for ($k = $this->mpdf->row; $k < $this->mpdf->row + $rs; $k++) {
4694 for ($l = $this->mpdf->col; $l < $this->mpdf->col + $cs; $l++) {
4695 if ($k - $this->mpdf->row || $l - $this->mpdf->col)
4696 $this->mpdf->cell[$k][$l] = 0;
4697 }
4698 }
4699 unset($table);
4700 break;
4701 /* -- END TABLES -- */
4702 }//end of switch
4703 }
4704
4705 function CloseTag($tag, &$ahtml, &$ihtml)
4706 { // mPDF 6
4707 //Closing tag
4708 if ($tag == 'OPTION') {
4709 $this->mpdf->selectoption['ACTIVE'] = false;
4710 $this->mpdf->lastoptionaltag = '';
4711 }
4712
4713 if ($tag == 'TTS' or $tag == 'TTA' or $tag == 'TTZ') {
4714 if ($this->mpdf->InlineProperties[$tag]) {
4715 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
4716 }
4717 unset($this->mpdf->InlineProperties[$tag]);
4718 $ltag = strtolower($tag);
4719 $this->mpdf->$ltag = false;
4720 }
4721
4722
4723 if ($tag == 'FONT' || $tag == 'SPAN' || $tag == 'CODE' || $tag == 'KBD' || $tag == 'SAMP' || $tag == 'TT' || $tag == 'VAR' || $tag == 'INS' || $tag == 'STRONG' || $tag == 'CITE' || $tag == 'SUB' || $tag == 'SUP' || $tag == 'S' || $tag == 'STRIKE' || $tag == 'DEL' || $tag == 'Q' || $tag == 'EM' || $tag == 'B' || $tag == 'I' || $tag == 'U' | $tag == 'SMALL' || $tag == 'BIG' || $tag == 'ACRONYM' || $tag == 'MARK' || $tag == 'TIME' || $tag == 'PROGRESS' || $tag == 'METER' || $tag == 'BDO' || $tag == 'BDI'
4724 ) {
4725
4726 $annot = false; // mPDF 6
4727 $bdf = false; // mPDF 6
4728 // mPDF 5.7.3 Inline tags
4729 if ($tag == 'PROGRESS' || $tag == 'METER') {
4730 if (isset($this->mpdf->InlineProperties[$tag]) && $this->mpdf->InlineProperties[$tag]) {
4731 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
4732 }
4733 unset($this->mpdf->InlineProperties[$tag]);
4734 if (isset($this->mpdf->InlineAnnots[$tag]) && $this->mpdf->InlineAnnots[$tag]) {
4735 $annot = $this->mpdf->InlineAnnots[$tag];
4736 } // *ANNOTATIONS*
4737 unset($this->mpdf->InlineAnnots[$tag]); // *ANNOTATIONS*
4738 } else {
4739 if (isset($this->mpdf->InlineProperties[$tag]) && count($this->mpdf->InlineProperties[$tag])) {
4740 $tmpProps = array_pop($this->mpdf->InlineProperties[$tag]); // mPDF 5.7.4
4741 $this->mpdf->restoreInlineProperties($tmpProps);
4742 }
4743 if (isset($this->mpdf->InlineAnnots[$tag]) && count($this->mpdf->InlineAnnots[$tag])) { // *ANNOTATIONS*
4744 $annot = array_pop($this->mpdf->InlineAnnots[$tag]); // *ANNOTATIONS*
4745 } // *ANNOTATIONS*
4746 if (isset($this->mpdf->InlineBDF[$tag]) && count($this->mpdf->InlineBDF[$tag])) { // mPDF 6
4747 $bdfarr = array_pop($this->mpdf->InlineBDF[$tag]);
4748 $bdf = $bdfarr[0];
4749 }
4750 }
4751
4752 /* -- ANNOTATIONS -- */
4753 if ($annot) { // mPDF 6
4754 if ($this->mpdf->tableLevel) { // *TABLES*
4755 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($annot); // *TABLES*
4756 } // *TABLES*
4757 else { // *TABLES*
4758 $this->mpdf->textbuffer[] = array($annot);
4759 } // *TABLES*
4760 }
4761 /* -- END ANNOTATIONS -- */
4762
4763 // mPDF 6 bidi
4764 // mPDF 6 Bidirectional formatting for inline elements
4765 if ($bdf) {
4766 $popf = $this->mpdf->_setBidiCodes('end', $bdf);
4767 $this->mpdf->OTLdata = array();
4768 if ($this->mpdf->tableLevel) {
4769 $this->mpdf->_saveCellTextBuffer($popf);
4770 } else {
4771 $this->mpdf->_saveTextBuffer($popf);
4772 }
4773 }
4774 } // End of (most) Inline elements eg SPAN
4775
4776
4777 if ($tag == 'METER' || $tag == 'PROGRESS') {
4778 $this->mpdf->ignorefollowingspaces = false;
4779 $this->mpdf->inMeter = false;
4780 }
4781
4782
4783 if ($tag == 'A') {
4784 $this->mpdf->HREF = '';
4785 if (isset($this->mpdf->InlineProperties['A'])) {
4786 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['A']);
4787 }
4788 unset($this->mpdf->InlineProperties['A']);
4789 }
4790
4791 if ($tag == 'LEGEND') {
4792 if (count($this->mpdf->textbuffer) && !$this->mpdf->tableLevel) {
4793 $leg = $this->mpdf->textbuffer[(count($this->mpdf->textbuffer) - 1)];
4794 unset($this->mpdf->textbuffer[(count($this->mpdf->textbuffer) - 1)]);
4795 $this->mpdf->textbuffer = array_values($this->mpdf->textbuffer);
4796 $this->mpdf->blk[$this->mpdf->blklvl]['border_legend'] = $leg;
4797 $this->mpdf->blk[$this->mpdf->blklvl]['margin_top'] += ($leg[11] / 2) / _MPDFK;
4798 $this->mpdf->blk[$this->mpdf->blklvl]['padding_top'] += ($leg[11] / 2) / _MPDFK;
4799 }
4800 if (isset($this->mpdf->InlineProperties['LEGEND'])) {
4801 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['LEGEND']);
4802 }
4803 unset($this->mpdf->InlineProperties['LEGEND']);
4804 $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
4805 }
4806
4807 /* -- FORMS -- */
4808 // *********** FORM ELEMENTS ********************
4809
4810 if ($tag == 'TEXTAREA') {
4811 $this->mpdf->ignorefollowingspaces = false;
4812 $this->mpdf->specialcontent = '';
4813 if ($this->mpdf->InlineProperties[$tag]) {
4814 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
4815 }
4816 unset($this->mpdf->InlineProperties[$tag]);
4817 }
4818
4819
4820 if ($tag == 'SELECT') {
4821 $this->mpdf->ignorefollowingspaces = false;
4822 $this->mpdf->lastoptionaltag = '';
4823 $texto = '';
4824 $OTLdata = false;
4825 if (isset($this->mpdf->selectoption['SELECTED'])) {
4826 $texto = $this->mpdf->selectoption['SELECTED'];
4827 }
4828 if (isset($this->mpdf->selectoption['SELECTED-OTLDATA'])) {
4829 $OTLdata = $this->mpdf->selectoption['SELECTED-OTLDATA'];
4830 }
4831
4832 if ($this->mpdf->useActiveForms) {
4833 $w = $this->mpdf->selectoption['MAXWIDTH'];
4834 } else {
4835 $w = $this->mpdf->GetStringWidth($texto, true, $OTLdata);
4836 }
4837 if ($w == 0) {
4838 $w = 5;
4839 }
4840 $objattr['type'] = 'select';
4841 $objattr['text'] = $texto;
4842 $objattr['OTLdata'] = $OTLdata;
4843 if (isset($this->mpdf->selectoption['NAME'])) {
4844 $objattr['fieldname'] = $this->mpdf->selectoption['NAME'];
4845 }
4846 if (isset($this->mpdf->selectoption['READONLY'])) {
4847 $objattr['readonly'] = true;
4848 }
4849 if (isset($this->mpdf->selectoption['REQUIRED'])) {
4850 $objattr['required'] = true;
4851 }
4852 if (isset($this->mpdf->selectoption['SPELLCHECK'])) {
4853 $objattr['spellcheck'] = true;
4854 }
4855 if (isset($this->mpdf->selectoption['EDITABLE'])) {
4856 $objattr['editable'] = true;
4857 }
4858 if (isset($this->mpdf->selectoption['ONCHANGE'])) {
4859 $objattr['onChange'] = $this->mpdf->selectoption['ONCHANGE'];
4860 }
4861 if (isset($this->mpdf->selectoption['ITEMS'])) {
4862 $objattr['items'] = $this->mpdf->selectoption['ITEMS'];
4863 }
4864 if (isset($this->mpdf->selectoption['MULTIPLE'])) {
4865 $objattr['multiple'] = $this->mpdf->selectoption['MULTIPLE'];
4866 }
4867 if (isset($this->mpdf->selectoption['DISABLED'])) {
4868 $objattr['disabled'] = $this->mpdf->selectoption['DISABLED'];
4869 }
4870 if (isset($this->mpdf->selectoption['TITLE'])) {
4871 $objattr['title'] = $this->mpdf->selectoption['TITLE'];
4872 }
4873 if (isset($this->mpdf->selectoption['COLOR'])) {
4874 $objattr['color'] = $this->mpdf->selectoption['COLOR'];
4875 }
4876 if (isset($this->mpdf->selectoption['SIZE'])) {
4877 $objattr['size'] = $this->mpdf->selectoption['SIZE'];
4878 }
4879 if (isset($objattr['size']) && $objattr['size'] > 1) {
4880 $rows = $objattr['size'];
4881 } else {
4882 $rows = 1;
4883 }
4884
4885 $objattr['fontfamily'] = $this->mpdf->FontFamily;
4886 $objattr['fontsize'] = $this->mpdf->FontSizePt;
4887
4888 $objattr['width'] = $w + ($this->mpdf->mpdfform->form_element_spacing['select']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['select']['inner']['h'] * 2) + ($this->mpdf->FontSize * 1.4);
4889 $objattr['height'] = ($this->mpdf->FontSize * $rows) + ($this->mpdf->mpdfform->form_element_spacing['select']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['select']['inner']['v'] * 2);
4890 $e = "\xbb\xa4\xactype=select,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
4891
4892 // Clear properties - tidy up
4893 $properties = array();
4894
4895 // Output it to buffers
4896 if ($this->mpdf->tableLevel) { // *TABLES*
4897 $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF);
4898 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; // *TABLES*
4899 } // *TABLES*
4900 else { // *TABLES*
4901 $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF);
4902 } // *TABLES*
4903
4904 $this->mpdf->selectoption = array();
4905 $this->mpdf->specialcontent = '';
4906
4907 if ($this->mpdf->InlineProperties[$tag]) {
4908 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]);
4909 }
4910 unset($this->mpdf->InlineProperties[$tag]);
4911 }
4912 /* -- END FORMS -- */
4913
4914
4915 // *********** BLOCKS ********************
4916 // mPDF 6 Lists
4917 if ($tag == 'P' || $tag == 'DIV' || $tag == 'H1' || $tag == 'H2' || $tag == 'H3' || $tag == 'H4' || $tag == 'H5' || $tag == 'H6' || $tag == 'PRE' || $tag == 'FORM' || $tag == 'ADDRESS' || $tag == 'BLOCKQUOTE' || $tag == 'CENTER' || $tag == 'DT' || $tag == 'DD' || $tag == 'DL' || $tag == 'CAPTION' || $tag == 'FIELDSET' || $tag == 'UL' || $tag == 'OL' || $tag == 'LI' || $tag == 'ARTICLE' || $tag == 'ASIDE' || $tag == 'FIGURE' || $tag == 'FIGCAPTION' || $tag == 'FOOTER' || $tag == 'HEADER' || $tag == 'HGROUP' || $tag == 'MAIN' || $tag == 'NAV' || $tag == 'SECTION' || $tag == 'DETAILS' || $tag == 'SUMMARY'
4918 ) {
4919
4920 // mPDF 6 bidi
4921 // Block
4922 // If unicode-bidi set, any embedding levels, isolates, or overrides started by this box are closed
4923 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
4924 $blockpost = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
4925 if ($blockpost) {
4926 $this->mpdf->OTLdata = array();
4927 if ($this->mpdf->tableLevel) {
4928 $this->mpdf->_saveCellTextBuffer($blockpost);
4929 } else {
4930 $this->mpdf->_saveTextBuffer($blockpost);
4931 }
4932 }
4933 }
4934
4935 $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
4936 $this->mpdf->blockjustfinished = true;
4937
4938 $this->mpdf->lastblockbottommargin = $this->mpdf->blk[$this->mpdf->blklvl]['margin_bottom'];
4939 // mPDF 6 Lists
4940 if ($tag == 'UL' || $tag == 'OL') {
4941 if ($this->mpdf->listlvl > 0 && $this->mpdf->tableLevel) {
4942 if (isset($this->mpdf->listtype[$this->mpdf->listlvl]))
4943 unset($this->mpdf->listtype[$this->mpdf->listlvl]);
4944 }
4945 $this->mpdf->listlvl--;
4946 $this->mpdf->listitem = array();
4947 }
4948 if ($tag == 'LI') {
4949 $this->mpdf->listitem = array();
4950 }
4951
4952 if (preg_match('/^H\d/', $tag) && !$this->mpdf->tableLevel && !$this->mpdf->writingToC) {
4953 if (isset($this->mpdf->h2toc[$tag]) || isset($this->mpdf->h2bookmarks[$tag])) {
4954 $content = '';
4955 if (count($this->mpdf->textbuffer) == 1) {
4956 $content = $this->mpdf->textbuffer[0][0];
4957 } else {
4958 for ($i = 0; $i < count($this->mpdf->textbuffer); $i++) {
4959 if (substr($this->mpdf->textbuffer[$i][0], 0, 3) != "\xbb\xa4\xac") { //inline object
4960 $content .= $this->mpdf->textbuffer[$i][0];
4961 }
4962 }
4963 }
4964 /* -- TOC -- */
4965 if (isset($this->mpdf->h2toc[$tag])) {
4966 $objattr = array();
4967 $objattr['type'] = 'toc';
4968 $objattr['toclevel'] = $this->mpdf->h2toc[$tag];
4969 $objattr['CONTENT'] = htmlspecialchars($content);
4970 $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
4971 array_unshift($this->mpdf->textbuffer, array($e));
4972 }
4973 /* -- END TOC -- */
4974 /* -- BOOKMARKS -- */
4975 if (isset($this->mpdf->h2bookmarks[$tag])) {
4976 $objattr = array();
4977 $objattr['type'] = 'bookmark';
4978 $objattr['bklevel'] = $this->mpdf->h2bookmarks[$tag];
4979 $objattr['CONTENT'] = $content;
4980 $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
4981 array_unshift($this->mpdf->textbuffer, array($e));
4982 }
4983 /* -- END BOOKMARKS -- */
4984 }
4985 }
4986
4987 /* -- TABLES -- */
4988 if ($this->mpdf->tableLevel) {
4989 if ($this->mpdf->linebreakjustfinished) {
4990 $this->mpdf->blockjustfinished = false;
4991 }
4992 if (isset($this->mpdf->InlineProperties['BLOCKINTABLE'])) {
4993 if ($this->mpdf->InlineProperties['BLOCKINTABLE']) {
4994 $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties['BLOCKINTABLE']);
4995 }
4996 unset($this->mpdf->InlineProperties['BLOCKINTABLE']);
4997 }
4998 if ($tag == 'PRE') {
4999 $this->mpdf->ispre = false;
5000 }
5001 return;
5002 }
5003 /* -- END TABLES -- */
5004 $this->mpdf->lastoptionaltag = '';
5005 $this->mpdf->divbegin = false;
5006
5007 $this->mpdf->linebreakjustfinished = false;
5008
5009 $this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
5010
5011 /* -- CSS-FLOAT -- */
5012 // If float contained in a float, need to extend bottom to allow for it
5013 $currpos = $this->mpdf->page * 1000 + $this->mpdf->y;
5014 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['float_endpos']) && $this->mpdf->blk[$this->mpdf->blklvl]['float_endpos'] > $currpos) {
5015 $old_page = $this->mpdf->page;
5016 $new_page = intval($this->mpdf->blk[$this->mpdf->blklvl]['float_endpos'] / 1000);
5017 if ($old_page != $new_page) {
5018 $s = $this->mpdf->PrintPageBackgrounds();
5019 // Writes after the marker so not overwritten later by page background etc.
5020 $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
5021 $this->mpdf->pageBackgrounds = array();
5022 $this->mpdf->page = $new_page;
5023 $this->mpdf->ResetMargins();
5024 $this->mpdf->Reset();
5025 $this->mpdf->pageoutput[$this->mpdf->page] = array();
5026 }
5027 $this->mpdf->y = (($this->mpdf->blk[$this->mpdf->blklvl]['float_endpos'] * 1000) % 1000000) / 1000; // mod changes operands to integers before processing
5028 }
5029 /* -- END CSS-FLOAT -- */
5030
5031
5032 //Print content
5033 if ($this->mpdf->lastblocklevelchange == 1) {
5034 $blockstate = 3;
5035 } // Top & bottom margins/padding
5036 else if ($this->mpdf->lastblocklevelchange == -1) {
5037 $blockstate = 2;
5038 } // Bottom margins/padding only
5039 else {
5040 $blockstate = 0;
5041 }
5042 // called from after e.g. </table> </div> </div> ... Outputs block margin/border and padding
5043 if (count($this->mpdf->textbuffer) && $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1]) {
5044 if (substr($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], 0, 3) != "\xbb\xa4\xac") { // not special content
5045 // Right trim last content and adjust OTLdata
5046 if (preg_match('/[ ]+$/', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], $m)) {
5047 $strip = strlen($m[0]);
5048 $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0] = substr($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], 0, (strlen($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0]) - $strip));
5049 /* -- OTL -- */
5050 if (isset($this->mpdf->CurrentFont['useOTL']) && $this->mpdf->CurrentFont['useOTL']) {
5051 $this->mpdf->otl->trimOTLdata($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18], false, true); // mPDF 6 ZZZ99K
5052 }
5053 /* -- END OTL -- */
5054 }
5055 }
5056 }
5057
5058 if (count($this->mpdf->textbuffer) == 0 && $this->mpdf->lastblocklevelchange != 0) {
5059 //$this->mpdf->newFlowingBlock( $this->mpdf->blk[$this->mpdf->blklvl]['width'],$this->mpdf->lineheight,'',false,2,true, (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction']) ? $this->mpdf->blk[$this->mpdf->blklvl]['direction'] : 'ltr'));
5060 $this->mpdf->newFlowingBlock($this->mpdf->blk[$this->mpdf->blklvl]['width'], $this->mpdf->lineheight, '', false, $blockstate, true, (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction']) ? $this->mpdf->blk[$this->mpdf->blklvl]['direction'] : 'ltr'));
5061 $this->mpdf->finishFlowingBlock(true); // true = END of flowing block
5062 $this->mpdf->PaintDivBB('', $blockstate);
5063 } else {
5064 $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
5065 }
5066
5067
5068 $this->mpdf->textbuffer = array();
5069
5070 if ($this->mpdf->kwt) {
5071 $this->mpdf->kwt_height = $this->mpdf->y - $this->mpdf->kwt_y0;
5072 }
5073
5074 /* -- CSS-IMAGE-FLOAT -- */
5075 $this->mpdf->printfloatbuffer();
5076 /* -- END CSS-IMAGE-FLOAT -- */
5077
5078 if ($tag == 'PRE') {
5079 $this->mpdf->ispre = false;
5080 }
5081
5082 /* -- CSS-FLOAT -- */
5083 if ($this->mpdf->blk[$this->mpdf->blklvl]['float'] == 'R') {
5084 // If width not set, here would need to adjust and output buffer
5085 $s = $this->mpdf->PrintPageBackgrounds();
5086 // Writes after the marker so not overwritten later by page background etc.
5087 $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
5088 $this->mpdf->pageBackgrounds = array();
5089 $this->mpdf->Reset();
5090 $this->mpdf->pageoutput[$this->mpdf->page] = array();
5091
5092 for ($i = ($this->mpdf->blklvl - 1); $i >= 0; $i--) {
5093 if (isset($this->mpdf->blk[$i]['float_endpos'])) {
5094 $this->mpdf->blk[$i]['float_endpos'] = max($this->mpdf->blk[$i]['float_endpos'], ($this->mpdf->page * 1000 + $this->mpdf->y));
5095 } else {
5096 $this->mpdf->blk[$i]['float_endpos'] = $this->mpdf->page * 1000 + $this->mpdf->y;
5097 }
5098 }
5099
5100 $this->mpdf->floatDivs[] = array(
5101 'side' => 'R',
5102 'startpage' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'],
5103 'y0' => $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
5104 'startpos' => ($this->mpdf->blk[$this->mpdf->blklvl]['startpage'] * 1000 + $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y']),
5105 'endpage' => $this->mpdf->page,
5106 'y1' => $this->mpdf->y,
5107 'endpos' => ($this->mpdf->page * 1000 + $this->mpdf->y),
5108 'w' => $this->mpdf->blk[$this->mpdf->blklvl]['float_width'],
5109 'blklvl' => $this->mpdf->blklvl,
5110 'blockContext' => $this->mpdf->blk[$this->mpdf->blklvl - 1]['blockContext']
5111 );
5112
5113 $this->mpdf->y = $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'];
5114 $this->mpdf->page = $this->mpdf->blk[$this->mpdf->blklvl]['startpage'];
5115 $this->mpdf->ResetMargins();
5116 $this->mpdf->pageoutput[$this->mpdf->page] = array();
5117 }
5118 if ($this->mpdf->blk[$this->mpdf->blklvl]['float'] == 'L') {
5119 // If width not set, here would need to adjust and output buffer
5120 $s = $this->mpdf->PrintPageBackgrounds();
5121 // Writes after the marker so not overwritten later by page background etc.
5122 $this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
5123 $this->mpdf->pageBackgrounds = array();
5124 $this->mpdf->Reset();
5125 $this->mpdf->pageoutput[$this->mpdf->page] = array();
5126
5127 for ($i = ($this->mpdf->blklvl - 1); $i >= 0; $i--) {
5128 if (isset($this->mpdf->blk[$i]['float_endpos'])) {
5129 $this->mpdf->blk[$i]['float_endpos'] = max($this->mpdf->blk[$i]['float_endpos'], ($this->mpdf->page * 1000 + $this->mpdf->y));
5130 } else {
5131 $this->mpdf->blk[$i]['float_endpos'] = $this->mpdf->page * 1000 + $this->mpdf->y;
5132 }
5133 }
5134
5135 $this->mpdf->floatDivs[] = array(
5136 'side' => 'L',
5137 'startpage' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'],
5138 'y0' => $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
5139 'startpos' => ($this->mpdf->blk[$this->mpdf->blklvl]['startpage'] * 1000 + $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y']),
5140 'endpage' => $this->mpdf->page,
5141 'y1' => $this->mpdf->y,
5142 'endpos' => ($this->mpdf->page * 1000 + $this->mpdf->y),
5143 'w' => $this->mpdf->blk[$this->mpdf->blklvl]['float_width'],
5144 'blklvl' => $this->mpdf->blklvl,
5145 'blockContext' => $this->mpdf->blk[$this->mpdf->blklvl - 1]['blockContext']
5146 );
5147
5148 $this->mpdf->y = $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'];
5149 $this->mpdf->page = $this->mpdf->blk[$this->mpdf->blklvl]['startpage'];
5150 $this->mpdf->ResetMargins();
5151 $this->mpdf->pageoutput[$this->mpdf->page] = array();
5152 }
5153 /* -- END CSS-FLOAT -- */
5154
5155 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['visibility']) && $this->mpdf->blk[$this->mpdf->blklvl]['visibility'] != 'visible') {
5156 $this->mpdf->SetVisibility('visible');
5157 }
5158
5159 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['page_break_after'])) {
5160 $page_break_after = $this->mpdf->blk[$this->mpdf->blklvl]['page_break_after'];
5161 } else {
5162 $page_break_after = '';
5163 }
5164
5165 //Reset values
5166 $this->mpdf->Reset();
5167
5168 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['z-index']) && $this->mpdf->blk[$this->mpdf->blklvl]['z-index'] > 0) {
5169 $this->mpdf->EndLayer();
5170 }
5171
5172 // mPDF 6 page-break-inside:avoid
5173 if ($this->mpdf->blk[$this->mpdf->blklvl]['keep_block_together']) {
5174 $movepage = false;
5175 // If page-break-inside:avoid section has broken to new page but fits on one side - then move:
5176 if (($this->mpdf->page - $this->mpdf->kt_p00) == 1 && $this->mpdf->y < $this->mpdf->kt_y00) {
5177 $movepage = true;
5178 }
5179 if (($this->mpdf->page - $this->mpdf->kt_p00) > 0) {
5180 for ($i = $this->mpdf->page; $i > $this->mpdf->kt_p00; $i--) {
5181 unset($this->mpdf->pages[$i]);
5182 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bb_painted'][$i])) {
5183 unset($this->mpdf->blk[$this->mpdf->blklvl]['bb_painted'][$i]);
5184 }
5185 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['marginCorrected'][$i])) {
5186 unset($this->mpdf->blk[$this->mpdf->blklvl]['marginCorrected'][$i]);
5187 }
5188 if (isset($this->mpdf->pageoutput[$i])) {
5189 unset($this->mpdf->pageoutput[$i]);
5190 }
5191 }
5192 $this->mpdf->page = $this->mpdf->kt_p00;
5193 }
5194 $this->mpdf->keep_block_together = 0;
5195 $this->mpdf->pageoutput[$this->mpdf->page] = array();
5196
5197 $this->mpdf->y = $this->mpdf->kt_y00;
5198 $ihtml = $this->mpdf->blk[$this->mpdf->blklvl]['array_i'] - 1;
5199
5200 $ahtml[$ihtml + 1] .= ' pagebreakavoidchecked="true";'; // avoid re-iterating; read in OpenTag()
5201
5202 unset($this->mpdf->blk[$this->mpdf->blklvl]);
5203 $this->mpdf->blklvl--;
5204
5205 for ($blklvl = 1; $blklvl <= $this->mpdf->blklvl; $blklvl++) {
5206 $this->mpdf->blk[$blklvl]['y0'] = $this->mpdf->blk[$blklvl]['initial_y0'];
5207 $this->mpdf->blk[$blklvl]['x0'] = $this->mpdf->blk[$blklvl]['initial_x0'];
5208 $this->mpdf->blk[$blklvl]['startpage'] = $this->mpdf->blk[$blklvl]['initial_startpage'];
5209 }
5210
5211 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['x0'])) {
5212 $this->mpdf->x = $this->mpdf->blk[$this->mpdf->blklvl]['x0'];
5213 } else {
5214 $this->mpdf->x = $this->mpdf->lMargin;
5215 }
5216
5217 $this->mpdf->lastblocklevelchange = 0;
5218 $this->mpdf->ResetMargins();
5219 if ($movepage) {
5220 $this->mpdf->AddPage();
5221 }
5222 return;
5223 }
5224
5225 if ($this->mpdf->blklvl > 0) { // ==0 SHOULDN'T HAPPEN - NOT XHTML
5226 if ($this->mpdf->blk[$this->mpdf->blklvl]['tag'] == $tag) {
5227 unset($this->mpdf->blk[$this->mpdf->blklvl]);
5228 $this->mpdf->blklvl--;
5229 }
5230 //else { echo $tag; exit; } // debug - forces error if incorrectly nested html tags
5231 }
5232
5233 $this->mpdf->lastblocklevelchange = -1;
5234 // Reset Inline-type properties
5235 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties'])) {
5236 $this->mpdf->restoreInlineProperties($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties']);
5237 }
5238
5239 $this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
5240
5241 if (!$this->mpdf->tableLevel && $page_break_after) {
5242 $save_blklvl = $this->mpdf->blklvl;
5243 $save_blk = $this->mpdf->blk;
5244 $save_silp = $this->mpdf->saveInlineProperties();
5245 $save_ilp = $this->mpdf->InlineProperties;
5246 $save_bflp = $this->mpdf->InlineBDF;
5247 $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
5248 // mPDF 6 pagebreaktype
5249 $startpage = $this->mpdf->page;
5250 $pagebreaktype = $this->mpdf->defaultPagebreakType;
5251 if ($this->mpdf->ColActive) {
5252 $pagebreaktype = 'cloneall';
5253 }
5254
5255 // mPDF 6 pagebreaktype
5256 $this->mpdf->_preForcedPagebreak($pagebreaktype);
5257
5258 if ($page_break_after == 'RIGHT') {
5259 $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
5260 } else if ($page_break_after == 'LEFT') {
5261 $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
5262 } else {
5263 $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
5264 }
5265
5266 // mPDF 6 pagebreaktype
5267 $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
5268
5269 $this->mpdf->InlineProperties = $save_ilp;
5270 $this->mpdf->InlineBDF = $save_bflp;
5271 $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
5272 $this->mpdf->restoreInlineProperties($save_silp);
5273 }
5274 // mPDF 6 bidi
5275 // Block
5276 // If unicode-bidi set, any embedding levels, isolates, or overrides reopened in the continuing block
5277 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
5278 $blockpre = $this->mpdf->_setBidiCodes('start', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
5279 if ($blockpre) {
5280 $this->mpdf->OTLdata = array();
5281 if ($this->mpdf->tableLevel) {
5282 $this->mpdf->_saveCellTextBuffer($blockpre);
5283 } else {
5284 $this->mpdf->_saveTextBuffer($blockpre);
5285 }
5286 }
5287 }
5288 }
5289
5290
5291 /* -- TABLES -- */
5292
5293 if ($tag == 'TH')
5294 $this->mpdf->SetStyle('B', false);
5295
5296 if (($tag == 'TH' or $tag == 'TD') && $this->mpdf->tableLevel) {
5297 $this->mpdf->lastoptionaltag = 'TR';
5298 unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
5299 $this->mpdf->cssmgr->tbCSSlvl--;
5300 if (!$this->mpdf->tdbegin) {
5301 return;
5302 }
5303 $this->mpdf->tdbegin = false;
5304 // Added for correct calculation of cell column width - otherwise misses the last line if not end </p> etc.
5305 if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
5306 if (!is_array($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col])) {
5307 throw new MpdfException("You may have an error in your HTML code e.g. &lt;/td&gt;&lt;/td&gt;");
5308 }
5309 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
5310 } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
5311 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
5312 }
5313
5314 // Remove last <br> if at end of cell
5315 if (isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'])) {
5316 $ntb = count($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer']);
5317 } else {
5318 $ntb = 0;
5319 }
5320 if ($ntb > 1 && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][$ntb - 1][0] == "\n") {
5321 unset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][$ntb - 1]);
5322 }
5323
5324 if ($this->mpdf->tablethead) {
5325 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_thead'][$this->mpdf->row] = true;
5326 if ($this->mpdf->tableLevel == 1) {
5327 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows'] = max($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows'], ($this->mpdf->row + 1));
5328 }
5329 }
5330 if ($this->mpdf->tabletfoot) {
5331 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$this->mpdf->row] = true;
5332 if ($this->mpdf->tableLevel == 1) {
5333 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows'] = max($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['footernrows'], ($this->mpdf->row + 1 - $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['headernrows']));
5334 }
5335 }
5336 $this->mpdf->Reset();
5337 }
5338
5339 if ($tag == 'TR' && $this->mpdf->tableLevel) {
5340 // If Border set on TR - Update right border
5341 if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-left'][$this->mpdf->row])) {
5342 $c = & $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col];
5343 if ($c) {
5344 if ($this->mpdf->packTableData) {
5345 $cell = $this->mpdf->_unpackCellBorder($c['borderbin']);
5346 } else {
5347 $cell = $c;
5348 }
5349 $cell['border_details']['R'] = $this->mpdf->border_details($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trborder-right'][$this->mpdf->row]);
5350 $this->mpdf->setBorder($cell['border'], _BORDER_RIGHT, $cell['border_details']['R']['s']);
5351 if ($this->mpdf->packTableData) {
5352 $c['borderbin'] = $this->mpdf->_packCellBorder($cell);
5353 unset($c['border']);
5354 unset($c['border_details']);
5355 } else {
5356 $c = $cell;
5357 }
5358 }
5359 }
5360 $this->mpdf->lastoptionaltag = '';
5361 unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
5362 $this->mpdf->cssmgr->tbCSSlvl--;
5363 $this->mpdf->trow_text_rotate = '';
5364 $this->mpdf->tabletheadjustfinished = false;
5365 }
5366
5367 if ($tag == 'TBODY') {
5368 $this->mpdf->lastoptionaltag = '';
5369 unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
5370 $this->mpdf->cssmgr->tbCSSlvl--;
5371 }
5372
5373 if ($tag == 'THEAD') {
5374 $this->mpdf->lastoptionaltag = '';
5375 unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
5376 $this->mpdf->cssmgr->tbCSSlvl--;
5377 $this->mpdf->tablethead = 0;
5378 $this->mpdf->tabletheadjustfinished = true;
5379 $this->mpdf->ResetStyles();
5380 $this->mpdf->thead_font_weight = '';
5381 $this->mpdf->thead_font_style = '';
5382 $this->mpdf->thead_font_smCaps = '';
5383
5384 $this->mpdf->thead_valign_default = '';
5385 $this->mpdf->thead_textalign_default = '';
5386 }
5387
5388 if ($tag == 'TFOOT') {
5389 $this->mpdf->lastoptionaltag = '';
5390 unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
5391 $this->mpdf->cssmgr->tbCSSlvl--;
5392 $this->mpdf->tabletfoot = 0;
5393 $this->mpdf->ResetStyles();
5394 $this->mpdf->tfoot_font_weight = '';
5395 $this->mpdf->tfoot_font_style = '';
5396 $this->mpdf->tfoot_font_smCaps = '';
5397
5398 $this->mpdf->tfoot_valign_default = '';
5399 $this->mpdf->tfoot_textalign_default = '';
5400 }
5401
5402 if ($tag == 'TABLE') { // TABLE-END (
5403 if ($this->mpdf->progressBar) {
5404 $this->mpdf->UpdateProgressBar(1, '', 'TABLE');
5405 } // *PROGRESS-BAR*
5406 if ($this->mpdf->progressBar) {
5407 $this->mpdf->UpdateProgressBar(7, 0, '');
5408 } // *PROGRESS-BAR*
5409 $this->mpdf->lastoptionaltag = '';
5410 unset($this->mpdf->cssmgr->tablecascadeCSS[$this->mpdf->cssmgr->tbCSSlvl]);
5411 $this->mpdf->cssmgr->tbCSSlvl--;
5412 $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
5413 // mPDF 5.7.3
5414 // In case a colspan (on a row after first row) exceeded number of columns in table
5415 for ($k = 0; $k < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr']; $k++) {
5416 for ($l = 0; $l < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc']; $l++) {
5417 if (!isset($this->mpdf->cell[$k][$l])) {
5418 for ($n = $l - 1; $n >= 0; $n--) {
5419 if (isset($this->mpdf->cell[$k][$n]) && $this->mpdf->cell[$k][$n] != 0) {
5420 break;
5421 }
5422 }
5423 $this->mpdf->cell[$k][$l] = array(
5424 'a' => 'C',
5425 'va' => 'M',
5426 'R' => false,
5427 'nowrap' => false,
5428 'bgcolor' => false,
5429 'padding' => array('L' => false, 'R' => false, 'T' => false, 'B' => false),
5430 'gradient' => false,
5431 's' => 0,
5432 'maxs' => 0,
5433 'textbuffer' => array(),
5434 'dfs' => $this->mpdf->FontSize,
5435 );
5436
5437 if (!$this->mpdf->simpleTables) {
5438 $this->mpdf->cell[$k][$l]['border'] = 0;
5439 $this->mpdf->cell[$k][$l]['border_details']['R'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
5440 $this->mpdf->cell[$k][$l]['border_details']['L'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
5441 $this->mpdf->cell[$k][$l]['border_details']['T'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
5442 $this->mpdf->cell[$k][$l]['border_details']['B'] = array('s' => 0, 'w' => 0, 'c' => false, 'style' => 'none', 'dom' => 0);
5443 $this->mpdf->cell[$k][$l]['border_details']['mbw'] = array('BL' => 0, 'BR' => 0, 'RT' => 0, 'RB' => 0, 'TL' => 0, 'TR' => 0, 'LT' => 0, 'LB' => 0);
5444 if ($this->mpdf->packTableData) {
5445 $this->mpdf->cell[$k][$l]['borderbin'] = $this->mpdf->_packCellBorder($this->mpdf->cell[$k][$l]);
5446 unset($this->mpdf->cell[$k][$l]['border']);
5447 unset($this->mpdf->cell[$k][$l]['border_details']);
5448 }
5449 }
5450 }
5451 }
5452 }
5453 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] = $this->mpdf->cell;
5454 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['wc'] = array_pad(array(), $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nc'], array('miw' => 0, 'maw' => 0));
5455 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['hr'] = array_pad(array(), $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr'], 0);
5456
5457 // Move table footer <tfoot> row to end of table
5458 if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot']) && count($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'])) {
5459 $tfrows = array();
5460 foreach ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] AS $r => $val) {
5461 if ($val) {
5462 $tfrows[] = $r;
5463 }
5464 }
5465 $temp = array();
5466 $temptf = array();
5467 foreach ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] AS $k => $row) {
5468 if (in_array($k, $tfrows)) {
5469 $temptf[] = $row;
5470 } else {
5471 $temp[] = $row;
5472 }
5473 }
5474 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'] = array();
5475 for ($i = count($temp); $i < (count($temp) + count($temptf)); $i++) {
5476 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['is_tfoot'][$i] = true;
5477 }
5478 // Update nestedpos row references
5479 if (isset($this->mpdf->table[($this->mpdf->tableLevel + 1)]) && count($this->mpdf->table[($this->mpdf->tableLevel + 1)])) {
5480 foreach ($this->mpdf->table[($this->mpdf->tableLevel + 1)] AS $nid => $nested) {
5481 $this->mpdf->table[($this->mpdf->tableLevel + 1)][$nid]['nestedpos'][0] -= count($temptf);
5482 }
5483 }
5484 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'] = array_merge($temp, $temptf);
5485
5486 // Update other arays set on row number
5487 // [trbackground-images] [trgradients]
5488 $temptrbgi = array();
5489 $temptrbgg = array();
5490 $temptrbgc = array();
5491 if (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][-1])) {
5492 $temptrbgc[-1] = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][-1];
5493 }
5494 for ($k = 0; $k < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr']; $k++) {
5495 if (!in_array($k, $tfrows)) {
5496 $temptrbgi[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k] : null);
5497 $temptrbgg[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k] : null);
5498 $temptrbgc[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k] : null);
5499 }
5500 }
5501 for ($k = 0; $k < $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['nr']; $k++) {
5502 if (in_array($k, $tfrows)) {
5503 $temptrbgi[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'][$k] : null);
5504 $temptrbgg[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'][$k] : null);
5505 $temptrbgc[] = (isset($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k]) ? $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'][$k] : null);
5506 }
5507 }
5508 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trbackground-images'] = $temptrbgi;
5509 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['trgradients'] = $temptrbgg;
5510 $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['bgcolor'] = $temptrbgc;
5511 // Should Update all other arays set on row number, but cell properties have been set so not needed
5512 // [bgcolor] [trborder-left] [trborder-right] [trborder-top] [trborder-bottom]
5513 }
5514
5515 if ($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['direction'] == 'rtl') {
5516 $this->mpdf->_reverseTableDir($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]);
5517 }
5518
5519 // Fix Borders *********************************************
5520 $this->mpdf->_fixTableBorders($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]);
5521
5522 if ($this->mpdf->progressBar) {
5523 $this->mpdf->UpdateProgressBar(7, 10, ' ');
5524 } // *PROGRESS-BAR*
5525
5526 if ($this->mpdf->ColActive) {
5527 $this->mpdf->table_rotate = 0;
5528 } // *COLUMNS*
5529 if ($this->mpdf->table_rotate <> 0) {
5530 $this->mpdf->tablebuffer = '';
5531 // Max width for rotated table
5532 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 1);
5533 $this->mpdf->tbrot_maxh = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']; // Max width for rotated table
5534 $this->mpdf->tbrot_align = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['a'];
5535 }
5536 $this->mpdf->shrin_k = 1;
5537
5538 if ($this->mpdf->shrink_tables_to_fit < 1) {
5539 $this->mpdf->shrink_tables_to_fit = 1;
5540 }
5541 if (!$this->mpdf->shrink_this_table_to_fit) {
5542 $this->mpdf->shrink_this_table_to_fit = $this->mpdf->shrink_tables_to_fit;
5543 }
5544
5545 if ($this->mpdf->tableLevel > 1) {
5546 // deal with nested table
5547
5548 $this->mpdf->_tableColumnWidth($this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]], true);
5549
5550 $tmiw = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['miw'];
5551 $tmaw = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['maw'];
5552 $tl = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['tl'];
5553
5554 // Go down to lower table level
5555 $this->mpdf->tableLevel--;
5556
5557 // Reset lower level table
5558 $this->mpdf->base_table_properties = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['baseProperties'];
5559 // mPDF 5.7.3
5560 $this->mpdf->default_font = $this->mpdf->base_table_properties['FONT-FAMILY'];
5561 $this->mpdf->SetFont($this->mpdf->default_font, '', 0, false);
5562 $this->mpdf->default_font_size = $this->mpdf->ConvertSize($this->mpdf->base_table_properties['FONT-SIZE']) * (_MPDFK);
5563 $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
5564
5565 $this->mpdf->cell = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['cells'];
5566 if (isset($this->mpdf->cell['PARENTCELL'])) {
5567 if ($this->mpdf->cell['PARENTCELL']) {
5568 $this->mpdf->restoreInlineProperties($this->mpdf->cell['PARENTCELL']);
5569 }
5570 unset($this->mpdf->cell['PARENTCELL']);
5571 }
5572 $this->mpdf->row = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currrow'];
5573 $this->mpdf->col = $this->mpdf->table[$this->mpdf->tableLevel][$this->mpdf->tbctr[$this->mpdf->tableLevel]]['currcol'];
5574 $objattr = array();
5575 $objattr['type'] = 'nestedtable';
5576 $objattr['nestedcontent'] = $this->mpdf->tbctr[($this->mpdf->tableLevel + 1)];
5577 $objattr['table'] = $this->mpdf->tbctr[$this->mpdf->tableLevel];
5578 $objattr['row'] = $this->mpdf->row;
5579 $objattr['col'] = $this->mpdf->col;
5580 $objattr['level'] = $this->mpdf->tableLevel;
5581 $e = "\xbb\xa4\xactype=nestedtable,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
5582 $this->mpdf->_saveCellTextBuffer($e);
5583 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $tl;
5584 if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) {
5585 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
5586 } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) {
5587 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'];
5588 }
5589 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset
5590 if ((isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw']) && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw'] < $tmaw) || !isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw'])) {
5591 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmaw'] = $tmaw;
5592 }
5593 if ((isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw']) && $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw'] < $tmiw) || !isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw'])) {
5594 $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['nestedmiw'] = $tmiw;
5595 }
5596 $this->mpdf->tdbegin = true;
5597 $this->mpdf->nestedtablejustfinished = true;
5598 $this->mpdf->ignorefollowingspaces = true;
5599 return;
5600 }
5601 $this->mpdf->cMarginL = 0;
5602 $this->mpdf->cMarginR = 0;
5603 $this->mpdf->cMarginT = 0;
5604 $this->mpdf->cMarginB = 0;
5605 $this->mpdf->cellPaddingL = 0;
5606 $this->mpdf->cellPaddingR = 0;
5607 $this->mpdf->cellPaddingT = 0;
5608 $this->mpdf->cellPaddingB = 0;
5609
5610 if (isset($this->mpdf->table[1][1]['overflow']) && $this->mpdf->table[1][1]['overflow'] == 'visible') {
5611 if ($this->mpdf->kwt || $this->mpdf->table_rotate || $this->mpdf->table_keep_together || $this->mpdf->ColActive) {
5612 $this->mpdf->kwt = false;
5613 $this->mpdf->table_rotate = 0;
5614 $this->mpdf->table_keep_together = false;
5615 //throw new MpdfException("mPDF Warning: You cannot use CSS overflow:visible together with any of these functions: 'Keep-with-table', rotated tables, page-break-inside:avoid, or columns");
5616 }
5617 $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], true);
5618 $this->mpdf->_tableWidth($this->mpdf->table[1][1]);
5619 } else {
5620 if (!$this->mpdf->kwt_saved) {
5621 $this->mpdf->kwt_height = 0;
5622 }
5623
5624 list($check, $tablemiw) = $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], true);
5625 $save_table = $this->mpdf->table;
5626 $reset_to_minimum_width = false;
5627 $added_page = false;
5628
5629 if ($check > 1) {
5630 if ($check > $this->mpdf->shrink_this_table_to_fit && $this->mpdf->table_rotate) {
5631 if ($this->mpdf->y != $this->mpdf->tMargin) {
5632 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5633 $this->mpdf->kwt_moved = true;
5634 }
5635 $added_page = true;
5636 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5637 //$check = $tablemiw/$this->mpdf->tbrot_maxw; // undo any shrink
5638 $check = 1; // undo any shrink
5639 }
5640 $reset_to_minimum_width = true;
5641 }
5642
5643 if ($reset_to_minimum_width) {
5644 $this->mpdf->shrin_k = $check;
5645
5646 $this->mpdf->default_font_size /= $this->mpdf->shrin_k;
5647 $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
5648
5649 $this->mpdf->shrinkTable($this->mpdf->table[1][1], $this->mpdf->shrin_k);
5650
5651 $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], false); // repeat
5652 // Starting at $this->mpdf->innermostTableLevel
5653 // Shrink table values - and redo columnWidth
5654 for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
5655 for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
5656 $this->mpdf->shrinkTable($this->mpdf->table[$lvl][$nid], $this->mpdf->shrin_k);
5657 $this->mpdf->_tableColumnWidth($this->mpdf->table[$lvl][$nid], false);
5658 }
5659 }
5660 }
5661
5662 // Set table cell widths for top level table
5663 // Use $shrin_k to resize but don't change again
5664 $this->mpdf->SetLineHeight('', $this->mpdf->table[1][1]['cellLineHeight']);
5665
5666 // Top level table
5667 $this->mpdf->_tableWidth($this->mpdf->table[1][1]);
5668 }
5669
5670 // Now work through any nested tables setting child table[w'] = parent cell['w']
5671 // Now do nested tables _tableWidth
5672 for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
5673 for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
5674 // HERE set child table width = cell width
5675
5676 list($parentrow, $parentcol, $parentnid) = $this->mpdf->table[$lvl][$nid]['nestedpos'];
5677
5678 $c = & $this->mpdf->table[($lvl - 1)][$parentnid]['cells'][$parentrow][$parentcol];
5679
5680 if (isset($c['colspan']) && $c['colspan'] > 1) {
5681 $parentwidth = 0;
5682 for ($cs = 0; $cs < $c['colspan']; $cs++) {
5683 $parentwidth += $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol + $cs];
5684 }
5685 } else {
5686 $parentwidth = $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol];
5687 }
5688
5689
5690 //$parentwidth -= ALLOW FOR PADDING ETC.in parent cell
5691 if (!$this->mpdf->simpleTables) {
5692 if ($this->mpdf->packTableData) {
5693 list($bt, $br, $bb, $bl) = $this->mpdf->_getBorderWidths($c['borderbin']);
5694 } else {
5695 $br = $c['border_details']['R']['w'];
5696 $bl = $c['border_details']['L']['w'];
5697 }
5698 if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
5699 $parentwidth -= $br + $bl + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
5700 } else {
5701 $parentwidth -= $br / 2 + $bl / 2 + $c['padding']['L'] + $c['padding']['R'];
5702 }
5703 } else if ($this->mpdf->simpleTables) {
5704 if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
5705 $parentwidth -= $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w'] + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
5706 } else {
5707 $parentwidth -= $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] / 2 + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w'] / 2 + $c['padding']['L'] + $c['padding']['R'];
5708 }
5709 }
5710 if (isset($this->mpdf->table[$lvl][$nid]['wpercent']) && $this->mpdf->table[$lvl][$nid]['wpercent'] && $lvl > 1) {
5711 $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
5712 } else if ($parentwidth > $this->mpdf->table[$lvl][$nid]['maw']) {
5713 $this->mpdf->table[$lvl][$nid]['w'] = $this->mpdf->table[$lvl][$nid]['maw'];
5714 } else {
5715 $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
5716 }
5717 unset($c);
5718 $this->mpdf->_tableWidth($this->mpdf->table[$lvl][$nid]);
5719 }
5720 }
5721
5722 // Starting at $this->mpdf->innermostTableLevel
5723 // Cascade back up nested tables: setting heights back up the tree
5724 for ($lvl = $this->mpdf->innermostTableLevel; $lvl > 0; $lvl--) {
5725 for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
5726 list($tableheight, $maxrowheight, $fullpage, $remainingpage, $maxfirstrowheight) = $this->mpdf->_tableHeight($this->mpdf->table[$lvl][$nid]);
5727 }
5728 }
5729 if ($this->mpdf->progressBar) {
5730 $this->mpdf->UpdateProgressBar(7, 20, ' ');
5731 } // *PROGRESS-BAR*
5732 if ($this->mpdf->table[1][1]['overflow'] == 'visible') {
5733 if ($maxrowheight > $fullpage) {
5734 throw new MpdfException("mPDF Warning: A Table row is greater than available height. You cannot use CSS overflow:visible");
5735 }
5736 if ($maxfirstrowheight > $remainingpage) {
5737 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5738 }
5739 $r = 0;
5740 $c = 0;
5741 $p = 0;
5742 $y = 0;
5743 $finished = false;
5744 while (!$finished) {
5745 list($finished, $r, $c, $p, $y, $y0) = $this->mpdf->_tableWrite($this->mpdf->table[1][1], true, $r, $c, $p, $y);
5746 if (!$finished) {
5747 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5748 // If printed something on first spread, set same y
5749 if ($r == 0 && $y0 > -1) {
5750 $this->mpdf->y = $y0;
5751 }
5752 }
5753 }
5754 } else {
5755 $recalculate = 1;
5756 $forcerecalc = false;
5757 // RESIZING ALGORITHM
5758 if ($maxrowheight > $fullpage) {
5759 $recalculate = $this->mpdf->tbsqrt($maxrowheight / $fullpage, 1);
5760 $forcerecalc = true;
5761 } else if ($this->mpdf->table_rotate) { // NB $remainingpage == $fullpage == the width of the page
5762 if ($tableheight > $remainingpage) {
5763 // If can fit on remainder of page whilst respecting autsize value..
5764 if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, 1)) <= $this->mpdf->shrink_this_table_to_fit) {
5765 $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, 1);
5766 } else if (!$added_page) {
5767 if ($this->mpdf->y != $this->mpdf->tMargin) {
5768 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5769 $this->mpdf->kwt_moved = true;
5770 }
5771 $added_page = true;
5772 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5773 // 0.001 to force it to recalculate
5774 $recalculate = (1 / $this->mpdf->shrin_k) + 0.001; // undo any shrink
5775 }
5776 } else {
5777 $recalculate = 1;
5778 }
5779 } else if ($this->mpdf->table_keep_together || ($this->mpdf->table[1][1]['nr'] == 1 && !$this->mpdf->writingHTMLfooter)) {
5780 if ($tableheight > $fullpage) {
5781 if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $fullpage, 1)) <= $this->mpdf->shrink_this_table_to_fit) {
5782 $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, 1);
5783 } else if ($this->mpdf->tableMinSizePriority) {
5784 $this->mpdf->table_keep_together = false;
5785 $recalculate = 1.001;
5786 } else {
5787 if ($this->mpdf->y != $this->mpdf->tMargin) {
5788 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5789 $this->mpdf->kwt_moved = true;
5790 }
5791 $added_page = true;
5792 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5793 $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, 1);
5794 }
5795 } else if ($tableheight > $remainingpage) {
5796 // If can fit on remainder of page whilst respecting autsize value..
5797 if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, 1)) <= $this->mpdf->shrink_this_table_to_fit) {
5798 $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, 1);
5799 } else {
5800 if ($this->mpdf->y != $this->mpdf->tMargin) {
5801 // mPDF 6
5802 if ($this->mpdf->AcceptPageBreak()) {
5803 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5804 } else if ($this->mpdf->ColActive && $tableheight > (($this->mpdf->h - $this->mpdf->bMargin) - $this->mpdf->y0)) {
5805 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5806 }
5807 $this->mpdf->kwt_moved = true;
5808 }
5809 $added_page = true;
5810 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5811 $recalculate = 1.001;
5812 }
5813 } else {
5814 $recalculate = 1;
5815 }
5816 } else {
5817 $recalculate = 1;
5818 }
5819
5820 if ($recalculate > $this->mpdf->shrink_this_table_to_fit && !$forcerecalc) {
5821 $recalculate = $this->mpdf->shrink_this_table_to_fit;
5822 }
5823
5824 $iteration = 1;
5825
5826 // RECALCULATE
5827 while ($recalculate <> 1) {
5828 $this->mpdf->shrin_k1 = $recalculate;
5829 $this->mpdf->shrin_k *= $recalculate;
5830 $this->mpdf->default_font_size /= ($this->mpdf->shrin_k1);
5831 $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
5832 $this->mpdf->SetLineHeight('', $this->mpdf->table[1][1]['cellLineHeight']);
5833 $this->mpdf->table = $save_table;
5834 if ($this->mpdf->shrin_k <> 1) {
5835 $this->mpdf->shrinkTable($this->mpdf->table[1][1], $this->mpdf->shrin_k);
5836 }
5837 $this->mpdf->_tableColumnWidth($this->mpdf->table[1][1], false); // repeat
5838 // Starting at $this->mpdf->innermostTableLevel
5839 // Shrink table values - and redo columnWidth
5840 for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
5841 for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
5842 if ($this->mpdf->shrin_k <> 1) {
5843 $this->mpdf->shrinkTable($this->mpdf->table[$lvl][$nid], $this->mpdf->shrin_k);
5844 }
5845 $this->mpdf->_tableColumnWidth($this->mpdf->table[$lvl][$nid], false);
5846 }
5847 }
5848 // Set table cell widths for top level table
5849 // Top level table
5850 $this->mpdf->_tableWidth($this->mpdf->table[1][1]);
5851
5852 // Now work through any nested tables setting child table[w'] = parent cell['w']
5853 // Now do nested tables _tableWidth
5854 for ($lvl = 2; $lvl <= $this->mpdf->innermostTableLevel; $lvl++) {
5855 for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
5856 // HERE set child table width = cell width
5857
5858 list($parentrow, $parentcol, $parentnid) = $this->mpdf->table[$lvl][$nid]['nestedpos'];
5859 $c = & $this->mpdf->table[($lvl - 1)][$parentnid]['cells'][$parentrow][$parentcol];
5860
5861 if (isset($c['colspan']) && $c['colspan'] > 1) {
5862 $parentwidth = 0;
5863 for ($cs = 0; $cs < $c['colspan']; $cs++) {
5864 $parentwidth += $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol + $cs];
5865 }
5866 } else {
5867 $parentwidth = $this->mpdf->table[($lvl - 1)][$parentnid]['wc'][$parentcol];
5868 }
5869
5870 //$parentwidth -= ALLOW FOR PADDING ETC.in parent cell
5871 if (!$this->mpdf->simpleTables) {
5872 if ($this->mpdf->packTableData) {
5873 list($bt, $br, $bb, $bl) = $this->mpdf->_getBorderWidths($c['borderbin']);
5874 } else {
5875 $br = $c['border_details']['R']['w'];
5876 $bl = $c['border_details']['L']['w'];
5877 }
5878 if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
5879 $parentwidth -= $br + $bl + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
5880 } else {
5881 $parentwidth -= $br / 2 + $bl / 2 + $c['padding']['L'] + $c['padding']['R'];
5882 }
5883 } else if ($this->mpdf->simpleTables) {
5884 if ($this->mpdf->table[$lvl - 1][$parentnid]['borders_separate']) {
5885 $parentwidth -= $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w'] + $c['padding']['L'] + $c['padding']['R'] + $this->mpdf->table[($lvl - 1)][$parentnid]['border_spacing_H'];
5886 } else {
5887 $parentwidth -= ($this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['L']['w'] + $this->mpdf->table[($lvl - 1)][$parentnid]['simple']['border_details']['R']['w']) / 2 + $c['padding']['L'] + $c['padding']['R'];
5888 }
5889 }
5890 if (isset($this->mpdf->table[$lvl][$nid]['wpercent']) && $this->mpdf->table[$lvl][$nid]['wpercent'] && $lvl > 1) {
5891 $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
5892 } else if ($parentwidth > $this->mpdf->table[$lvl][$nid]['maw']) {
5893 $this->mpdf->table[$lvl][$nid]['w'] = $this->mpdf->table[$lvl][$nid]['maw'];
5894 } else {
5895 $this->mpdf->table[$lvl][$nid]['w'] = $parentwidth;
5896 }
5897 unset($c);
5898 $this->mpdf->_tableWidth($this->mpdf->table[$lvl][$nid]);
5899 }
5900 }
5901
5902 // Starting at $this->mpdf->innermostTableLevel
5903 // Cascade back up nested tables: setting heights back up the tree
5904 for ($lvl = $this->mpdf->innermostTableLevel; $lvl > 0; $lvl--) {
5905 for ($nid = 1; $nid <= $this->mpdf->tbctr[$lvl]; $nid++) {
5906 list($tableheight, $maxrowheight, $fullpage, $remainingpage, $maxfirstrowheight) = $this->mpdf->_tableHeight($this->mpdf->table[$lvl][$nid]);
5907 }
5908 }
5909
5910 // RESIZING ALGORITHM
5911
5912 if ($maxrowheight > $fullpage) {
5913 $recalculate = $this->mpdf->tbsqrt($maxrowheight / $fullpage, $iteration);
5914 $iteration++;
5915 } else if ($this->mpdf->table_rotate && $tableheight > $remainingpage && !$added_page) {
5916 // If can fit on remainder of page whilst respecting autosize value..
5917 if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->mpdf->shrink_this_table_to_fit) {
5918 $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration);
5919 $iteration++;
5920 } else {
5921 if (!$added_page) {
5922 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5923 $added_page = true;
5924 $this->mpdf->kwt_moved = true;
5925 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5926 }
5927 // 0.001 to force it to recalculate
5928 $recalculate = (1 / $this->mpdf->shrin_k) + 0.001; // undo any shrink
5929 }
5930 } else if ($this->mpdf->table_keep_together || ($this->mpdf->table[1][1]['nr'] == 1 && !$this->mpdf->writingHTMLfooter)) {
5931 if ($tableheight > $fullpage) {
5932 if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration)) <= $this->mpdf->shrink_this_table_to_fit) {
5933 $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration);
5934 $iteration++;
5935 } else if ($this->mpdf->tableMinSizePriority) {
5936 $this->mpdf->table_keep_together = false;
5937 $recalculate = (1 / $this->mpdf->shrin_k) + 0.001;
5938 } else {
5939 if (!$added_page && $this->mpdf->y != $this->mpdf->tMargin) {
5940 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5941 $added_page = true;
5942 $this->mpdf->kwt_moved = true;
5943 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5944 }
5945 $recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration);
5946 $iteration++;
5947 }
5948 } else if ($tableheight > $remainingpage) {
5949 // If can fit on remainder of page whilst respecting autosize value..
5950 if (($this->mpdf->shrin_k * $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->mpdf->shrink_this_table_to_fit) {
5951 $recalculate = $this->mpdf->tbsqrt($tableheight / $remainingpage, $iteration);
5952 $iteration++;
5953 } else {
5954 if (!$added_page) {
5955 // mPDF 6
5956 if ($this->mpdf->AcceptPageBreak()) {
5957 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5958 } else if ($this->mpdf->ColActive && $tableheight > (($this->mpdf->h - $this->mpdf->bMargin) - $this->mpdf->y0)) {
5959 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5960 }
5961 $added_page = true;
5962 $this->mpdf->kwt_moved = true;
5963 $this->mpdf->tbrot_maxw = $this->mpdf->h - ($this->mpdf->y + $this->mpdf->bMargin + 5) - $this->mpdf->kwt_height;
5964 }
5965
5966 //$recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
5967 $recalculate = (1 / $this->mpdf->shrin_k) + 0.001; // undo any shrink
5968 }
5969 } else {
5970 $recalculate = 1;
5971 }
5972 } else {
5973 $recalculate = 1;
5974 }
5975 }
5976
5977
5978 if ($maxfirstrowheight > $remainingpage && !$added_page && !$this->mpdf->table_rotate && !$this->mpdf->ColActive && !$this->mpdf->table_keep_together && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) {
5979 $this->mpdf->AddPage($this->mpdf->CurOrientation);
5980 $this->mpdf->kwt_moved = true;
5981 }
5982
5983 // keep-with-table: if page has advanced, print out buffer now, else done in fn. _Tablewrite()
5984 if ($this->mpdf->kwt_saved && $this->mpdf->kwt_moved) {
5985 $this->mpdf->printkwtbuffer();
5986 $this->mpdf->kwt_moved = false;
5987 $this->mpdf->kwt_saved = false;
5988 }
5989
5990 if ($this->mpdf->progressBar) {
5991 $this->mpdf->UpdateProgressBar(7, 30, ' ');
5992 } // *PROGRESS-BAR*
5993 // Recursively writes all tables starting at top level
5994 $this->mpdf->_tableWrite($this->mpdf->table[1][1]);
5995
5996 if ($this->mpdf->table_rotate && $this->mpdf->tablebuffer) {
5997 $this->mpdf->PageBreakTrigger = $this->mpdf->h - $this->mpdf->bMargin;
5998 $save_tr = $this->mpdf->table_rotate;
5999 $save_y = $this->mpdf->y;
6000 $this->mpdf->table_rotate = 0;
6001 $this->mpdf->y = $this->mpdf->tbrot_y0;
6002 $h = $this->mpdf->tbrot_w;
6003 $this->mpdf->DivLn($h, $this->mpdf->blklvl, true);
6004
6005 $this->mpdf->table_rotate = $save_tr;
6006 $this->mpdf->y = $save_y;
6007
6008 $this->mpdf->printtablebuffer();
6009 }
6010 $this->mpdf->table_rotate = 0;
6011 }
6012
6013
6014 $this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
6015
6016 $this->mpdf->maxPosR = max($this->mpdf->maxPosR, ($this->mpdf->x + $this->mpdf->table[1][1]['w']));
6017
6018 $this->mpdf->blockjustfinished = true;
6019 $this->mpdf->lastblockbottommargin = $this->mpdf->table[1][1]['margin']['B'];
6020 //Reset values
6021
6022 if (isset($this->mpdf->table[1][1]['page_break_after'])) {
6023 $page_break_after = $this->mpdf->table[1][1]['page_break_after'];
6024 } else {
6025 $page_break_after = '';
6026 }
6027
6028 // Keep-with-table
6029 $this->mpdf->kwt = false;
6030 $this->mpdf->kwt_y0 = 0;
6031 $this->mpdf->kwt_x0 = 0;
6032 $this->mpdf->kwt_height = 0;
6033 $this->mpdf->kwt_buffer = array();
6034 $this->mpdf->kwt_Links = array();
6035 $this->mpdf->kwt_Annots = array();
6036 $this->mpdf->kwt_moved = false;
6037 $this->mpdf->kwt_saved = false;
6038
6039 $this->mpdf->kwt_Reference = array();
6040 $this->mpdf->kwt_BMoutlines = array();
6041 $this->mpdf->kwt_toc = array();
6042
6043 $this->mpdf->shrin_k = 1;
6044 $this->mpdf->shrink_this_table_to_fit = 0;
6045
6046 unset($this->mpdf->table);
6047 $this->mpdf->table = array(); //array
6048 $this->mpdf->tableLevel = 0;
6049 $this->mpdf->tbctr = array();
6050 $this->mpdf->innermostTableLevel = 0;
6051 $this->mpdf->cssmgr->tbCSSlvl = 0;
6052 $this->mpdf->cssmgr->tablecascadeCSS = array();
6053
6054 unset($this->mpdf->cell);
6055 $this->mpdf->cell = array(); //array
6056
6057 $this->mpdf->col = -1; //int
6058 $this->mpdf->row = -1; //int
6059 $this->mpdf->Reset();
6060
6061 $this->mpdf->cellPaddingL = 0;
6062 $this->mpdf->cellPaddingT = 0;
6063 $this->mpdf->cellPaddingR = 0;
6064 $this->mpdf->cellPaddingB = 0;
6065 $this->mpdf->cMarginL = 0;
6066 $this->mpdf->cMarginT = 0;
6067 $this->mpdf->cMarginR = 0;
6068 $this->mpdf->cMarginB = 0;
6069 $this->mpdf->default_font_size = $this->mpdf->original_default_font_size;
6070 $this->mpdf->default_font = $this->mpdf->original_default_font;
6071 $this->mpdf->SetFontSize($this->mpdf->default_font_size, false);
6072 $this->mpdf->SetFont($this->mpdf->default_font, '', 0, false);
6073 $this->mpdf->SetLineHeight();
6074 if (isset($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties'])) {
6075 $this->mpdf->restoreInlineProperties($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties']);
6076 }
6077 if ($this->mpdf->progressBar) {
6078 $this->mpdf->UpdateProgressBar(7, 100, ' ');
6079 } // *PROGRESS-BAR*
6080
6081 if ($page_break_after) {
6082 $save_blklvl = $this->mpdf->blklvl;
6083 $save_blk = $this->mpdf->blk;
6084 $save_silp = $this->mpdf->saveInlineProperties();
6085 $save_ilp = $this->mpdf->InlineProperties;
6086 $save_bflp = $this->mpdf->InlineBDF;
6087 $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
6088 // mPDF 6 pagebreaktype
6089 $startpage = $this->mpdf->page;
6090 $pagebreaktype = $this->mpdf->defaultPagebreakType;
6091 if ($this->mpdf->ColActive) {
6092 $pagebreaktype = 'cloneall';
6093 }
6094
6095 // mPDF 6 pagebreaktype
6096 $this->mpdf->_preForcedPagebreak($pagebreaktype);
6097
6098 if ($page_break_after == 'RIGHT') {
6099 $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
6100 } else if ($page_break_after == 'LEFT') {
6101 $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
6102 } else {
6103 $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
6104 }
6105
6106 // mPDF 6 pagebreaktype
6107 $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
6108
6109 $this->mpdf->InlineProperties = $save_ilp;
6110 $this->mpdf->InlineBDF = $save_bflp;
6111 $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
6112 $this->mpdf->restoreInlineProperties($save_silp);
6113 }
6114 }
6115 /* -- END TABLES -- */
6116 }
6117
6118 }
6119