8 public function __construct(mPDF
$mpdf)
13 function OpenTag($tag, $attr, &$ahtml, &$ihtml)
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'])) {
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);
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);
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);
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);
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);
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);
52 if (!$closed && ($tag == 'TD' ||
$tag == 'TH') && $this->mpdf
->lastoptionaltag
== 'TH') {
53 $this->CloseTag($this->mpdf
->lastoptionaltag
, $ahtml, $ihtml);
56 if (!$closed && $tag == 'TR' && $this->mpdf
->lastoptionaltag
== 'TR') {
57 $this->CloseTag($this->mpdf
->lastoptionaltag
, $ahtml, $ihtml);
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);
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);
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');
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
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);
102 $objattr['outdent'] = 0;
105 $objattr['fontfamily'] = $this->mpdf
->FontFamily
;
106 $objattr['fontsize'] = $this->mpdf
->FontSizePt
;
108 $e = "\xbb\xa4\xactype=dottab,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
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'];
117 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] = 0; // reset
118 $this->mpdf
->_saveCellTextBuffer($e);
120 /* -- END TABLES -- */
121 $this->mpdf
->_saveTextBuffer($e);
127 $this->mpdf
->ignorefollowingspaces
= true;
129 $pname = $attr['NAME'];
131 $pname = '_nonhtmldefault';
134 $p = array(); // mPDF 6
138 $p['L']['font-style'] = '';
139 $p['C']['font-style'] = '';
140 $p['R']['font-style'] = '';
142 if (isset($attr['CONTENT-LEFT'])) {
143 $p['L']['content'] = $attr['CONTENT-LEFT'];
145 if (isset($attr['CONTENT-CENTER'])) {
146 $p['C']['content'] = $attr['CONTENT-CENTER'];
148 if (isset($attr['CONTENT-RIGHT'])) {
149 $p['R']['content'] = $attr['CONTENT-RIGHT'];
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']);
156 $properties = $this->mpdf
->cssmgr
->readInlineCSS($attr['FOOTER-STYLE']);
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'];
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
;
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';
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';
178 if (isset($properties['COLOR'])) {
179 $p['L']['color'] = $properties['COLOR'];
180 $p['C']['color'] = $properties['COLOR'];
181 $p['R']['color'] = $properties['COLOR'];
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']);
188 $properties = $this->mpdf
->cssmgr
->readInlineCSS($attr['FOOTER-STYLE-LEFT']);
190 if (isset($properties['FONT-FAMILY'])) {
191 $p['L']['font-family'] = $properties['FONT-FAMILY'];
193 if (isset($properties['FONT-SIZE'])) {
194 $p['L']['font-size'] = $this->mpdf
->ConvertSize($properties['FONT-SIZE']) * _MPDFK
;
196 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
197 $p['L']['font-style'] = 'B';
199 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
200 $p['L']['font-style'] .='I';
202 if (isset($properties['COLOR'])) {
203 $p['L']['color'] = $properties['COLOR'];
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']);
210 $properties = $this->mpdf
->cssmgr
->readInlineCSS($attr['FOOTER-STYLE-CENTER']);
212 if (isset($properties['FONT-FAMILY'])) {
213 $p['C']['font-family'] = $properties['FONT-FAMILY'];
215 if (isset($properties['FONT-SIZE'])) {
216 $p['C']['font-size'] = $this->mpdf
->ConvertSize($properties['FONT-SIZE']) * _MPDFK
;
218 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
219 $p['C']['font-style'] = 'B';
221 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
222 $p['C']['font-style'] .= 'I';
224 if (isset($properties['COLOR'])) {
225 $p['C']['color'] = $properties['COLOR'];
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']);
232 $properties = $this->mpdf
->cssmgr
->readInlineCSS($attr['FOOTER-STYLE-RIGHT']);
234 if (isset($properties['FONT-FAMILY'])) {
235 $p['R']['font-family'] = $properties['FONT-FAMILY'];
237 if (isset($properties['FONT-SIZE'])) {
238 $p['R']['font-size'] = $this->mpdf
->ConvertSize($properties['FONT-SIZE']) * _MPDFK
;
240 if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') {
241 $p['R']['font-style'] = 'B';
243 if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') {
244 $p['R']['font-style'] .= 'I';
246 if (isset($properties['COLOR'])) {
247 $p['R']['color'] = $properties['COLOR'];
250 if (isset($attr['LINE']) && $attr['LINE']) { // 0|1|on|off
251 if ($attr['LINE'] == '1' ||
strtoupper($attr['LINE']) == 'ON') {
256 $p['line'] = $lineset;
259 if ($tag == 'PAGEHEADER') {
260 $this->mpdf
->DefHeaderByName($pname, $p);
262 $this->mpdf
->DefFooterByName($pname, $p);
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';
280 if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
281 if (strtoupper($attr['PAGE']) == 'O' ||
strtoupper($attr['PAGE']) == 'ODD') {
283 } else if (strtoupper($attr['PAGE']) == 'E' ||
strtoupper($attr['PAGE']) == 'EVEN') {
285 } else if (strtoupper($attr['PAGE']) == 'ALL') {
293 if (isset($attr['VALUE']) && $attr['VALUE']) { // -1|1|on|off
294 if ($attr['VALUE'] == '1' ||
strtoupper($attr['VALUE']) == 'ON') {
296 } else if ($attr['VALUE'] == '-1' ||
strtoupper($attr['VALUE']) == 'OFF') {
304 if (isset($attr['SHOW-THIS-PAGE']) && $attr['SHOW-THIS-PAGE'] && ($tag == 'SETHTMLPAGEHEADER' ||
$tag == 'SETPAGEHEADER')) {
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');
317 $this->mpdf
->SetHTMLFooter('', 'O');
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');
328 $this->mpdf
->SetHTMLFooter('', 'E');
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');
340 if (empty($this->mpdf
->tocontents
)) {
341 $this->mpdf
->tocontents
= new tocontents($this);
343 $this->mpdf
->tocontents
->openTagTOC($attr);
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');
351 if (empty($this->mpdf
->tocontents
)) {
352 $this->mpdf
->tocontents
= new tocontents($this->mpdf
);
354 list($isbreak, $toc_id) = $this->mpdf
->tocontents
->openTagTOCPAGEBREAK($attr);
357 if (!isset($attr['RESETPAGENUM']) ||
$attr['RESETPAGENUM'] < 1) {
358 $attr['RESETPAGENUM'] = 1;
360 // No break - continues as PAGEBREAK...
364 case 'PAGE_BREAK': //custom-tag
365 case 'PAGEBREAK': //custom-tag
366 case 'NEWPAGE': //custom-tag
367 case 'FORMFEED': //custom-tag
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]));
375 $newformat = $attr['SHEET-SIZE'];
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
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);
392 if (isset($attr['MARGIN-LEFT'])) {
393 $mgl = $this->mpdf
->ConvertSize($attr['MARGIN-LEFT'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
395 if (isset($attr['MARGIN-TOP'])) {
396 $mgt = $this->mpdf
->ConvertSize($attr['MARGIN-TOP'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
398 if (isset($attr['MARGIN-BOTTOM'])) {
399 $mgb = $this->mpdf
->ConvertSize($attr['MARGIN-BOTTOM'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
401 if (isset($attr['MARGIN-HEADER'])) {
402 $mgh = $this->mpdf
->ConvertSize($attr['MARGIN-HEADER'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
404 if (isset($attr['MARGIN-FOOTER'])) {
405 $mgf = $this->mpdf
->ConvertSize($attr['MARGIN-FOOTER'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
407 $ohname = $ehname = $ofname = $efname = '';
408 if (isset($attr['ODD-HEADER-NAME'])) {
409 $ohname = $attr['ODD-HEADER-NAME'];
411 if (isset($attr['EVEN-HEADER-NAME'])) {
412 $ehname = $attr['EVEN-HEADER-NAME'];
414 if (isset($attr['ODD-FOOTER-NAME'])) {
415 $ofname = $attr['ODD-FOOTER-NAME'];
417 if (isset($attr['EVEN-FOOTER-NAME'])) {
418 $efname = $attr['EVEN-FOOTER-NAME'];
420 $ohvalue = $ehvalue = $ofvalue = $efvalue = 0;
421 if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '1' ||
strtoupper($attr['ODD-HEADER-VALUE']) == 'ON')) {
423 } else if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '-1' ||
strtoupper($attr['ODD-HEADER-VALUE']) == 'OFF')) {
426 if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '1' ||
strtoupper($attr['EVEN-HEADER-VALUE']) == 'ON')) {
428 } else if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '-1' ||
strtoupper($attr['EVEN-HEADER-VALUE']) == 'OFF')) {
431 if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '1' ||
strtoupper($attr['ODD-FOOTER-VALUE']) == 'ON')) {
433 } else if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '-1' ||
strtoupper($attr['ODD-FOOTER-VALUE']) == 'OFF')) {
436 if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '1' ||
strtoupper($attr['EVEN-FOOTER-VALUE']) == 'ON')) {
438 } else if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '-1' ||
strtoupper($attr['EVEN-FOOTER-VALUE']) == 'OFF')) {
442 if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'L' ||
strtoupper($attr['ORIENTATION']) == 'LANDSCAPE')) {
444 } else if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'P' ||
strtoupper($attr['ORIENTATION']) == 'PORTRAIT')) {
447 $orient = $this->mpdf
->CurOrientation
;
450 if (isset($attr['PAGE-SELECTOR']) && $attr['PAGE-SELECTOR']) {
451 $pagesel = $attr['PAGE-SELECTOR'];
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']);
467 if ($tag == 'TOCPAGEBREAK') {
468 $pagebreaktype = 'cloneall';
469 } else if ($this->mpdf
->ColActive
) {
470 $pagebreaktype = 'cloneall';
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';
480 // mPDF 6 pagebreaktype
481 $this->mpdf
->_preForcedPagebreak($pagebreaktype);
483 $this->mpdf
->ignorefollowingspaces
= true;
489 if (isset($attr['RESETPAGENUM'])) {
490 $resetpagenum = $attr['RESETPAGENUM'];
492 if (isset($attr['PAGENUMSTYLE'])) {
493 $pagenumstyle = $attr['PAGENUMSTYLE'];
495 if (isset($attr['SUPPRESS'])) {
496 $suppress = $attr['SUPPRESS'];
499 if ($tag == 'TOCPAGEBREAK') {
501 } else if (isset($attr['TYPE'])) {
502 $type = strtoupper($attr['TYPE']);
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);
516 $this->mpdf
->AddPage($orient, '', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat);
520 if ($tag == 'TOCPAGEBREAK') {
522 $this->mpdf
->tocontents
->m_TOC
[$toc_id]['TOCmark'] = $this->mpdf
->page
;
524 $this->mpdf
->tocontents
->TOCmark
= $this->mpdf
->page
;
529 // mPDF 6 pagebreaktype
530 $this->mpdf
->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
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);
542 if (isset($attr['CONTENT']) && $attr['CONTENT']) {
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'];
550 $objattr['toclevel'] = 0;
552 if (isset($attr['NAME']) && $attr['NAME']) {
553 $objattr['toc_id'] = $attr['NAME'];
555 $objattr['toc_id'] = 0;
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);
562 $this->mpdf
->textbuffer
[] = array($e);
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']);
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);
584 $this->mpdf
->textbuffer
[] = array($e);
591 if (isset($attr['COLLATION'])) {
592 $indexCollationLocale = $attr['COLLATION'];
594 $indexCollationLocale = '';
596 if (isset($attr['COLLATION-GROUP'])) {
597 $indexCollationGroup = $attr['COLLATION-GROUP'];
599 $indexCollationGroup = '';
601 if (isset($attr['USEDIVLETTERS']) && (strtoupper($attr['USEDIVLETTERS']) == 'OFF' ||
$attr['USEDIVLETTERS'] == -1 ||
$attr['USEDIVLETTERS'] === '0')) {
606 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' ||
$attr['LINKS'] == 1)) {
611 $this->mpdf
->InsertIndex($usedivletters, $links, $indexCollationLocale, $indexCollationGroup);
614 /* -- END INDEX -- */
616 /* -- WATERMARK -- */
618 case 'WATERMARKTEXT':
619 if (isset($attr['CONTENT']) && $attr['CONTENT']) {
620 $txt = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES
);
624 if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) {
625 $alpha = $attr['ALPHA'];
629 $this->mpdf
->SetWatermarkText($txt, $alpha);
633 case 'WATERMARKIMAGE':
634 if (isset($attr['SRC'])) {
639 if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) {
640 $alpha = $attr['ALPHA'];
644 if (isset($attr['SIZE']) && $attr['SIZE']) {
645 $size = $attr['SIZE'];
646 if (strpos($size, ',')) {
647 $size = explode(',', $size);
652 if (isset($attr['POSITION']) && $attr['POSITION']) { // mPDF 5.7.2
653 $pos = $attr['POSITION'];
654 if (strpos($pos, ',')) {
655 $pos = explode(',', $pos);
660 $this->mpdf
->SetWatermarkImage($src, $alpha, $size, $pos);
662 /* -- END WATERMARK -- */
664 /* -- BOOKMARKS -- */
666 if (isset($attr['CONTENT'])) {
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'];
673 $objattr['bklevel'] = 0;
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);
680 $this->mpdf
->textbuffer
[] = array($e);
684 /* -- END BOOKMARKS -- */
686 /* -- ANNOTATIONS -- */
689 //if (isset($attr['CONTENT']) && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) { // Stops annotations in FixedPos
690 if (isset($attr['CONTENT'])) {
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'] = '';
708 if (isset($attr['POS-X'])) {
709 $objattr['POS-X'] = $attr['POS-X'];
711 $objattr['POS-X'] = 0;
713 if (isset($attr['POS-Y'])) {
714 $objattr['POS-Y'] = $attr['POS-Y'];
716 $objattr['POS-Y'] = 0;
718 if (isset($attr['ICON'])) {
719 $objattr['ICON'] = $attr['ICON'];
721 $objattr['ICON'] = 'Note';
723 if (isset($attr['AUTHOR'])) {
724 $objattr['AUTHOR'] = $attr['AUTHOR'];
725 } else if (isset($attr['TITLE'])) {
726 $objattr['AUTHOR'] = $attr['TITLE'];
728 $objattr['AUTHOR'] = '';
730 if (isset($attr['FILE'])) {
731 $objattr['FILE'] = $attr['FILE'];
733 $objattr['FILE'] = '';
735 if (isset($attr['SUBJECT'])) {
736 $objattr['SUBJECT'] = $attr['SUBJECT'];
738 $objattr['SUBJECT'] = '';
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;
745 $objattr['OPACITY'] = $this->mpdf
->annotOpacity
;
747 if (isset($attr['COLOR'])) {
748 $cor = $this->mpdf
->ConvertColor($attr['COLOR']);
750 $objattr['COLOR'] = $cor;
752 $objattr['COLOR'] = $this->mpdf
->ConvertColor('yellow');
755 $objattr['COLOR'] = $this->mpdf
->ConvertColor('yellow');
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;
763 $objattr['POPUP'] = true;
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);
771 $this->mpdf
->textbuffer
[] = array($e);
774 /* -- END ANNOTATIONS -- */
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);
784 if (!empty($this->mpdf
->textbuffer
)) { //Output previously buffered content
785 $this->mpdf
->printbuffer($this->mpdf
->textbuffer
);
786 $this->mpdf
->textbuffer
= array();
789 if (isset($attr['VALIGN']) && $attr['VALIGN']) {
790 if ($attr['VALIGN'] == 'J') {
793 $valign = $align[$attr['VALIGN']];
798 if (isset($attr['COLUMN-GAP']) && $attr['COLUMN-GAP']) {
799 $this->mpdf
->SetColumns($attr['COLUMN-COUNT'], $valign, $attr['COLUMN-GAP']);
801 $this->mpdf
->SetColumns($attr['COLUMN-COUNT'], $valign);
804 $this->mpdf
->ignorefollowingspaces
= true;
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.
815 /* -- END COLUMNS -- */
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');
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');
831 $this->mpdf
->tta
= true;
832 $this->mpdf
->InlineProperties
[$tag] = $this->mpdf
->saveInlineProperties();
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');
839 $this->mpdf
->setCSS(array('FONT-FAMILY' => 'chelvetica'), 'INLINE');
845 // INLINE PHRASES OR STYLES
870 case 'BDO': // mPDF 6
871 case 'BDI': // mPDF 6
874 /* -- ANNOTATIONS -- */
875 if ($this->mpdf
->title2annots
&& isset($attr['TITLE'])) {
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;
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";
899 /* -- END ANNOTATIONS -- */
901 // mPDF 5.7.3 Inline tags
902 if (!isset($this->mpdf
->InlineProperties
[$tag])) {
903 $this->mpdf
->InlineProperties
[$tag] = array($this->mpdf
->saveInlineProperties());
905 $this->mpdf
->InlineProperties
[$tag][] = $this->mpdf
->saveInlineProperties();
907 if (isset($annot)) { // *ANNOTATIONS*
908 if (!isset($this->mpdf
->InlineAnnots
[$tag])) {
909 $this->mpdf
->InlineAnnots
[$tag] = array($annot);
912 $this->mpdf
->InlineAnnots
[$tag][] = $annot;
916 $properties = $this->mpdf
->cssmgr
->MergeCSS('INLINE', $tag, $attr);
917 if (!empty($properties))
918 $this->mpdf
->setCSS($properties, 'INLINE');
920 // mPDF 6 Bidirectional formatting for inline elements
925 // Get current direction
926 if (isset($this->mpdf
->blk
[$this->mpdf
->blklvl
]['direction'])) {
927 $currdir = $this->mpdf
->blk
[$this->mpdf
->blklvl
]['direction'];
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') {
934 if (isset($attr['DIR']) and $attr['DIR'] != '') {
935 $currdir = strtolower($attr['DIR']);
937 if (isset($properties['DIRECTION'])) {
938 $currdir = strtolower($properties['DIRECTION']);
942 // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi
944 if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
948 else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
952 } else if ($tag == 'BDI') {
953 if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
957 else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
965 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'bidi-override') {
966 if ($currdir == 'rtl') {
974 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'embed') {
975 if ($currdir == 'rtl') {
983 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate') {
984 if ($currdir == 'rtl') {
992 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate-override') {
993 if ($currdir == 'rtl') {
996 $popd = 'RLIRLOPDFPDI';
997 } // U+2067 RLI // U+202E RLO
1001 $popd = 'LRILROPDFPDI';
1002 } // U+2066 LRI // U+202D LRO
1003 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') {
1005 $popd = 'FSIPDI'; // U+2068 FSI
1007 if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') {
1011 else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') {
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
));
1022 $this->mpdf
->InlineBDF
[$tag][] = array($popd, $this->mpdf
->InlineBDFctr
);
1024 $this->mpdf
->InlineBDFctr++
;
1026 $bdf2 = code2utf($bdf);
1028 $this->mpdf
->OTLdata
= array();
1029 if ($this->mpdf
->tableLevel
) {
1030 $this->mpdf
->_saveCellTextBuffer(code2utf($bdf) . $bdf2);
1032 $this->mpdf
->_saveTextBuffer(code2utf($bdf) . $bdf2);
1034 $this->mpdf
->biDirectional
= true;
1041 if (isset($attr['NAME']) and $attr['NAME'] != '') {
1043 /* -- BOOKMARKS -- */
1044 if ($this->mpdf
->anchor2Bookmark
) {
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'];
1051 $objattr['bklevel'] = 0;
1053 $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
1055 /* -- END BOOKMARKS -- */
1056 if ($this->mpdf
->tableLevel
) { // *TABLES*
1057 $this->mpdf
->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
1060 $this->mpdf
->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
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
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');
1083 $this->mpdf
->inMeter
= true;
1085 if (isset($attr['MAX']) && $attr['MAX']) {
1086 $max = $attr['MAX'];
1090 if (isset($attr['MIN']) && $attr['MIN'] && $tag == 'METER') {
1091 $min = $attr['MIN'];
1099 if (isset($attr['VALUE']) && ($attr['VALUE'] ||
$attr['VALUE'] === '0')) {
1100 $value = $attr['VALUE'];
1101 if ($value < $min) {
1103 } else if ($value > $max) {
1110 if (isset($attr['LOW']) && $attr['LOW']) {
1111 $low = $attr['LOW'];
1117 } else if ($low > $max) {
1120 if (isset($attr['HIGH']) && $attr['HIGH']) {
1121 $high = $attr['HIGH'];
1127 } else if ($high > $max) {
1130 if (isset($attr['OPTIMUM']) && $attr['OPTIMUM']) {
1131 $optimum = $attr['OPTIMUM'];
1133 $optimum = $min +
(($max - $min) / 2);
1135 if ($optimum < $min) {
1137 } else if ($optimum > $max) {
1140 if (isset($attr['TYPE']) && $attr['TYPE']) {
1141 $type = $attr['TYPE'];
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;
1161 $properties = $this->mpdf
->cssmgr
->MergeCSS('INLINE', $tag, $attr);
1162 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
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;
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);
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);
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);
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);
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);
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);
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);
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);
1199 if (isset($properties['BORDER-TOP'])) {
1200 $objattr['border_top'] = $this->mpdf
->border_details($properties['BORDER-TOP']);
1202 if (isset($properties['BORDER-BOTTOM'])) {
1203 $objattr['border_bottom'] = $this->mpdf
->border_details($properties['BORDER-BOTTOM']);
1205 if (isset($properties['BORDER-LEFT'])) {
1206 $objattr['border_left'] = $this->mpdf
->border_details($properties['BORDER-LEFT']);
1208 if (isset($properties['BORDER-RIGHT'])) {
1209 $objattr['border_right'] = $this->mpdf
->border_details($properties['BORDER-RIGHT']);
1212 if (isset($properties['VERTICAL-ALIGN'])) {
1213 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
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);
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);
1227 if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
1228 $objattr['opacity'] = $properties['OPACITY'];
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];
1238 $objattr['link'] = $this->mpdf
->HREF
;
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'];
1245 if (!class_exists('meter', false)) {
1246 include(_MPDF_PATH
. 'classes/meter.php');
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);
1256 $info = $this->mpdf
->_getImage($srcpath, true, true, $orig_srcpath);
1258 $info = $this->mpdf
->_getImage($this->mpdf
->noImageFile
);
1260 $srcpath = $this->mpdf
->noImageFile
;
1261 $w = ($info['w'] * (25.4 / $this->mpdf
->dpi
));
1262 $h = ($info['h'] * (25.4 / $this->mpdf
->dpi
));
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
;
1275 // IF WIDTH OR HEIGHT SPECIFIED
1277 $w = abs($h * $info['w'] / $info['h']);
1279 $h = abs($w * $info['h'] / $info['w']);
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
;
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']);
1292 if ($h +
$extraheight > $maxHeight) {
1293 $h = $maxHeight - $extraheight;
1294 $w = abs($h * $info['w'] / $info['h']);
1296 $objattr['type'] = 'image';
1297 $objattr['itype'] = $info['type'];
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'];
1313 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
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
);
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
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']);
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
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];
1351 for ($i = count($iBDF) - 1; $i >= 0; $i--) {
1352 $inlinepre .= $this->mpdf
->_setBidiCodes('end', $iBDF[$i]);
1354 for ($i = 0; $i < count($iBDF); $i++
) {
1355 $inlinepost .= $this->mpdf
->_setBidiCodes('start', $iBDF[$i]);
1361 if ($this->mpdf
->tableLevel
) {
1363 if ($this->mpdf
->blockjustfinished
) {
1364 $this->mpdf
->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
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'];
1373 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] = 0; // reset
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);
1382 $this->mpdf
->_saveTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost);
1384 $this->mpdf
->ignorefollowingspaces
= true;
1385 $this->mpdf
->blockjustfinished
= false;
1387 $this->mpdf
->linebreakjustfinished
= true;
1391 // *********** BLOCKS ********************
1395 $this->mpdf
->ispre
= true; // ADDED - Prevents left trim of textbuffer in printbuffer()
1415 case 'UL': // mPDF 6 Lists
1416 case 'OL': // mPDF 6
1417 case 'LI': // mPDF 6
1432 $this->mpdf
->lastoptionaltag
= '';
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']);
1440 $this->mpdf
->OTLdata
= array();
1441 if ($this->mpdf
->tableLevel
) {
1442 $this->mpdf
->_saveCellTextBuffer($blockpost);
1444 $this->mpdf
->_saveTextBuffer($blockpost);
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
1457 if ($tag == 'CAPTION') {
1458 // position is written in AdjstHTML
1459 if (isset($attr['POSITION']) && strtolower($attr['POSITION']) == 'bottom') {
1464 if (isset($attr['ALIGN']) && strtolower($attr['ALIGN']) == 'bottom') {
1466 } else if (isset($p['CAPTION-SIDE']) && strtolower($p['CAPTION-SIDE']) == 'bottom') {
1471 if (isset($attr['ALIGN'])) {
1472 unset($attr['ALIGN']);
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
1483 if ($tag == 'FORM') {
1484 if (isset($attr['METHOD']) && strtolower($attr['METHOD']) == 'get') {
1485 $this->mpdf
->mpdfform
->formMethod
= 'GET';
1487 $this->mpdf
->mpdfform
->formMethod
= 'POST';
1489 if (isset($attr['ACTION'])) {
1490 $this->mpdf
->mpdfform
->formAction
= $attr['ACTION'];
1492 $this->mpdf
->mpdfform
->formAction
= '';
1495 /* -- END FORMS -- */
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");
1503 $this->mpdf
->inFixedPosBlock
= true;
1506 /* -- END CSS-POSITION -- */
1508 $this->mpdf
->ignorefollowingspaces
= true;
1510 if ($this->mpdf
->blockjustfinished
&& !count($this->mpdf
->textbuffer
) && $this->mpdf
->y
!= $this->mpdf
->tMargin
&& $this->mpdf
->collapseBlockMargins
) {
1511 $lastbottommargin = $this->mpdf
->lastblockbottommargin
;
1513 $lastbottommargin = 0;
1515 $this->mpdf
->lastblockbottommargin
= 0;
1516 $this->mpdf
->blockjustfinished
= false;
1519 $this->mpdf
->InlineBDF
= array(); // mPDF 6
1520 $this->mpdf
->InlineBDFctr
= 0; // mPDF 6
1521 $this->mpdf
->InlineProperties
= array();
1522 $this->mpdf
->divbegin
= true;
1524 $this->mpdf
->linebreakjustfinished
= false;
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'];
1536 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] = 0; // reset
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'];
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');
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;
1554 $this->mpdf
->listcounter
[$this->mpdf
->listlvl
] = 0;
1556 $this->mpdf
->listitem
= array();
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';
1565 $this->mpdf
->listtype
[$this->mpdf
->listlvl
] = 'square';
1569 // mPDF 6 Lists - in Tables
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;
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
]) {
1583 $blt = $this->mpdf
->dec2alpha($this->mpdf
->listcounter
[$this->mpdf
->listlvl
], true) . $this->mpdf
->list_number_suffix
;
1588 $blt = $this->mpdf
->dec2alpha($this->mpdf
->listcounter
[$this->mpdf
->listlvl
], false) . $this->mpdf
->list_number_suffix
;
1592 $blt = $this->mpdf
->dec2roman($this->mpdf
->listcounter
[$this->mpdf
->listlvl
], true) . $this->mpdf
->list_number_suffix
;
1596 $blt = $this->mpdf
->dec2roman($this->mpdf
->listcounter
[$this->mpdf
->listlvl
], false) . $this->mpdf
->list_number_suffix
;
1600 $blt = $this->mpdf
->listcounter
[$this->mpdf
->listlvl
] . $this->mpdf
->list_number_suffix
;
1603 if ($this->mpdf
->listlvl %
3 == 1 && $this->mpdf
->_charDefined($this->mpdf
->CurrentFont
['cw'], 8226)) {
1604 $blt = "\xe2\x80\xa2";
1606 else if ($this->mpdf
->listlvl %
3 == 2 && $this->mpdf
->_charDefined($this->mpdf
->CurrentFont
['cw'], 9900)) {
1607 $blt = "\xe2\x9a\xac";
1609 else if ($this->mpdf
->listlvl %
3 == 0 && $this->mpdf
->_charDefined($this->mpdf
->CurrentFont
['cw'], 9642)) {
1610 $blt = "\xe2\x96\xaa";
1618 // change to spaces
1619 if ($this->mpdf
->usingCoreFont
) {
1620 $ls = str_repeat(chr(160) . chr(160), ($this->mpdf
->listlvl
- 1) * 2) . $blt . ' ';
1622 $ls = str_repeat("\xc2\xa0\xc2\xa0", ($this->mpdf
->listlvl
- 1) * 2) . $blt . ' ';
1624 $this->mpdf
->_saveCellTextBuffer($ls);
1625 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] +
= $this->mpdf
->GetStringWidth($ls);
1630 /* -- END TABLES -- */
1632 if ($this->mpdf
->lastblocklevelchange
== 1) {
1634 } // Top margins/padding only
1635 else if ($this->mpdf
->lastblocklevelchange
< 1) {
1637 } // NO margins/padding
1638 $this->mpdf
->printbuffer($this->mpdf
->textbuffer
, $blockstate);
1639 $this->mpdf
->textbuffer
= array();
1641 $save_blklvl = $this->mpdf
->blklvl
;
1642 $save_blk = $this->mpdf
->blk
;
1644 $this->mpdf
->Reset();
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 -- */
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';
1663 if ($pagesel && (!isset($this->mpdf
->page_box
['current']) ||
$pagesel != $this->mpdf
->page_box
['current'])) {
1664 $pagebreaktype = 'cloneall';
1666 $this->mpdf
->_preForcedPagebreak($pagebreaktype);
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);
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);
1684 /* -- END CSS-PAGE -- */
1686 // mPDF 6 pagebreaktype
1687 $this->mpdf
->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
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;
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;
1707 if ($lastbottommargin && isset($properties['MARGIN-TOP']) && $properties['MARGIN-TOP'] && empty($properties['FLOAT'])) {
1708 $currblk['lastbottommargin'] = $lastbottommargin;
1711 if (isset($properties['Z-INDEX']) && $this->mpdf
->current_layer
== 0) {
1712 $v = intval($properties['Z-INDEX']);
1714 $currblk['z-index'] = $v;
1715 $this->mpdf
->BeginLayer($v);
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) {
1727 $listtype = 'upper-latin';
1730 $listtype = 'lower-latin';
1733 $listtype = 'upper-roman';
1736 $listtype = 'lower-roman';
1739 $listtype = 'decimal';
1742 $currblk['list_style_type'] = $listtype;
1746 $this->mpdf
->setCSS($properties, 'BLOCK', $tag); //name(id/class/style) found in the CSS array!
1747 $currblk['InlineProperties'] = $this->mpdf
->saveInlineProperties();
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);
1758 if (isset($attr['ALIGN']) && $attr['ALIGN']) {
1759 $currblk['block-align'] = $align[strtolower($attr['ALIGN'])];
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
);
1769 $currblk['css_set_height'] = false;
1773 // Added mPDF 3.0 Float DIV
1774 if (isset($prevblk['blockContext'])) {
1775 $currblk['blockContext'] = $prevblk['blockContext'];
1778 if (isset($properties['CLEAR'])) {
1779 $this->mpdf
->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf
->blklvl
- 1);
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'];
1788 if (isset($currblk['css_set_width'])) {
1789 $setwidth = $currblk['css_set_width'];
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;
1801 $this->mpdf
->blockContext++
;
1802 $currblk['blockContext'] = $this->mpdf
->blockContext
;
1804 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf
->GetFloatDivInfo($this->mpdf
->blklvl
- 1);
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);
1815 $this->mpdf
->ClearFloats('BOTH', $this->mpdf
->blklvl
- 1);
1817 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf
->GetFloatDivInfo($this->mpdf
->blklvl
- 1);
1821 $currblk['margin_right'] +
= $r_width;
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']);
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
1834 $currblk['margin_left'] +
= $l_width;
1836 $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] +
$currblk['margin_right'] +
$bdl +
$pdl +
$bdr +
$pdr);
1838 $currblk['float_width'] = ($currblk['css_set_width'] +
$bdl +
$pdl +
$bdr +
$pdr +
$currblk['margin_right']);
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;
1846 $this->mpdf
->blockContext++
;
1847 $currblk['blockContext'] = $this->mpdf
->blockContext
;
1849 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf
->GetFloatDivInfo($this->mpdf
->blklvl
- 1);
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);
1860 $this->mpdf
->ClearFloats('BOTH', $this->mpdf
->blklvl
- 1);
1862 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf
->GetFloatDivInfo($this->mpdf
->blklvl
- 1);
1866 $currblk['margin_left'] +
= $l_width;
1869 $currblk['float'] = 'L';
1870 $currblk['float_start_y'] = $this->mpdf
->y
;
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']);
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
1879 $currblk['margin_right'] +
= $r_width;
1881 $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] +
$currblk['margin_right'] +
$bdl +
$pdl +
$bdr +
$pdr);
1883 $currblk['float_width'] = ($currblk['css_set_width'] +
$bdl +
$pdl +
$bdr +
$pdr +
$currblk['margin_left']);
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);
1896 $this->mpdf
->ClearFloats('BOTH', $this->mpdf
->blklvl
- 1);
1898 list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf
->GetFloatDivInfo($this->mpdf
->blklvl
- 1);
1901 $currblk['padding_right'] = max(($r_width - $currblk['margin_right'] - $bdr), $pdr);
1904 $currblk['padding_left'] = max(($l_width - $currblk['margin_left'] - $bdl), $pdl);
1907 /* -- END CSS-FLOAT -- */
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']);
1917 $this->mpdf
->_borderPadding($currblk['border_radius_TL_V'], $currblk['border_radius_TL_H'], $currblk['padding_top'], $currblk['padding_left']);
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']);
1924 $this->mpdf
->_borderPadding($currblk['border_radius_TR_V'], $currblk['border_radius_TR_H'], $currblk['padding_top'], $currblk['padding_right']);
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']);
1931 $this->mpdf
->_borderPadding($currblk['border_radius_BL_V'], $currblk['border_radius_BL_H'], $currblk['padding_bottom'], $currblk['padding_left']);
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']);
1938 $this->mpdf
->_borderPadding($currblk['border_radius_BR_V'], $currblk['border_radius_BR_H'], $currblk['padding_bottom'], $currblk['padding_right']);
1942 /* -- END BORDER-RADIUS -- */
1945 // Hanging indent - if negative indent: ensure padding is >= indent
1946 if (!isset($currblk['text_indent'])) {
1947 $currblk['text_indent'] = null;
1949 if (!isset($currblk['inner_width'])) {
1950 $currblk['inner_width'] = null;
1952 $cbti = $this->mpdf
->ConvertSize($currblk['text_indent'], $this->mpdf
->blk
[$this->mpdf
->blklvl
]['inner_width'], $this->mpdf
->FontSize
, false);
1954 $hangind = -($cbti);
1955 if (isset($currblk['direction']) && $currblk['direction'] == 'rtl') { // *OTL*
1956 $currblk['padding_right'] = max($currblk['padding_right'], $hangind); // *OTL*
1959 $currblk['padding_left'] = max($currblk['padding_left'], $hangind);
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;
1970 $currblk['margin_left'] = $currblk['margin_right'] = 0;
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;
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;
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*
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;
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'];
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']);
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!"); }
2024 $this->mpdf
->x
= $this->mpdf
->lMargin +
$currblk['outer_left_margin'];
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']);
2030 $currblk['background-image'] = $ret;
2033 /* -- END BACKGROUNDS -- */
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();
2051 /* -- END TABLES -- */
2052 $this->mpdf
->kwt
= false;
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
;
2063 $this->mpdf
->lastblocklevelchange
= 1;
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;
2072 $this->mpdf
->listcounter
[$this->mpdf
->listlvl
] = 0;
2074 $this->mpdf
->listitem
= array();
2077 if (!isset($currblk['list_style_type']) ||
!$currblk['list_style_type']) {
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';
2086 $currblk['list_style_type'] = 'square';
2091 if (!isset($currblk['list_style_image']) ||
!$currblk['list_style_image']) {
2092 $currblk['list_style_image'] = 'none';
2096 if (!isset($currblk['list_style_position']) ||
!$currblk['list_style_position']) {
2097 $currblk['list_style_position'] = 'outside';
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);
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;
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);
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;
2131 $this->mpdf
->listcounter
[$this->mpdf
->listlvl
] ++
;
2132 $this->mpdf
->listitem
= array();
2135 $this->mpdf
->_setListMarker($currblk['list_style_type'], $currblk['list_style_image'], $currblk['list_style_position']);
2138 // mPDF 6 Bidirectional formatting for block elements
2143 // Get current direction
2144 if (isset($currblk['direction'])) {
2145 $currdir = $currblk['direction'];
2149 if (isset($attr['DIR']) and $attr['DIR'] != '') {
2150 $currdir = strtolower($attr['DIR']);
2152 if (isset($properties['DIRECTION'])) {
2153 $currdir = strtolower($properties['DIRECTION']);
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') {
2167 } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') {
2169 $popd = 'FSIPDI'; // U+2068 FSI
2173 $bdf2 = code2utf($bdf);
2175 $this->mpdf
->OTLdata
= array();
2176 if ($this->mpdf
->tableLevel
) {
2177 $this->mpdf
->_saveCellTextBuffer(code2utf($bdf) . $bdf2);
2179 $this->mpdf
->_saveTextBuffer(code2utf($bdf) . $bdf2);
2181 $this->mpdf
->biDirectional
= true;
2182 $currblk['bidicode'] = $popd;
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
);
2196 $this->mpdf
->ignorefollowingspaces
= true;
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);
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);
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'])];
2225 if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
2226 $objattr['align'] = 'R';
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';
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);
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'];
2250 if (isset($attr['WIDTH']) && stristr($attr['WIDTH'], '%')) {
2251 $attr['WIDTH'] +
= 0; //make "90%" become simply "90"
2252 $objattr['W-PERCENT'] = $attr['WIDTH'];
2255 /* -- END TABLES -- */
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";
2261 // Clear properties - tidy up
2262 $properties = array();
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'];
2272 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] = 0; // reset
2273 $this->mpdf
->_saveCellTextBuffer($e, $this->mpdf
->HREF
);
2275 /* -- END TABLES -- */
2276 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
2282 /* -- BARCODES -- */
2285 $this->mpdf
->ignorefollowingspaces
= false;
2286 if (isset($attr['CODE']) && $attr['CODE']) {
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'];
2304 if (isset($attr['TYPE'])) {
2305 $objattr['btype'] = trim(strtoupper($attr['TYPE']));
2307 $objattr['btype'] = 'EAN13';
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];
2317 $objattr['bsupp'] = 0;
2320 if (isset($attr['TEXT']) && $attr['TEXT'] == 1) {
2321 $objattr['showtext'] = 1;
2323 $objattr['showtext'] = 0;
2325 if (isset($attr['SIZE']) && $attr['SIZE'] > 0) {
2326 $objattr['bsize'] = $attr['SIZE'];
2328 $objattr['bsize'] = 1;
2330 if (isset($attr['HEIGHT']) && $attr['HEIGHT'] > 0) {
2331 $objattr['bheight'] = $attr['HEIGHT'];
2333 $objattr['bheight'] = 1;
2335 if (isset($attr['PR']) && $attr['PR'] > 0) {
2336 $objattr['pr_ratio'] = $attr['PR'];
2338 $objattr['pr_ratio'] = '';
2340 $properties = $this->mpdf
->cssmgr
->MergeCSS('', $tag, $attr);
2341 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
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);
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);
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);
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);
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);
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);
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);
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);
2370 if (isset($properties['BORDER-TOP'])) {
2371 $objattr['border_top'] = $this->mpdf
->border_details($properties['BORDER-TOP']);
2373 if (isset($properties['BORDER-BOTTOM'])) {
2374 $objattr['border_bottom'] = $this->mpdf
->border_details($properties['BORDER-BOTTOM']);
2376 if (isset($properties['BORDER-LEFT'])) {
2377 $objattr['border_left'] = $this->mpdf
->border_details($properties['BORDER-LEFT']);
2379 if (isset($properties['BORDER-RIGHT'])) {
2380 $objattr['border_right'] = $this->mpdf
->border_details($properties['BORDER-RIGHT']);
2383 if (isset($properties['VERTICAL-ALIGN'])) {
2384 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
2386 if (isset($properties['COLOR']) && $properties['COLOR'] != '') {
2387 $objattr['color'] = $this->mpdf
->ConvertColor($properties['COLOR']);
2389 $objattr['color'] = false;
2391 if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
2392 $objattr['bgcolor'] = $this->mpdf
->ConvertColor($properties['BACKGROUND-COLOR']);
2394 $objattr['bgcolor'] = false;
2397 if (!class_exists('PDFBarcode', false)) {
2398 include(_MPDF_PATH
. 'classes/barcode.php');
2400 $this->mpdf
->barcode
= new PDFBarcode();
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');
2407 $arrcode = $this->mpdf
->barcode
->getBarcodeArray($code, $objattr['btype']);
2409 if ($arrcode === false) {
2410 throw new MpdfException('Error in barcode string.');
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'];
2417 $w = ($arrcode["maxw"] +
$arrcode['lightmL'] +
$arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize'];
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;
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'];
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.');
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.');
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'];
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'];
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);
2466 /* -- END CSS-IMAGE-FLOAT -- */
2468 $e = "\xbb\xa4\xactype=barcode,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
2470 // Clear properties - tidy up
2471 $properties = array();
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'];
2479 /* -- END TABLES -- */
2480 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
2484 /* -- END BARCODES -- */
2487 // *********** FORM ELEMENTS ********************
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);
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);
2501 if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
2502 $this->mpdf
->selectoption
['SPELLCHECK'] = true;
2505 if (isset($properties['COLOR'])) {
2506 $this->mpdf
->selectoption
['COLOR'] = $this->mpdf
->ConvertColor($properties['COLOR']);
2508 $this->mpdf
->specialcontent
= "type=select";
2509 if (isset($attr['DISABLED'])) {
2510 $this->mpdf
->selectoption
['DISABLED'] = $attr['DISABLED'];
2512 if (isset($attr['READONLY'])) {
2513 $this->mpdf
->selectoption
['READONLY'] = $attr['READONLY'];
2515 if (isset($attr['REQUIRED'])) {
2516 $this->mpdf
->selectoption
['REQUIRED'] = $attr['REQUIRED'];
2518 if (isset($attr['EDITABLE'])) {
2519 $this->mpdf
->selectoption
['EDITABLE'] = $attr['EDITABLE'];
2521 if (isset($attr['TITLE'])) {
2522 $this->mpdf
->selectoption
['TITLE'] = $attr['TITLE'];
2524 if (isset($attr['MULTIPLE'])) {
2525 $this->mpdf
->selectoption
['MULTIPLE'] = $attr['MULTIPLE'];
2527 if (isset($attr['SIZE']) && $attr['SIZE'] > 1) {
2528 $this->mpdf
->selectoption
['SIZE'] = $attr['SIZE'];
2530 if ($this->mpdf
->useActiveForms
) {
2531 if (isset($attr['NAME'])) {
2532 $this->mpdf
->selectoption
['NAME'] = $attr['NAME'];
2534 if (isset($attr['ONCHANGE'])) {
2535 $this->mpdf
->selectoption
['ONCHANGE'] = $attr['ONCHANGE'];
2539 $properties = array();
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'] = '';
2550 if (isset($attr['SELECTED'])) {
2551 $this->mpdf
->selectoption
['SELECTED'] = '';
2552 $this->mpdf
->selectoption
['currentSEL'] = true;
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');
2560 $this->mpdf
->selectoption
['currentVAL'] = $attr['VALUE'];
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;
2578 if (isset($attr['READONLY'])) {
2579 $objattr['readonly'] = true;
2581 if (isset($attr['REQUIRED'])) {
2582 $objattr['required'] = true;
2584 if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
2585 $objattr['spellcheck'] = true;
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');
2592 if ($this->mpdf
->useActiveForms
) {
2593 if (isset($attr['NAME'])) {
2594 $objattr['fieldname'] = $attr['NAME'];
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'];
2603 if (isset($attr['ONVALIDATE'])) {
2604 $objattr['onValidate'] = $attr['ONVALIDATE'];
2606 if (isset($attr['ONKEYSTROKE'])) {
2607 $objattr['onKeystroke'] = $attr['ONKEYSTROKE'];
2609 if (isset($attr['ONFORMAT'])) {
2610 $objattr['onFormat'] = $attr['ONFORMAT'];
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);
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);
2622 if (isset($properties['COLOR'])) {
2623 $objattr['color'] = $this->mpdf
->ConvertColor($properties['COLOR']);
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'])];
2633 if (isset($properties['OVERFLOW']) && strtolower($properties['OVERFLOW']) == 'hidden') {
2634 $objattr['donotscroll'] = true;
2636 if (isset($properties['BORDER-TOP-COLOR'])) {
2637 $objattr['border-col'] = $this->mpdf
->ConvertColor($properties['BORDER-TOP-COLOR']);
2639 if (isset($properties['BACKGROUND-COLOR'])) {
2640 $objattr['background-col'] = $this->mpdf
->ConvertColor($properties['BACKGROUND-COLOR']);
2643 $this->mpdf
->SetLineHeight('', $this->mpdf
->mpdfform
->textarea_lineheight
);
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'])];
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']);
2662 $charsize = $this->mpdf
->GetCharWidth('w', false);
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);
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
);
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;
2676 $this->mpdf
->specialcontent
= serialize($objattr);
2678 if ($this->mpdf
->tableLevel
) { // *TABLES*
2679 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] +
= $objattr['width']; // *TABLES*
2681 // Clear properties - tidy up
2682 $properties = array();
2687 // *********** FORM - INPUT ********************
2690 $this->mpdf
->ignorefollowingspaces
= false;
2691 if (!isset($attr['TYPE']))
2692 $attr['TYPE'] == 'TEXT';
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;
2708 if (isset($attr['READONLY'])) {
2709 $objattr['readonly'] = true;
2711 if (isset($attr['REQUIRED'])) {
2712 $objattr['required'] = true;
2714 if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') {
2715 $objattr['spellcheck'] = true;
2717 if (isset($attr['TITLE'])) {
2718 $objattr['title'] = $attr['TITLE'];
2719 } else if (isset($attr['ALT'])) {
2720 $objattr['title'] = $attr['ALT'];
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'];
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'];
2740 $this->mpdf
->InlineProperties
[$tag] = $this->mpdf
->saveInlineProperties();
2741 $properties = $this->mpdf
->cssmgr
->MergeCSS('', $tag, $attr);
2742 $objattr['vertical-align'] = '';
2744 if (isset($properties['FONT-FAMILY'])) {
2745 $this->mpdf
->SetFont($properties['FONT-FAMILY'], $this->mpdf
->FontStyle
, 0, false);
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);
2751 if (isset($properties['COLOR'])) {
2752 $objattr['color'] = $this->mpdf
->ConvertColor($properties['COLOR']);
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'])];
2762 if (isset($properties['BORDER-TOP-COLOR'])) {
2763 $objattr['border-col'] = $this->mpdf
->ConvertColor($properties['BORDER-TOP-COLOR']);
2765 if (isset($properties['BACKGROUND-COLOR'])) {
2766 $objattr['background-col'] = $this->mpdf
->ConvertColor($properties['BACKGROUND-COLOR']);
2772 $height = $this->mpdf
->FontSize
;
2774 $spacesize = $this->mpdf
->GetCharWidth(' ', false);
2777 if (isset($properties['WIDTH']))
2778 $w = $this->mpdf
->ConvertSize($properties['WIDTH'], $this->mpdf
->blk
[$this->mpdf
->blklvl
]['inner_width']);
2780 if ($properties['VERTICAL-ALIGN']) {
2781 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
2784 switch (strtoupper($attr['TYPE'])) {
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);
2790 if ($this->mpdf
->InlineProperties
[$tag]) {
2791 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
[$tag]);
2793 unset($this->mpdf
->InlineProperties
[$tag]);
2795 case 'CHECKBOX': //Draw Checkbox
2797 if (isset($attr['CHECKED'])) {
2798 $objattr['checked'] = true;
2800 $objattr['checked'] = false;
2802 $width = $this->mpdf
->FontSize
;
2803 $height = $this->mpdf
->FontSize
;
2806 case 'RADIO': //Draw Radio button
2808 if (isset($attr['CHECKED']))
2809 $objattr['checked'] = true;
2810 $width = $this->mpdf
->FontSize
;
2811 $height = $this->mpdf
->FontSize
;
2814 /* -- IMAGES-CORE -- */
2815 case 'IMAGE': // Draw an Image button
2816 if (isset($attr['SRC'])) {
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);
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);
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);
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);
2835 if (isset($properties['BORDER-TOP'])) {
2836 $objattr['border_top'] = $this->mpdf
->border_details($properties['BORDER-TOP']);
2838 if (isset($properties['BORDER-BOTTOM'])) {
2839 $objattr['border_bottom'] = $this->mpdf
->border_details($properties['BORDER-BOTTOM']);
2841 if (isset($properties['BORDER-LEFT'])) {
2842 $objattr['border_left'] = $this->mpdf
->border_details($properties['BORDER-LEFT']);
2844 if (isset($properties['BORDER-RIGHT'])) {
2845 $objattr['border_right'] = $this->mpdf
->border_details($properties['BORDER-RIGHT']);
2848 $objattr['padding_top'] = 0;
2849 $objattr['padding_bottom'] = 0;
2850 $objattr['padding_left'] = 0;
2851 $objattr['padding_right'] = 0;
2853 if (isset($properties['VERTICAL-ALIGN'])) {
2854 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
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']);
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'];
2868 $info = $this->mpdf
->_getImage($srcpath, true, true, $orig_srcpath);
2870 $info = $this->mpdf
->_getImage($this->mpdf
->noImageFile
);
2872 $srcpath = $this->mpdf
->noImageFile
;
2873 $w = ($info['w'] * (25.4 / $this->mpdf
->dpi
));
2874 $h = ($info['h'] * (25.4 / $this->mpdf
->dpi
));
2879 if ($info['cs'] == 'Indexed') {
2880 $objattr['Indexed'] = true;
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
);
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
;
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
);
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)) {
2910 $w *= $this->mpdf
->img_dpi
/ $dpi;
2911 $h *= $this->mpdf
->img_dpi
/ $dpi;
2916 // IF WIDTH OR HEIGHT SPECIFIED
2918 $w = $h * $info['w'] / $info['h'];
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
;
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'];
2931 if ($h +
$extraheight > $maxHeight) {
2932 $h = $maxHeight - $extraheight;
2933 $w = $h * $info['w'] / $info['h'];
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'];
2946 /* -- END IMAGES-WMF -- */
2947 if ($info['type'] == 'svg') {
2948 $objattr['wmf_x'] = $info['x'];
2949 $objattr['wmf_y'] = $info['y'];
2951 $objattr['height'] = $h +
$extraheight;
2952 $objattr['width'] = $w +
$extrawidth;
2954 $objattr['image_height'] = $h;
2955 $objattr['image_width'] = $w;
2956 $objattr['ID'] = $info['i'];
2958 if ($this->mpdf
->useActiveForms
) {
2959 if (isset($attr['ONCLICK'])) {
2960 $objattr['onClick'] = $attr['ONCLICK'];
2962 $objattr['type'] = 'input';
2967 /* -- END IMAGES-CORE -- */
2969 case 'BUTTON': // Draw a button
2972 $type = strtoupper($attr['TYPE']);
2973 if ($type == 'IMAGE') {
2975 } // src path not found
2976 if (isset($attr['NOPRINT'])) {
2977 $objattr['noprint'] = true;
2979 if (!isset($attr['VALUE'])) {
2980 $objattr['value'] = ucfirst(strtolower($type));
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'];
2999 if (strtoupper($attr['TYPE']) == 'PASSWORD') {
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);
3007 $texto = $attr['VALUE'];
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);
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'];
3028 if (isset($attr['ONVALIDATE'])) {
3029 $objattr['onValidate'] = $attr['ONVALIDATE'];
3031 if (isset($attr['ONKEYSTROKE'])) {
3032 $objattr['onKeystroke'] = $attr['ONKEYSTROKE'];
3034 if (isset($attr['ONFORMAT'])) {
3035 $objattr['onFormat'] = $attr['ONFORMAT'];
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";
3047 // Clear properties - tidy up
3048 $properties = array();
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'];
3056 /* -- END TABLES -- */
3057 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
3060 if ($this->mpdf
->InlineProperties
[$tag]) {
3061 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
[$tag]);
3063 unset($this->mpdf
->InlineProperties
[$tag]);
3065 break; // END of INPUT
3066 /* -- END FORMS -- */
3069 // *********** GRAPH ********************
3071 if (!$this->mpdf
->useGraphs
) {
3074 if ($attr['TABLE']) {
3075 $gid = strtoupper($attr['TABLE']);
3079 if (!is_array($this->mpdf
->graphs
[$gid]) ||
count($this->mpdf
->graphs
[$gid]) == 0) {
3082 $this->mpdf
->ignorefollowingspaces
= false;
3083 include_once(_MPDF_PATH
. 'graph.php');
3084 $this->mpdf
->graphs
[$gid]['attr'] = $attr;
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']);
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']);
3094 $graph_img = print_graph($this->mpdf
->graphs
[$gid], $this->mpdf
->blk
[$this->mpdf
->blklvl
]['inner_width']);
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;
3103 $attr['SRC'] = $graph_img['file'];
3104 $attr['WIDTH'] = $graph_img['w'];
3105 $attr['HEIGHT'] = $graph_img['h'];
3110 // *********** IMAGE ********************
3111 /* -- IMAGES-CORE -- */
3113 $this->mpdf
->ignorefollowingspaces
= false;
3114 if ($this->mpdf
->progressBar
) {
3115 $this->mpdf
->UpdateProgressBar(1, '', 'IMG');
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') {
3139 if (isset($properties['Z-INDEX']) && $this->mpdf
->current_layer
== 0) {
3140 $v = intval($properties['Z-INDEX']);
3142 $objattr['z-index'] = $v;
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;
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);
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);
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);
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);
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);
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);
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);
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);
3181 if (isset($properties['BORDER-TOP'])) {
3182 $objattr['border_top'] = $this->mpdf
->border_details($properties['BORDER-TOP']);
3184 if (isset($properties['BORDER-BOTTOM'])) {
3185 $objattr['border_bottom'] = $this->mpdf
->border_details($properties['BORDER-BOTTOM']);
3187 if (isset($properties['BORDER-LEFT'])) {
3188 $objattr['border_left'] = $this->mpdf
->border_details($properties['BORDER-LEFT']);
3190 if (isset($properties['BORDER-RIGHT'])) {
3191 $objattr['border_right'] = $this->mpdf
->border_details($properties['BORDER-RIGHT']);
3194 if (isset($properties['VERTICAL-ALIGN'])) {
3195 $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
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);
3225 if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
3226 $objattr['opacity'] = $properties['OPACITY'];
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];
3236 $objattr['link'] = $this->mpdf
->HREF
;
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'];
3242 // mPDF 5.7.3 TRANSFORMS
3243 if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
3244 $objattr['bgcolor'] = $this->mpdf
->ConvertColor($properties['BACKGROUND-COLOR']);
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'];
3251 /* -- END BACKGROUNDS -- */
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
;
3265 $interpolation = false;
3267 $info['interpolation'] = $interpolation;
3271 $info = $this->mpdf
->_getImage($srcpath, true, true, $orig_srcpath, $interpolation); // mPDF 6
3273 $info = $this->mpdf
->_getImage($this->mpdf
->noImageFile
);
3275 $srcpath = $this->mpdf
->noImageFile
;
3276 $w = ($info['w'] * (25.4 / $this->mpdf
->dpi
));
3277 $h = ($info['h'] * (25.4 / $this->mpdf
->dpi
));
3283 if (isset($attr['ROTATE'])) {
3284 $image_orientation = $attr['ROTATE'];
3285 } else if (isset($properties['IMAGE-ORIENTATION'])) {
3286 $image_orientation = $properties['IMAGE-ORIENTATION'];
3288 $image_orientation = 0;
3290 if ($image_orientation) {
3291 if ($image_orientation == 90 ||
$image_orientation == -90 ||
$image_orientation == 270) {
3293 $info['w'] = $info['h'];
3296 $objattr['ROTATE'] = $image_orientation;
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
);
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
;
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
);
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)) {
3327 $w *= $this->mpdf
->img_dpi
/ $dpi;
3328 $h *= $this->mpdf
->img_dpi
/ $dpi;
3333 // IF WIDTH OR HEIGHT SPECIFIED
3335 $w = abs($h * $info['w'] / $info['h']);
3337 $h = abs($w * $info['h'] / $info['w']);
3339 if ($minw && $w < $minw) {
3341 $h = abs($w * $info['h'] / $info['w']);
3343 if ($maxw && $w > $maxw) {
3345 $h = abs($w * $info['h'] / $info['w']);
3347 if ($minh && $h < $minh) {
3349 $w = abs($h * $info['w'] / $info['h']);
3351 if ($maxh && $h > $maxh) {
3353 $w = abs($h * $info['w'] / $info['h']);
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
;
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']);
3367 if ($h +
$extraheight > $maxHeight) {
3368 $h = $maxHeight - $extraheight;
3369 $w = abs($h * $info['w'] / $info['h']);
3371 $objattr['type'] = 'image';
3372 $objattr['itype'] = $info['type'];
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'];
3381 /* -- END IMAGES-WMF -- */
3382 if ($info['type'] == 'svg') {
3383 $objattr['wmf_x'] = $info['x'];
3384 $objattr['wmf_y'] = $info['y'];
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);
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'];
3402 $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
3404 // Clear properties - tidy up
3405 $properties = array();
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'];
3413 /* -- END TABLES -- */
3414 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
3416 /* -- ANNOTATIONS -- */
3417 if ($this->mpdf
->title2annots
&& isset($attr['TITLE'])) {
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*
3443 $this->mpdf
->textbuffer
[] = array($e);
3446 /* -- END ANNOTATIONS -- */
3449 /* -- END IMAGES-CORE -- */
3452 // *********** CIRCULAR TEXT = TEXTCIRCLE ********************
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;
3475 $this->mpdf
->InlineProperties
[$tag] = $this->mpdf
->saveInlineProperties();
3476 $properties = $this->mpdf
->cssmgr
->MergeCSS('INLINE', $tag, $attr);
3478 if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') {
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);
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');
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');
3496 if (isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) {
3497 $objattr['space-width'] = $attr['SPACE-WIDTH'];
3499 if (isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) {
3500 $objattr['char-width'] = $attr['CHAR-WIDTH'];
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;
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;
3516 $objattr['fontsize'] = -1;
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
;
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');
3531 if (isset($properties['COLOR'])) {
3532 $objattr['color'] = $this->mpdf
->ConvertColor($properties['COLOR']);
3535 $objattr['fontstyle'] = '';
3536 if (isset($properties['FONT-WEIGHT'])) {
3537 if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
3538 $objattr['fontstyle'] .= 'B';
3541 if (isset($properties['FONT-STYLE'])) {
3542 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
3543 $objattr['fontstyle'] .= 'I';
3547 if (isset($properties['FONT-FAMILY'])) {
3548 $this->mpdf
->SetFont($properties['FONT-FAMILY'], $this->mpdf
->FontStyle
, 0, false);
3550 $objattr['fontfamily'] = $this->mpdf
->FontFamily
;
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);
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);
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);
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);
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);
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);
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);
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);
3579 if (isset($properties['BORDER-TOP'])) {
3580 $objattr['border_top'] = $this->mpdf
->border_details($properties['BORDER-TOP']);
3582 if (isset($properties['BORDER-BOTTOM'])) {
3583 $objattr['border_bottom'] = $this->mpdf
->border_details($properties['BORDER-BOTTOM']);
3585 if (isset($properties['BORDER-LEFT'])) {
3586 $objattr['border_left'] = $this->mpdf
->border_details($properties['BORDER-LEFT']);
3588 if (isset($properties['BORDER-RIGHT'])) {
3589 $objattr['border_right'] = $this->mpdf
->border_details($properties['BORDER-RIGHT']);
3592 if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) {
3593 $objattr['opacity'] = $properties['OPACITY'];
3595 if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') {
3596 $objattr['bgcolor'] = $this->mpdf
->ConvertColor($properties['BACKGROUND-COLOR']);
3598 $objattr['bgcolor'] = false;
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];
3608 $objattr['link'] = $this->mpdf
->HREF
;
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'];
3615 $w = $objattr['r'] * 2;
3617 $objattr['height'] = $h +
$extraheight;
3618 $objattr['width'] = $w +
$extrawidth;
3619 $objattr['type'] = 'textcircle';
3621 $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
3623 // Clear properties - tidy up
3624 $properties = array();
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'];
3632 /* -- END TABLES -- */
3633 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
3636 if ($this->mpdf
->InlineProperties
[$tag]) {
3637 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
[$tag]);
3639 unset($this->mpdf
->InlineProperties
[$tag]);
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
= '';
3653 if ($this->mpdf
->lastblocklevelchange
== 1) {
3655 } // Top margins/padding only
3656 else if ($this->mpdf
->lastblocklevelchange
< 1) {
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);
3667 $this->mpdf
->textbuffer
= array();
3668 $this->mpdf
->lastblocklevelchange
= -1;
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
;
3680 $this->mpdf
->tableLevel++
;
3681 $this->mpdf
->cssmgr
->tbCSSlvl++
;
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
;
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'];
3695 if (isset($this->mpdf
->tbctr
[$this->mpdf
->tableLevel
])) {
3696 $this->mpdf
->tbctr
[$this->mpdf
->tableLevel
] ++
;
3698 $this->mpdf
->tbctr
[$this->mpdf
->tableLevel
] = 1;
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
];
3704 if ($this->mpdf
->tableLevel
> $this->mpdf
->innermostTableLevel
) {
3705 $this->mpdf
->innermostTableLevel
= $this->mpdf
->tableLevel
;
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)]);
3710 //++++++++++++++++++++++++++++
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
]];
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;
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;
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
;
3771 $lastbottommargin = 0;
3773 $this->mpdf
->lastblockbottommargin
= 0;
3774 $this->mpdf
->blockjustfinished
= false;
3776 if ($this->mpdf
->tableLevel
== 1) {
3777 $table['headernrows'] = 0;
3778 $table['footernrows'] = 0;
3779 $this->mpdf
->base_table_properties
= array();
3782 // ADDED CSS FUNCIONS FOR TABLE
3783 if ($this->mpdf
->cssmgr
->tbCSSlvl
== 1) {
3784 $properties = $this->mpdf
->cssmgr
->MergeCSS('TOPTABLE', $tag, $attr);
3786 $properties = $this->mpdf
->cssmgr
->MergeCSS('TABLE', $tag, $attr);
3790 if (isset($properties['WIDTH'])) {
3791 $w = $properties['WIDTH'];
3792 } else if (isset($attr['WIDTH']) && $attr['WIDTH']) {
3793 $w = $attr['WIDTH'];
3796 if (isset($attr['ALIGN']) && isset($align[strtolower($attr['ALIGN'])])) {
3797 $table['a'] = $align[strtolower($attr['ALIGN'])];
3800 if ($table['direction'] == 'rtl') {
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'];
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'];
3823 if (isset($properties['VERTICAL-ALIGN']) && isset($align[strtolower($properties['VERTICAL-ALIGN'])])) {
3824 $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])];
3826 if (isset($properties['TEXT-ALIGN']) && isset($align[strtolower($properties['TEXT-ALIGN'])])) {
3827 $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])];
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;
3836 if (isset($properties['ROTATE']) && $properties['ROTATE'] && $this->mpdf
->tableLevel
== 1) {
3837 $this->mpdf
->table_rotate
= $properties['ROTATE'];
3839 if (isset($properties['TOPNTAIL'])) {
3840 $table['topntail'] = $properties['TOPNTAIL'];
3842 if (isset($properties['THEAD-UNDERLINE'])) {
3843 $table['thead-underline'] = $properties['THEAD-UNDERLINE'];
3846 if (isset($properties['BORDER'])) {
3847 $bord = $this->mpdf
->border_details($properties['BORDER']);
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;
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*
3861 $table['border_details']['R'] = $this->mpdf
->border_details($properties['BORDER-RIGHT']);
3863 $this->mpdf
->setBorder($table['border'], _BORDER_RIGHT
, $table['border_details']['R']['s']);
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*
3870 $table['border_details']['L'] = $this->mpdf
->border_details($properties['BORDER-LEFT']);
3872 $this->mpdf
->setBorder($table['border'], _BORDER_LEFT
, $table['border_details']['L']['s']);
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']);
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']);
3882 if ($table['border']) {
3883 $this->mpdf
->table_border_css_set
= 1;
3885 $this->mpdf
->table_border_css_set
= 0;
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;
3898 $this->mpdf
->currentLang
= $properties['LANG'];
3902 if (isset($properties['FONT-FAMILY'])) {
3903 $this->mpdf
->default_font
= $properties['FONT-FAMILY'];
3904 $this->mpdf
->SetFont($this->mpdf
->default_font
, '', 0, false);
3906 $this->mpdf
->base_table_properties
['FONT-FAMILY'] = $this->mpdf
->FontFamily
;
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']);
3912 $mmsize = $this->mpdf
->ConvertSize($properties['FONT-SIZE'], $this->mpdf
->default_font_size
/ _MPDFK
);
3915 $this->mpdf
->default_font_size
= $mmsize * (_MPDFK
);
3916 $this->mpdf
->SetFontSize($this->mpdf
->default_font_size
, false);
3919 $this->mpdf
->base_table_properties
['FONT-SIZE'] = $this->mpdf
->FontSize
. 'mm';
3921 if (isset($properties['FONT-WEIGHT'])) {
3922 if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') {
3923 $this->mpdf
->base_table_properties
['FONT-WEIGHT'] = 'BOLD';
3926 if (isset($properties['FONT-STYLE'])) {
3927 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
3928 $this->mpdf
->base_table_properties
['FONT-STYLE'] = 'ITALIC';
3931 if (isset($properties['COLOR'])) {
3932 $this->mpdf
->base_table_properties
['COLOR'] = $properties['COLOR'];
3934 if (isset($properties['FONT-KERNING'])) {
3935 $this->mpdf
->base_table_properties
['FONT-KERNING'] = $properties['FONT-KERNING'];
3937 if (isset($properties['LETTER-SPACING'])) {
3938 $this->mpdf
->base_table_properties
['LETTER-SPACING'] = $properties['LETTER-SPACING'];
3940 if (isset($properties['WORD-SPACING'])) {
3941 $this->mpdf
->base_table_properties
['WORD-SPACING'] = $properties['WORD-SPACING'];
3944 if (isset($properties['HYPHENS'])) {
3945 $this->mpdf
->base_table_properties
['HYPHENS'] = $properties['HYPHENS'];
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'];
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'];
3958 $table['cellLineStackingStrategy'] = 'inline-line-height';
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'];
3966 $table['cellLineStackingShift'] = 'consider-shifts';
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);
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);
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);
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);
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;
3988 $properties['MARGIN-TOP'] = 0;
3991 $table['margin']['T'] = $this->mpdf
->ConvertSize($properties['MARGIN-TOP'], $this->mpdf
->blk
[$this->mpdf
->blklvl
]['inner_width'], $this->mpdf
->FontSize
, false);
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);
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);
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);
4004 if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT']) == 'auto' && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
4006 } else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') {
4008 } else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') {
4012 if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE']) == 'SEPARATE') {
4013 $table['borders_separate'] = true;
4015 $table['borders_separate'] = false;
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);
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);
4027 if (!$table['borders_separate']) {
4028 $table['border_spacing_H'] = $table['border_spacing_V'] = 0;
4031 if (isset($properties['EMPTY-CELLS'])) {
4032 $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show'
4034 $table['empty_cells'] = '';
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;
4042 if (isset($properties['PAGE-BREAK-AFTER']) && $this->mpdf
->tableLevel
== 1) {
4043 $table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
4046 /* -- BACKGROUNDS -- */
4047 if (isset($properties['BACKGROUND-GRADIENT']) && !$this->mpdf
->kwt
&& !$this->mpdf
->ColActive
) {
4048 $table['gradient'] = $properties['BACKGROUND-GRADIENT'];
4051 if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf
->kwt
&& !$this->mpdf
->ColActive
) {
4052 $ret = $this->mpdf
->SetBackground($properties, $currblk['inner_width']);
4054 $table['background-image'] = $ret;
4057 /* -- END BACKGROUNDS -- */
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']);
4066 $properties = array();
4069 if (isset($attr['CELLPADDING'])) {
4070 $table['cell_padding'] = $attr['CELLPADDING'];
4072 $table['cell_padding'] = false;
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');
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;
4086 $this->mpdf
->table_border_attr_set
= 0;
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;
4094 $tblblw = $table['margin']['L'] +
$table['margin']['R'] +
$table['max_cell_border_width']['L'] / 2 +
$table['max_cell_border_width']['R'] / 2;
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;
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
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;
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'];
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;
4122 if (isset($attr['ROTATE']) && $this->mpdf
->tableLevel
== 1) {
4123 $this->mpdf
->table_rotate
= $attr['ROTATE'];
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();
4135 if ($this->mpdf
->kwt
) {
4136 if ($this->mpdf
->table_rotate
) {
4137 $this->mpdf
->table_keep_together
= true;
4139 $this->mpdf
->kwt
= false;
4140 $this->mpdf
->kwt_saved
= true;
4143 if ($this->mpdf
->tableLevel
== 1 && $this->mpdf
->useGraphs
) {
4144 if (isset($attr['ID']) && $attr['ID']) {
4145 $this->mpdf
->currentGraphId
= strtoupper($attr['ID']);
4147 $this->mpdf
->currentGraphId
= '0';
4149 $this->mpdf
->graphs
[$this->mpdf
->currentGraphId
] = array();
4151 //++++++++++++++++++++++++++++
4152 $this->mpdf
->plainCell_properties
= array();
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';
4166 $this->mpdf
->thead_font_weight
= '';
4170 if (isset($properties['FONT-STYLE'])) {
4171 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
4172 $this->mpdf
->thead_font_style
= 'I';
4174 $this->mpdf
->thead_font_style
= '';
4177 if (isset($properties['FONT-VARIANT'])) {
4178 if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') {
4179 $this->mpdf
->thead_font_smCaps
= 'S';
4181 $this->mpdf
->thead_font_smCaps
= '';
4185 if (isset($properties['VERTICAL-ALIGN'])) {
4186 $this->mpdf
->thead_valign_default
= $properties['VERTICAL-ALIGN'];
4188 if (isset($properties['TEXT-ALIGN'])) {
4189 $this->mpdf
->thead_textalign_default
= $properties['TEXT-ALIGN'];
4191 $properties = array();
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';
4204 $this->mpdf
->tfoot_font_weight
= '';
4208 if (isset($properties['FONT-STYLE'])) {
4209 if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') {
4210 $this->mpdf
->tfoot_font_style
= 'I';
4212 $this->mpdf
->tfoot_font_style
= '';
4215 if (isset($properties['FONT-VARIANT'])) {
4216 if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') {
4217 $this->mpdf
->tfoot_font_smCaps
= 'S';
4219 $this->mpdf
->tfoot_font_smCaps
= '';
4223 if (isset($properties['VERTICAL-ALIGN'])) {
4224 $this->mpdf
->tfoot_valign_default
= $properties['VERTICAL-ALIGN'];
4226 if (isset($properties['TEXT-ALIGN'])) {
4227 $this->mpdf
->tfoot_textalign_default
= $properties['TEXT-ALIGN'];
4229 $properties = array();
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);
4243 $this->mpdf
->lastoptionaltag
= $tag; // Save current HTML specified optional endtag
4244 $this->mpdf
->cssmgr
->tbCSSlvl++
;
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);
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'];
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'];
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'];
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'];
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'];
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'];
4275 if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf
->kwt
&& !$this->mpdf
->ColActive
) {
4276 $ret = $this->mpdf
->SetBackground($properties, $currblk['inner_width']);
4278 $this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['trbackground-images'][$this->mpdf
->row
] = $ret;
4281 /* -- END BACKGROUNDS -- */
4286 if (isset($properties['TEXT-ROTATE'])) {
4287 $this->mpdf
->trow_text_rotate
= $properties['TEXT-ROTATE'];
4289 if (isset($attr['TEXT-ROTATE']))
4290 $this->mpdf
->trow_text_rotate
= $attr['TEXT-ROTATE'];
4292 if ($this->mpdf
->tablethead
) {
4293 $this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['is_thead'][$this->mpdf
->row
] = true;
4295 if ($this->mpdf
->tabletfoot
) {
4296 $this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['is_tfoot'][$this->mpdf
->row
] = true;
4298 $properties = array();
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;
4312 while (isset($this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
])) {
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;
4321 $table = &$this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]];
4323 $c = array('a' => false,
4327 'padding' => array('L' => false,
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;
4379 $c['va'] = $table['va'];
4381 if ($table['txta']) {
4382 $c['a'] = $table['txta'];
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'];
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);
4414 if ($this->mpdf
->thead_font_style
== 'I') {
4415 $this->mpdf
->SetStyle('I', true);
4417 if ($this->mpdf
->thead_font_smCaps
== 'S') {
4418 $this->mpdf
->textvar
= ($this->mpdf
->textvar | FC_SMALLCAPS
);
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);
4431 if ($this->mpdf
->tfoot_font_style
== 'I') {
4432 $this->mpdf
->SetStyle('I', true);
4434 if ($this->mpdf
->tfoot_font_style
== 'S') {
4435 $this->mpdf
->textvar
= ($this->mpdf
->textvar | FC_SMALLCAPS
);
4440 if ($this->mpdf
->trow_text_rotate
) {
4441 $c['R'] = $this->mpdf
->trow_text_rotate
;
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;
4449 $properties = $this->mpdf
->cssmgr
->MergeCSS('TABLE', $tag, $attr);
4451 $properties = $this->mpdf
->cssmgr
->array_merge_recursive_unique($this->mpdf
->base_table_properties
, $properties);
4453 $this->mpdf
->Reset(); // mPDF 6 ?????????????????????
4455 $this->mpdf
->setCSS($properties, 'TABLECELL', $tag);
4457 $c['dfs'] = $this->mpdf
->FontSize
; // Default Font size
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'];
4469 /* -- BACKGROUNDS -- */
4470 if (isset($properties['BACKGROUND-GRADIENT'])) {
4471 $c['gradient'] = $properties['BACKGROUND-GRADIENT'];
4473 $c['gradient'] = false;
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']);
4479 $c['background-image'] = $ret;
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'])];
4489 if (isset($properties['TEXT-ALIGN']) && $properties['TEXT-ALIGN']) {
4490 if (substr($properties['TEXT-ALIGN'], 0, 1) == 'D') {
4491 $c['a'] = $properties['TEXT-ALIGN'];
4493 $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])];
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
);
4509 $c['a'] = $align[strtolower($attr['ALIGN'])];
4514 $c['direction'] = $table['direction'];
4515 if (isset($attr['DIR']) and $attr['DIR'] != '') {
4516 $c['direction'] = strtolower($attr['DIR']);
4518 if (isset($properties['DIRECTION'])) {
4519 $c['direction'] = strtolower($properties['DIRECTION']);
4523 if (isset($c['direction']) && $c['direction'] == 'rtl') {
4530 $c['cellLineHeight'] = $table['cellLineHeight'];
4531 if (isset($properties['LINE-HEIGHT'])) {
4532 $c['cellLineHeight'] = $this->mpdf
->fixLineheight($properties['LINE-HEIGHT']);
4535 $c['cellLineStackingStrategy'] = $table['cellLineStackingStrategy'];
4536 if (isset($properties['LINE-STACKING-STRATEGY'])) {
4537 $c['cellLineStackingStrategy'] = strtolower($properties['LINE-STACKING-STRATEGY']);
4540 $c['cellLineStackingShift'] = $table['cellLineStackingShift'];
4541 if (isset($properties['LINE-STACKING-SHIFT'])) {
4542 $c['cellLineStackingShift'] = strtolower($properties['LINE-STACKING-SHIFT']);
4545 if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] ||
$properties['TEXT-ROTATE'] === "0")) {
4546 $c['R'] = $properties['TEXT-ROTATE'];
4548 if (isset($properties['BORDER'])) {
4549 $bord = $this->mpdf
->border_details($properties['BORDER']);
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;
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
;
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
;
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
;
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
;
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']);
4595 $table['simple']['border'] = _BORDER_ALL
;
4597 $table['simple']['border'] = 0;
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;
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'];
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']);
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']);
4624 if ($this->mpdf
->packTableData
&& !$this->mpdf
->simpleTables
) {
4625 $c['borderbin'] = $this->mpdf
->_packCellBorder($c);
4626 unset($c['border']);
4627 unset($c['border_details']);
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);
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);
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);
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);
4644 if (isset($properties['WIDTH'])) {
4645 $w = $properties['WIDTH'];
4646 } else if (isset($attr['WIDTH'])) {
4647 $w = $attr['WIDTH'];
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);
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);
4663 if (isset($properties['WHITE-SPACE'])) {
4664 if (strtoupper($properties['WHITE-SPACE']) == 'NOWRAP') {
4668 $properties = array();
4671 if (isset($attr['TEXT-ROTATE'])) {
4672 $c['R'] = $attr['TEXT-ROTATE'];
4674 if (isset($attr['NOWRAP']) && $attr['NOWRAP'])
4677 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
] = $c;
4679 $this->mpdf
->cell
[$this->mpdf
->row
][$this->mpdf
->col
]['s'] = 0;
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;
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;
4701 /* -- END TABLES -- */
4705 function CloseTag($tag, &$ahtml, &$ihtml)
4708 if ($tag == 'OPTION') {
4709 $this->mpdf
->selectoption
['ACTIVE'] = false;
4710 $this->mpdf
->lastoptionaltag
= '';
4713 if ($tag == 'TTS' or $tag == 'TTA' or $tag == 'TTZ') {
4714 if ($this->mpdf
->InlineProperties
[$tag]) {
4715 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
[$tag]);
4717 unset($this->mpdf
->InlineProperties
[$tag]);
4718 $ltag = strtolower($tag);
4719 $this->mpdf
->$ltag = false;
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'
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]);
4733 unset($this->mpdf
->InlineProperties
[$tag]);
4734 if (isset($this->mpdf
->InlineAnnots
[$tag]) && $this->mpdf
->InlineAnnots
[$tag]) {
4735 $annot = $this->mpdf
->InlineAnnots
[$tag];
4737 unset($this->mpdf
->InlineAnnots
[$tag]); // *ANNOTATIONS*
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);
4743 if (isset($this->mpdf
->InlineAnnots
[$tag]) && count($this->mpdf
->InlineAnnots
[$tag])) { // *ANNOTATIONS*
4744 $annot = array_pop($this->mpdf
->InlineAnnots
[$tag]); // *ANNOTATIONS*
4746 if (isset($this->mpdf
->InlineBDF
[$tag]) && count($this->mpdf
->InlineBDF
[$tag])) { // mPDF 6
4747 $bdfarr = array_pop($this->mpdf
->InlineBDF
[$tag]);
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*
4758 $this->mpdf
->textbuffer
[] = array($annot);
4761 /* -- END ANNOTATIONS -- */
4764 // mPDF 6 Bidirectional formatting for inline elements
4766 $popf = $this->mpdf
->_setBidiCodes('end', $bdf);
4767 $this->mpdf
->OTLdata
= array();
4768 if ($this->mpdf
->tableLevel
) {
4769 $this->mpdf
->_saveCellTextBuffer($popf);
4771 $this->mpdf
->_saveTextBuffer($popf);
4774 } // End of (most) Inline elements eg SPAN
4777 if ($tag == 'METER' ||
$tag == 'PROGRESS') {
4778 $this->mpdf
->ignorefollowingspaces
= false;
4779 $this->mpdf
->inMeter
= false;
4784 $this->mpdf
->HREF
= '';
4785 if (isset($this->mpdf
->InlineProperties
['A'])) {
4786 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
['A']);
4788 unset($this->mpdf
->InlineProperties
['A']);
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
;
4800 if (isset($this->mpdf
->InlineProperties
['LEGEND'])) {
4801 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
['LEGEND']);
4803 unset($this->mpdf
->InlineProperties
['LEGEND']);
4804 $this->mpdf
->ignorefollowingspaces
= true; //Eliminate exceeding left-side spaces
4808 // *********** FORM ELEMENTS ********************
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]);
4816 unset($this->mpdf
->InlineProperties
[$tag]);
4820 if ($tag == 'SELECT') {
4821 $this->mpdf
->ignorefollowingspaces
= false;
4822 $this->mpdf
->lastoptionaltag
= '';
4825 if (isset($this->mpdf
->selectoption
['SELECTED'])) {
4826 $texto = $this->mpdf
->selectoption
['SELECTED'];
4828 if (isset($this->mpdf
->selectoption
['SELECTED-OTLDATA'])) {
4829 $OTLdata = $this->mpdf
->selectoption
['SELECTED-OTLDATA'];
4832 if ($this->mpdf
->useActiveForms
) {
4833 $w = $this->mpdf
->selectoption
['MAXWIDTH'];
4835 $w = $this->mpdf
->GetStringWidth($texto, true, $OTLdata);
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'];
4846 if (isset($this->mpdf
->selectoption
['READONLY'])) {
4847 $objattr['readonly'] = true;
4849 if (isset($this->mpdf
->selectoption
['REQUIRED'])) {
4850 $objattr['required'] = true;
4852 if (isset($this->mpdf
->selectoption
['SPELLCHECK'])) {
4853 $objattr['spellcheck'] = true;
4855 if (isset($this->mpdf
->selectoption
['EDITABLE'])) {
4856 $objattr['editable'] = true;
4858 if (isset($this->mpdf
->selectoption
['ONCHANGE'])) {
4859 $objattr['onChange'] = $this->mpdf
->selectoption
['ONCHANGE'];
4861 if (isset($this->mpdf
->selectoption
['ITEMS'])) {
4862 $objattr['items'] = $this->mpdf
->selectoption
['ITEMS'];
4864 if (isset($this->mpdf
->selectoption
['MULTIPLE'])) {
4865 $objattr['multiple'] = $this->mpdf
->selectoption
['MULTIPLE'];
4867 if (isset($this->mpdf
->selectoption
['DISABLED'])) {
4868 $objattr['disabled'] = $this->mpdf
->selectoption
['DISABLED'];
4870 if (isset($this->mpdf
->selectoption
['TITLE'])) {
4871 $objattr['title'] = $this->mpdf
->selectoption
['TITLE'];
4873 if (isset($this->mpdf
->selectoption
['COLOR'])) {
4874 $objattr['color'] = $this->mpdf
->selectoption
['COLOR'];
4876 if (isset($this->mpdf
->selectoption
['SIZE'])) {
4877 $objattr['size'] = $this->mpdf
->selectoption
['SIZE'];
4879 if (isset($objattr['size']) && $objattr['size'] > 1) {
4880 $rows = $objattr['size'];
4885 $objattr['fontfamily'] = $this->mpdf
->FontFamily
;
4886 $objattr['fontsize'] = $this->mpdf
->FontSizePt
;
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";
4892 // Clear properties - tidy up
4893 $properties = array();
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*
4901 $this->mpdf
->_saveTextBuffer($e, $this->mpdf
->HREF
);
4904 $this->mpdf
->selectoption
= array();
4905 $this->mpdf
->specialcontent
= '';
4907 if ($this->mpdf
->InlineProperties
[$tag]) {
4908 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
[$tag]);
4910 unset($this->mpdf
->InlineProperties
[$tag]);
4912 /* -- END FORMS -- */
4915 // *********** BLOCKS ********************
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'
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']);
4926 $this->mpdf
->OTLdata
= array();
4927 if ($this->mpdf
->tableLevel
) {
4928 $this->mpdf
->_saveCellTextBuffer($blockpost);
4930 $this->mpdf
->_saveTextBuffer($blockpost);
4935 $this->mpdf
->ignorefollowingspaces
= true; //Eliminate exceeding left-side spaces
4936 $this->mpdf
->blockjustfinished
= true;
4938 $this->mpdf
->lastblockbottommargin
= $this->mpdf
->blk
[$this->mpdf
->blklvl
]['margin_bottom'];
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
]);
4945 $this->mpdf
->listlvl
--;
4946 $this->mpdf
->listitem
= array();
4949 $this->mpdf
->listitem
= array();
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])) {
4955 if (count($this->mpdf
->textbuffer
) == 1) {
4956 $content = $this->mpdf
->textbuffer
[0][0];
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];
4965 if (isset($this->mpdf
->h2toc
[$tag])) {
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));
4974 /* -- BOOKMARKS -- */
4975 if (isset($this->mpdf
->h2bookmarks
[$tag])) {
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));
4983 /* -- END BOOKMARKS -- */
4988 if ($this->mpdf
->tableLevel
) {
4989 if ($this->mpdf
->linebreakjustfinished
) {
4990 $this->mpdf
->blockjustfinished
= false;
4992 if (isset($this->mpdf
->InlineProperties
['BLOCKINTABLE'])) {
4993 if ($this->mpdf
->InlineProperties
['BLOCKINTABLE']) {
4994 $this->mpdf
->restoreInlineProperties($this->mpdf
->InlineProperties
['BLOCKINTABLE']);
4996 unset($this->mpdf
->InlineProperties
['BLOCKINTABLE']);
4998 if ($tag == 'PRE') {
4999 $this->mpdf
->ispre
= false;
5003 /* -- END TABLES -- */
5004 $this->mpdf
->lastoptionaltag
= '';
5005 $this->mpdf
->divbegin
= false;
5007 $this->mpdf
->linebreakjustfinished
= false;
5009 $this->mpdf
->x
= $this->mpdf
->lMargin +
$this->mpdf
->blk
[$this->mpdf
->blklvl
]['outer_left_margin'];
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();
5027 $this->mpdf
->y
= (($this->mpdf
->blk
[$this->mpdf
->blklvl
]['float_endpos'] * 1000) %
1000000) / 1000; // mod changes operands to integers before processing
5029 /* -- END CSS-FLOAT -- */
5033 if ($this->mpdf
->lastblocklevelchange
== 1) {
5035 } // Top & bottom margins/padding
5036 else if ($this->mpdf
->lastblocklevelchange
== -1) {
5038 } // Bottom margins/padding only
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));
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
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);
5064 $this->mpdf
->printbuffer($this->mpdf
->textbuffer
, $blockstate);
5068 $this->mpdf
->textbuffer
= array();
5070 if ($this->mpdf
->kwt
) {
5071 $this->mpdf
->kwt_height
= $this->mpdf
->y
- $this->mpdf
->kwt_y0
;
5074 /* -- CSS-IMAGE-FLOAT -- */
5075 $this->mpdf
->printfloatbuffer();
5076 /* -- END CSS-IMAGE-FLOAT -- */
5078 if ($tag == 'PRE') {
5079 $this->mpdf
->ispre
= false;
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();
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
));
5096 $this->mpdf
->blk
[$i]['float_endpos'] = $this->mpdf
->page
* 1000 +
$this->mpdf
->y
;
5100 $this->mpdf
->floatDivs
[] = array(
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']
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();
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();
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
));
5131 $this->mpdf
->blk
[$i]['float_endpos'] = $this->mpdf
->page
* 1000 +
$this->mpdf
->y
;
5135 $this->mpdf
->floatDivs
[] = array(
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']
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();
5153 /* -- END CSS-FLOAT -- */
5155 if (isset($this->mpdf
->blk
[$this->mpdf
->blklvl
]['visibility']) && $this->mpdf
->blk
[$this->mpdf
->blklvl
]['visibility'] != 'visible') {
5156 $this->mpdf
->SetVisibility('visible');
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'];
5162 $page_break_after = '';
5166 $this->mpdf
->Reset();
5168 if (isset($this->mpdf
->blk
[$this->mpdf
->blklvl
]['z-index']) && $this->mpdf
->blk
[$this->mpdf
->blklvl
]['z-index'] > 0) {
5169 $this->mpdf
->EndLayer();
5172 // mPDF 6 page-break-inside:avoid
5173 if ($this->mpdf
->blk
[$this->mpdf
->blklvl
]['keep_block_together']) {
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
) {
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]);
5185 if (isset($this->mpdf
->blk
[$this->mpdf
->blklvl
]['marginCorrected'][$i])) {
5186 unset($this->mpdf
->blk
[$this->mpdf
->blklvl
]['marginCorrected'][$i]);
5188 if (isset($this->mpdf
->pageoutput
[$i])) {
5189 unset($this->mpdf
->pageoutput
[$i]);
5192 $this->mpdf
->page
= $this->mpdf
->kt_p00
;
5194 $this->mpdf
->keep_block_together
= 0;
5195 $this->mpdf
->pageoutput
[$this->mpdf
->page
] = array();
5197 $this->mpdf
->y
= $this->mpdf
->kt_y00
;
5198 $ihtml = $this->mpdf
->blk
[$this->mpdf
->blklvl
]['array_i'] - 1;
5200 $ahtml[$ihtml +
1] .= ' pagebreakavoidchecked="true";'; // avoid re-iterating; read in OpenTag()
5202 unset($this->mpdf
->blk
[$this->mpdf
->blklvl
]);
5203 $this->mpdf
->blklvl
--;
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'];
5211 if (isset($this->mpdf
->blk
[$this->mpdf
->blklvl
]['x0'])) {
5212 $this->mpdf
->x
= $this->mpdf
->blk
[$this->mpdf
->blklvl
]['x0'];
5214 $this->mpdf
->x
= $this->mpdf
->lMargin
;
5217 $this->mpdf
->lastblocklevelchange
= 0;
5218 $this->mpdf
->ResetMargins();
5220 $this->mpdf
->AddPage();
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
--;
5230 //else { echo $tag; exit; } // debug - forces error if incorrectly nested html tags
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']);
5239 $this->mpdf
->x
= $this->mpdf
->lMargin +
$this->mpdf
->blk
[$this->mpdf
->blklvl
]['outer_left_margin'];
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';
5255 // mPDF 6 pagebreaktype
5256 $this->mpdf
->_preForcedPagebreak($pagebreaktype);
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);
5263 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
5266 // mPDF 6 pagebreaktype
5267 $this->mpdf
->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
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);
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']);
5280 $this->mpdf
->OTLdata
= array();
5281 if ($this->mpdf
->tableLevel
) {
5282 $this->mpdf
->_saveCellTextBuffer($blockpre);
5284 $this->mpdf
->_saveTextBuffer($blockpre);
5294 $this->mpdf
->SetStyle('B', false);
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
) {
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. </td></td>");
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'];
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']);
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]);
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));
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']));
5336 $this->mpdf
->Reset();
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
];
5344 if ($this->mpdf
->packTableData
) {
5345 $cell = $this->mpdf
->_unpackCellBorder($c['borderbin']);
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']);
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;
5367 if ($tag == 'TBODY') {
5368 $this->mpdf
->lastoptionaltag
= '';
5369 unset($this->mpdf
->cssmgr
->tablecascadeCSS
[$this->mpdf
->cssmgr
->tbCSSlvl
]);
5370 $this->mpdf
->cssmgr
->tbCSSlvl
--;
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
= '';
5384 $this->mpdf
->thead_valign_default
= '';
5385 $this->mpdf
->thead_textalign_default
= '';
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
= '';
5398 $this->mpdf
->tfoot_valign_default
= '';
5399 $this->mpdf
->tfoot_textalign_default
= '';
5402 if ($tag == 'TABLE') { // TABLE-END (
5403 if ($this->mpdf
->progressBar
) {
5404 $this->mpdf
->UpdateProgressBar(1, '', 'TABLE');
5406 if ($this->mpdf
->progressBar
) {
5407 $this->mpdf
->UpdateProgressBar(7, 0, '');
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
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) {
5423 $this->mpdf
->cell
[$k][$l] = array(
5429 'padding' => array('L' => false, 'R' => false, 'T' => false, 'B' => false),
5430 'gradient' => false,
5433 'textbuffer' => array(),
5434 'dfs' => $this->mpdf
->FontSize
,
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']);
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);
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'])) {
5460 foreach ($this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['is_tfoot'] AS $r => $val) {
5467 foreach ($this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['cells'] AS $k => $row) {
5468 if (in_array($k, $tfrows)) {
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;
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);
5484 $this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['cells'] = array_merge($temp, $temptf);
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];
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);
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);
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]
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
]]);
5519 // Fix Borders *********************************************
5520 $this->mpdf
->_fixTableBorders($this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]);
5522 if ($this->mpdf
->progressBar
) {
5523 $this->mpdf
->UpdateProgressBar(7, 10, ' ');
5526 if ($this->mpdf
->ColActive
) {
5527 $this->mpdf
->table_rotate
= 0;
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'];
5536 $this->mpdf
->shrin_k
= 1;
5538 if ($this->mpdf
->shrink_tables_to_fit
< 1) {
5539 $this->mpdf
->shrink_tables_to_fit
= 1;
5541 if (!$this->mpdf
->shrink_this_table_to_fit
) {
5542 $this->mpdf
->shrink_this_table_to_fit
= $this->mpdf
->shrink_tables_to_fit
;
5545 if ($this->mpdf
->tableLevel
> 1) {
5546 // deal with nested table
5548 $this->mpdf
->_tableColumnWidth($this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]], true);
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'];
5554 // Go down to lower table level
5555 $this->mpdf
->tableLevel
--;
5557 // Reset lower level table
5558 $this->mpdf
->base_table_properties
= $this->mpdf
->table
[$this->mpdf
->tableLevel
][$this->mpdf
->tbctr
[$this->mpdf
->tableLevel
]]['baseProperties'];
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);
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']);
5570 unset($this->mpdf
->cell
['PARENTCELL']);
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'];
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'];
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;
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;
5596 $this->mpdf
->tdbegin
= true;
5597 $this->mpdf
->nestedtablejustfinished
= true;
5598 $this->mpdf
->ignorefollowingspaces
= true;
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;
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");
5617 $this->mpdf
->_tableColumnWidth($this->mpdf
->table
[1][1], true);
5618 $this->mpdf
->_tableWidth($this->mpdf
->table
[1][1]);
5620 if (!$this->mpdf
->kwt_saved
) {
5621 $this->mpdf
->kwt_height
= 0;
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;
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;
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
5640 $reset_to_minimum_width = true;
5643 if ($reset_to_minimum_width) {
5644 $this->mpdf
->shrin_k
= $check;
5646 $this->mpdf
->default_font_size
/= $this->mpdf
->shrin_k
;
5647 $this->mpdf
->SetFontSize($this->mpdf
->default_font_size
, false);
5649 $this->mpdf
->shrinkTable($this->mpdf
->table
[1][1], $this->mpdf
->shrin_k
);
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);
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']);
5667 $this->mpdf
->_tableWidth($this->mpdf
->table
[1][1]);
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
5676 list($parentrow, $parentcol, $parentnid) = $this->mpdf
->table
[$lvl][$nid]['nestedpos'];
5678 $c = & $this->mpdf
->table
[($lvl - 1)][$parentnid]['cells'][$parentrow][$parentcol];
5680 if (isset($c['colspan']) && $c['colspan'] > 1) {
5682 for ($cs = 0; $cs < $c['colspan']; $cs++
) {
5683 $parentwidth +
= $this->mpdf
->table
[($lvl - 1)][$parentnid]['wc'][$parentcol +
$cs];
5686 $parentwidth = $this->mpdf
->table
[($lvl - 1)][$parentnid]['wc'][$parentcol];
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']);
5695 $br = $c['border_details']['R']['w'];
5696 $bl = $c['border_details']['L']['w'];
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'];
5701 $parentwidth -= $br / 2 +
$bl / 2 +
$c['padding']['L'] +
$c['padding']['R'];
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'];
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'];
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'];
5715 $this->mpdf
->table
[$lvl][$nid]['w'] = $parentwidth;
5718 $this->mpdf
->_tableWidth($this->mpdf
->table
[$lvl][$nid]);
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]);
5729 if ($this->mpdf
->progressBar
) {
5730 $this->mpdf
->UpdateProgressBar(7, 20, ' ');
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");
5736 if ($maxfirstrowheight > $remainingpage) {
5737 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
);
5744 while (!$finished) {
5745 list($finished, $r, $c, $p, $y, $y0) = $this->mpdf
->_tableWrite($this->mpdf
->table
[1][1], true, $r, $c, $p, $y);
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;
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;
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
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;
5787 if ($this->mpdf
->y
!= $this->mpdf
->tMargin
) {
5788 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
);
5789 $this->mpdf
->kwt_moved
= 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);
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);
5800 if ($this->mpdf
->y
!= $this->mpdf
->tMargin
) {
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
);
5807 $this->mpdf
->kwt_moved
= true;
5810 $this->mpdf
->tbrot_maxw
= $this->mpdf
->h
- ($this->mpdf
->y +
$this->mpdf
->bMargin +
5) - $this->mpdf
->kwt_height
;
5811 $recalculate = 1.001;
5820 if ($recalculate > $this->mpdf
->shrink_this_table_to_fit
&& !$forcerecalc) {
5821 $recalculate = $this->mpdf
->shrink_this_table_to_fit
;
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
);
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
);
5845 $this->mpdf
->_tableColumnWidth($this->mpdf
->table
[$lvl][$nid], false);
5848 // Set table cell widths for top level table
5850 $this->mpdf
->_tableWidth($this->mpdf
->table
[1][1]);
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
5858 list($parentrow, $parentcol, $parentnid) = $this->mpdf
->table
[$lvl][$nid]['nestedpos'];
5859 $c = & $this->mpdf
->table
[($lvl - 1)][$parentnid]['cells'][$parentrow][$parentcol];
5861 if (isset($c['colspan']) && $c['colspan'] > 1) {
5863 for ($cs = 0; $cs < $c['colspan']; $cs++
) {
5864 $parentwidth +
= $this->mpdf
->table
[($lvl - 1)][$parentnid]['wc'][$parentcol +
$cs];
5867 $parentwidth = $this->mpdf
->table
[($lvl - 1)][$parentnid]['wc'][$parentcol];
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']);
5875 $br = $c['border_details']['R']['w'];
5876 $bl = $c['border_details']['L']['w'];
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'];
5881 $parentwidth -= $br / 2 +
$bl / 2 +
$c['padding']['L'] +
$c['padding']['R'];
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'];
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'];
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'];
5895 $this->mpdf
->table
[$lvl][$nid]['w'] = $parentwidth;
5898 $this->mpdf
->_tableWidth($this->mpdf
->table
[$lvl][$nid]);
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]);
5910 // RESIZING ALGORITHM
5912 if ($maxrowheight > $fullpage) {
5913 $recalculate = $this->mpdf
->tbsqrt($maxrowheight / $fullpage, $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);
5922 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
);
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
;
5927 // 0.001 to force it to recalculate
5928 $recalculate = (1 / $this->mpdf
->shrin_k
) +
0.001; // undo any shrink
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);
5935 } else if ($this->mpdf
->tableMinSizePriority
) {
5936 $this->mpdf
->table_keep_together
= false;
5937 $recalculate = (1 / $this->mpdf
->shrin_k
) +
0.001;
5939 if (!$added_page && $this->mpdf
->y
!= $this->mpdf
->tMargin
) {
5940 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
);
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
;
5945 $recalculate = $this->mpdf
->tbsqrt($tableheight / $fullpage, $iteration);
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);
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
);
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
;
5966 //$recalculate = $this->mpdf->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
5967 $recalculate = (1 / $this->mpdf
->shrin_k
) +
0.001; // undo any shrink
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;
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;
5990 if ($this->mpdf
->progressBar
) {
5991 $this->mpdf
->UpdateProgressBar(7, 30, ' ');
5993 // Recursively writes all tables starting at top level
5994 $this->mpdf
->_tableWrite($this->mpdf
->table
[1][1]);
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);
6005 $this->mpdf
->table_rotate
= $save_tr;
6006 $this->mpdf
->y
= $save_y;
6008 $this->mpdf
->printtablebuffer();
6010 $this->mpdf
->table_rotate
= 0;
6014 $this->mpdf
->x
= $this->mpdf
->lMargin +
$this->mpdf
->blk
[$this->mpdf
->blklvl
]['outer_left_margin'];
6016 $this->mpdf
->maxPosR
= max($this->mpdf
->maxPosR
, ($this->mpdf
->x +
$this->mpdf
->table
[1][1]['w']));
6018 $this->mpdf
->blockjustfinished
= true;
6019 $this->mpdf
->lastblockbottommargin
= $this->mpdf
->table
[1][1]['margin']['B'];
6022 if (isset($this->mpdf
->table
[1][1]['page_break_after'])) {
6023 $page_break_after = $this->mpdf
->table
[1][1]['page_break_after'];
6025 $page_break_after = '';
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;
6039 $this->mpdf
->kwt_Reference
= array();
6040 $this->mpdf
->kwt_BMoutlines
= array();
6041 $this->mpdf
->kwt_toc
= array();
6043 $this->mpdf
->shrin_k
= 1;
6044 $this->mpdf
->shrink_this_table_to_fit
= 0;
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();
6054 unset($this->mpdf
->cell
);
6055 $this->mpdf
->cell
= array(); //array
6057 $this->mpdf
->col
= -1; //int
6058 $this->mpdf
->row
= -1; //int
6059 $this->mpdf
->Reset();
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']);
6077 if ($this->mpdf
->progressBar
) {
6078 $this->mpdf
->UpdateProgressBar(7, 100, ' ');
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';
6095 // mPDF 6 pagebreaktype
6096 $this->mpdf
->_preForcedPagebreak($pagebreaktype);
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);
6103 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0);
6106 // mPDF 6 pagebreaktype
6107 $this->mpdf
->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
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);
6115 /* -- END TABLES -- */