mpdf = $mpdf; } function OpenTag($tag, $attr, &$ahtml, &$ihtml) { // mPDF 6 //Opening tag // mPDF 6 // Correct for tags where HTML5 specifies optional end tags excluding table elements (cf WriteHTML() ) if ($this->mpdf->allow_html_optional_endtags) { if (isset($this->mpdf->blk[$this->mpdf->blklvl]['tag'])) { $closed = false; // li end tag may be omitted if immediately followed by another li element if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'LI' && $tag == 'LI') { $this->CloseTag('LI', $ahtml, $ihtml); $closed = true; } // dt end tag may be omitted if immediately followed by another dt element or a dd element if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'DT' && ($tag == 'DT' || $tag == 'DD')) { $this->CloseTag('DT', $ahtml, $ihtml); $closed = true; } // dd end tag may be omitted if immediately followed by another dd element or a dt element if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'DD' && ($tag == 'DT' || $tag == 'DD')) { $this->CloseTag('DD', $ahtml, $ihtml); $closed = true; } // p end tag may be omitted if immediately followed by an address, article, aside, blockquote, div, dl, fieldset, form, // h1, h2, h3, h4, h5, h6, hgroup, hr, main, nav, ol, p, pre, section, table, ul 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')) { $this->CloseTag('P', $ahtml, $ihtml); $closed = true; } // option end tag may be omitted if immediately followed by another option element (or if it is immediately followed by an optgroup element) if (!$closed && $this->mpdf->blk[$this->mpdf->blklvl]['tag'] == 'OPTION' && $tag == 'OPTION') { $this->CloseTag('OPTION', $ahtml, $ihtml); $closed = true; } // Table elements - see also WriteHTML() if (!$closed && ($tag == 'TD' || $tag == 'TH') && $this->mpdf->lastoptionaltag == 'TD') { $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml); $closed = true; } // *TABLES* if (!$closed && ($tag == 'TD' || $tag == 'TH') && $this->mpdf->lastoptionaltag == 'TH') { $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml); $closed = true; } // *TABLES* if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TR') { $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml); $closed = true; } // *TABLES* if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TD') { $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml); $this->CloseTag('TR', $ahtml, $ihtml); $this->CloseTag('THEAD', $ahtml, $ihtml); $closed = true; } // *TABLES* if (!$closed && $tag == 'TR' && $this->mpdf->lastoptionaltag == 'TH') { $this->CloseTag($this->mpdf->lastoptionaltag, $ahtml, $ihtml); $this->CloseTag('TR', $ahtml, $ihtml); $this->CloseTag('THEAD', $ahtml, $ihtml); $closed = true; } // *TABLES* } } $align = array('left' => 'L', 'center' => 'C', 'right' => 'R', 'top' => 'T', 'text-top' => 'TT', 'middle' => 'M', 'baseline' => 'BS', 'bottom' => 'B', 'text-bottom' => 'TB', 'justify' => 'J'); switch ($tag) { case 'DOTTAB': $objattr = array(); $objattr['type'] = 'dottab'; $dots = str_repeat('.', 3) . " "; // minimum number of dots $objattr['width'] = $this->mpdf->GetStringWidth($dots); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['height'] = 0; $objattr['colorarray'] = $this->mpdf->colorarray; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['vertical_align'] = 'BS'; // mPDF 6 DOTTAB $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr); if (isset($properties['OUTDENT'])) { $objattr['outdent'] = $this->mpdf->ConvertSize($properties['OUTDENT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } else if (isset($attr['OUTDENT'])) { $objattr['outdent'] = $this->mpdf->ConvertSize($attr['OUTDENT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } else { $objattr['outdent'] = 0; } $objattr['fontfamily'] = $this->mpdf->FontFamily; $objattr['fontsize'] = $this->mpdf->FontSizePt; $e = "\xbb\xa4\xactype=dottab,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; /* -- TABLES -- */ // Output it to buffers if ($this->mpdf->tableLevel) { if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset $this->mpdf->_saveCellTextBuffer($e); } else { /* -- END TABLES -- */ $this->mpdf->_saveTextBuffer($e); } // *TABLES* break; case 'PAGEHEADER': case 'PAGEFOOTER': $this->mpdf->ignorefollowingspaces = true; if ($attr['NAME']) { $pname = $attr['NAME']; } else { $pname = '_nonhtmldefault'; } // mPDF 6 $p = array(); // mPDF 6 $p['L'] = array(); $p['C'] = array(); $p['R'] = array(); $p['L']['font-style'] = ''; $p['C']['font-style'] = ''; $p['R']['font-style'] = ''; if (isset($attr['CONTENT-LEFT'])) { $p['L']['content'] = $attr['CONTENT-LEFT']; } if (isset($attr['CONTENT-CENTER'])) { $p['C']['content'] = $attr['CONTENT-CENTER']; } if (isset($attr['CONTENT-RIGHT'])) { $p['R']['content'] = $attr['CONTENT-RIGHT']; } if (isset($attr['HEADER-STYLE']) || isset($attr['FOOTER-STYLE'])) { // font-family,size,weight,style,color if ($tag == 'PAGEHEADER') { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE']); } else { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE']); } if (isset($properties['FONT-FAMILY'])) { $p['L']['font-family'] = $properties['FONT-FAMILY']; $p['C']['font-family'] = $properties['FONT-FAMILY']; $p['R']['font-family'] = $properties['FONT-FAMILY']; } if (isset($properties['FONT-SIZE'])) { $p['L']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK; $p['C']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK; $p['R']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK; } if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') { $p['L']['font-style'] = 'B'; $p['C']['font-style'] = 'B'; $p['R']['font-style'] = 'B'; } if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') { $p['L']['font-style'] .= 'I'; $p['C']['font-style'] .= 'I'; $p['R']['font-style'] .= 'I'; } if (isset($properties['COLOR'])) { $p['L']['color'] = $properties['COLOR']; $p['C']['color'] = $properties['COLOR']; $p['R']['color'] = $properties['COLOR']; } } if (isset($attr['HEADER-STYLE-LEFT']) || isset($attr['FOOTER-STYLE-LEFT'])) { if ($tag == 'PAGEHEADER') { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-LEFT']); } else { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-LEFT']); } if (isset($properties['FONT-FAMILY'])) { $p['L']['font-family'] = $properties['FONT-FAMILY']; } if (isset($properties['FONT-SIZE'])) { $p['L']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK; } if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') { $p['L']['font-style'] = 'B'; } if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') { $p['L']['font-style'] .='I'; } if (isset($properties['COLOR'])) { $p['L']['color'] = $properties['COLOR']; } } if (isset($attr['HEADER-STYLE-CENTER']) || isset($attr['FOOTER-STYLE-CENTER'])) { if ($tag == 'PAGEHEADER') { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-CENTER']); } else { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-CENTER']); } if (isset($properties['FONT-FAMILY'])) { $p['C']['font-family'] = $properties['FONT-FAMILY']; } if (isset($properties['FONT-SIZE'])) { $p['C']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK; } if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') { $p['C']['font-style'] = 'B'; } if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') { $p['C']['font-style'] .= 'I'; } if (isset($properties['COLOR'])) { $p['C']['color'] = $properties['COLOR']; } } if (isset($attr['HEADER-STYLE-RIGHT']) || isset($attr['FOOTER-STYLE-RIGHT'])) { if ($tag == 'PAGEHEADER') { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['HEADER-STYLE-RIGHT']); } else { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['FOOTER-STYLE-RIGHT']); } if (isset($properties['FONT-FAMILY'])) { $p['R']['font-family'] = $properties['FONT-FAMILY']; } if (isset($properties['FONT-SIZE'])) { $p['R']['font-size'] = $this->mpdf->ConvertSize($properties['FONT-SIZE']) * _MPDFK; } if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT'] == 'bold') { $p['R']['font-style'] = 'B'; } if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE'] == 'italic') { $p['R']['font-style'] .= 'I'; } if (isset($properties['COLOR'])) { $p['R']['color'] = $properties['COLOR']; } } if (isset($attr['LINE']) && $attr['LINE']) { // 0|1|on|off if ($attr['LINE'] == '1' || strtoupper($attr['LINE']) == 'ON') { $lineset = 1; } else { $lineset = 0; } $p['line'] = $lineset; } // mPDF 6 if ($tag == 'PAGEHEADER') { $this->mpdf->DefHeaderByName($pname, $p); } else { $this->mpdf->DefFooterByName($pname, $p); } break; case 'SETPAGEHEADER': // mPDF 6 case 'SETPAGEFOOTER': case 'SETHTMLPAGEHEADER': case 'SETHTMLPAGEFOOTER': $this->mpdf->ignorefollowingspaces = true; if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; } else if ($tag == 'SETPAGEHEADER' || $tag == 'SETPAGEFOOTER') { $pname = '_nonhtmldefault'; } // mPDF 6 else { $pname = '_default'; } if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank] if (strtoupper($attr['PAGE']) == 'O' || strtoupper($attr['PAGE']) == 'ODD') { $side = 'odd'; } else if (strtoupper($attr['PAGE']) == 'E' || strtoupper($attr['PAGE']) == 'EVEN') { $side = 'even'; } else if (strtoupper($attr['PAGE']) == 'ALL') { $side = 'both'; } else { $side = 'odd'; } } else { $side = 'odd'; } if (isset($attr['VALUE']) && $attr['VALUE']) { // -1|1|on|off if ($attr['VALUE'] == '1' || strtoupper($attr['VALUE']) == 'ON') { $set = 1; } else if ($attr['VALUE'] == '-1' || strtoupper($attr['VALUE']) == 'OFF') { $set = 0; } else { $set = 1; } } else { $set = 1; } if (isset($attr['SHOW-THIS-PAGE']) && $attr['SHOW-THIS-PAGE'] && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) { $write = 1; } else { $write = 0; } if ($side == 'odd' || $side == 'both') { if ($set && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) { $this->mpdf->SetHTMLHeader($this->mpdf->pageHTMLheaders[$pname], 'O', $write); } else if ($set && ($tag == 'SETHTMLPAGEFOOTER' || $tag == 'SETPAGEFOOTER')) { $this->mpdf->SetHTMLFooter($this->mpdf->pageHTMLfooters[$pname], 'O'); } else if ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER') { $this->mpdf->SetHTMLHeader('', 'O'); } else { $this->mpdf->SetHTMLFooter('', 'O'); } } if ($side == 'even' || $side == 'both') { if ($set && ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER')) { $this->mpdf->SetHTMLHeader($this->mpdf->pageHTMLheaders[$pname], 'E', $write); } else if ($set && ($tag == 'SETHTMLPAGEFOOTER' || $tag == 'SETPAGEFOOTER')) { $this->mpdf->SetHTMLFooter($this->mpdf->pageHTMLfooters[$pname], 'E'); } else if ($tag == 'SETHTMLPAGEHEADER' || $tag == 'SETPAGEHEADER') { $this->mpdf->SetHTMLHeader('', 'E'); } else { $this->mpdf->SetHTMLFooter('', 'E'); } } break; /* -- TOC -- */ case 'TOC': //added custom-tag - set Marker for insertion later of ToC if (!class_exists('tocontents', false)) { include(_MPDF_PATH . 'classes/tocontents.php'); } if (empty($this->mpdf->tocontents)) { $this->mpdf->tocontents = new tocontents($this); } $this->mpdf->tocontents->openTagTOC($attr); break; case 'TOCPAGEBREAK': // custom-tag - set Marker for insertion later of ToC AND adds PAGEBREAK if (!class_exists('tocontents', false)) { include(_MPDF_PATH . 'classes/tocontents.php'); } if (empty($this->mpdf->tocontents)) { $this->mpdf->tocontents = new tocontents($this->mpdf); } list($isbreak, $toc_id) = $this->mpdf->tocontents->openTagTOCPAGEBREAK($attr); if ($isbreak) break; if (!isset($attr['RESETPAGENUM']) || $attr['RESETPAGENUM'] < 1) { $attr['RESETPAGENUM'] = 1; } // mPDF 6 // No break - continues as PAGEBREAK... /* -- END TOC -- */ case 'PAGE_BREAK': //custom-tag case 'PAGEBREAK': //custom-tag case 'NEWPAGE': //custom-tag case 'FORMFEED': //custom-tag if (isset($attr['SHEET-SIZE'])) { // Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h) $prop = preg_split('/\s+/', trim($attr['SHEET-SIZE'])); if (count($prop) == 2) { $newformat = array($this->mpdf->ConvertSize($prop[0]), $this->mpdf->ConvertSize($prop[1])); } else { $newformat = $attr['SHEET-SIZE']; } } else { $newformat = ''; } $save_blklvl = $this->mpdf->blklvl; $save_blk = $this->mpdf->blk; $save_silp = $this->mpdf->saveInlineProperties(); $save_ilp = $this->mpdf->InlineProperties; $save_bflp = $this->mpdf->InlineBDF; $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6 $mgr = $mgl = $mgt = $mgb = $mgh = $mgf = ''; if (isset($attr['MARGIN-RIGHT'])) { $mgr = $this->mpdf->ConvertSize($attr['MARGIN-RIGHT'], $this->mpdf->w, $this->mpdf->FontSize, false); } if (isset($attr['MARGIN-LEFT'])) { $mgl = $this->mpdf->ConvertSize($attr['MARGIN-LEFT'], $this->mpdf->w, $this->mpdf->FontSize, false); } if (isset($attr['MARGIN-TOP'])) { $mgt = $this->mpdf->ConvertSize($attr['MARGIN-TOP'], $this->mpdf->w, $this->mpdf->FontSize, false); } if (isset($attr['MARGIN-BOTTOM'])) { $mgb = $this->mpdf->ConvertSize($attr['MARGIN-BOTTOM'], $this->mpdf->w, $this->mpdf->FontSize, false); } if (isset($attr['MARGIN-HEADER'])) { $mgh = $this->mpdf->ConvertSize($attr['MARGIN-HEADER'], $this->mpdf->w, $this->mpdf->FontSize, false); } if (isset($attr['MARGIN-FOOTER'])) { $mgf = $this->mpdf->ConvertSize($attr['MARGIN-FOOTER'], $this->mpdf->w, $this->mpdf->FontSize, false); } $ohname = $ehname = $ofname = $efname = ''; if (isset($attr['ODD-HEADER-NAME'])) { $ohname = $attr['ODD-HEADER-NAME']; } if (isset($attr['EVEN-HEADER-NAME'])) { $ehname = $attr['EVEN-HEADER-NAME']; } if (isset($attr['ODD-FOOTER-NAME'])) { $ofname = $attr['ODD-FOOTER-NAME']; } if (isset($attr['EVEN-FOOTER-NAME'])) { $efname = $attr['EVEN-FOOTER-NAME']; } $ohvalue = $ehvalue = $ofvalue = $efvalue = 0; if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '1' || strtoupper($attr['ODD-HEADER-VALUE']) == 'ON')) { $ohvalue = 1; } else if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '-1' || strtoupper($attr['ODD-HEADER-VALUE']) == 'OFF')) { $ohvalue = -1; } if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '1' || strtoupper($attr['EVEN-HEADER-VALUE']) == 'ON')) { $ehvalue = 1; } else if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '-1' || strtoupper($attr['EVEN-HEADER-VALUE']) == 'OFF')) { $ehvalue = -1; } if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '1' || strtoupper($attr['ODD-FOOTER-VALUE']) == 'ON')) { $ofvalue = 1; } else if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '-1' || strtoupper($attr['ODD-FOOTER-VALUE']) == 'OFF')) { $ofvalue = -1; } if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '1' || strtoupper($attr['EVEN-FOOTER-VALUE']) == 'ON')) { $efvalue = 1; } else if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '-1' || strtoupper($attr['EVEN-FOOTER-VALUE']) == 'OFF')) { $efvalue = -1; } if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'L' || strtoupper($attr['ORIENTATION']) == 'LANDSCAPE')) { $orient = 'L'; } else if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) == 'P' || strtoupper($attr['ORIENTATION']) == 'PORTRAIT')) { $orient = 'P'; } else { $orient = $this->mpdf->CurOrientation; } if (isset($attr['PAGE-SELECTOR']) && $attr['PAGE-SELECTOR']) { $pagesel = $attr['PAGE-SELECTOR']; } else { $pagesel = ''; } // mPDF 6 pagebreaktype $pagebreaktype = $this->mpdf->defaultPagebreakType; if ($tag == 'FORMFEED') { $pagebreaktype = 'slice'; } // can be overridden by PAGE-BREAK-TYPE $startpage = $this->mpdf->page; if (isset($attr['PAGE-BREAK-TYPE'])) { if (strtolower($attr['PAGE-BREAK-TYPE']) == 'cloneall' || strtolower($attr['PAGE-BREAK-TYPE']) == 'clonebycss' || strtolower($attr['PAGE-BREAK-TYPE']) == 'slice') { $pagebreaktype = strtolower($attr['PAGE-BREAK-TYPE']); } } if ($tag == 'TOCPAGEBREAK') { $pagebreaktype = 'cloneall'; } else if ($this->mpdf->ColActive) { $pagebreaktype = 'cloneall'; } // Any change in headers/footers (may need to _getHtmlHeight), or page size/orientation, @page selector, or margins - force cloneall else if ($mgr !== '' || $mgl !== '' || $mgt !== '' || $mgb !== '' || $mgh !== '' || $mgf !== '' || $ohname !== '' || $ehname !== '' || $ofname !== '' || $efname !== '' || $ohvalue || $ehvalue || $ofvalue || $efvalue || $orient != $this->mpdf->CurOrientation || $newformat || $pagesel) { $pagebreaktype = 'cloneall'; } // mPDF 6 pagebreaktype $this->mpdf->_preForcedPagebreak($pagebreaktype); $this->mpdf->ignorefollowingspaces = true; $resetpagenum = ''; $pagenumstyle = ''; $suppress = ''; if (isset($attr['RESETPAGENUM'])) { $resetpagenum = $attr['RESETPAGENUM']; } if (isset($attr['PAGENUMSTYLE'])) { $pagenumstyle = $attr['PAGENUMSTYLE']; } if (isset($attr['SUPPRESS'])) { $suppress = $attr['SUPPRESS']; } if ($tag == 'TOCPAGEBREAK') { $type = 'NEXT-ODD'; } else if (isset($attr['TYPE'])) { $type = strtoupper($attr['TYPE']); } else { $type = ''; } if ($type == 'E' || $type == 'EVEN') { $this->mpdf->AddPage($orient, 'E', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat); } else if ($type == 'O' || $type == 'ODD') { $this->mpdf->AddPage($orient, 'O', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat); } else if ($type == 'NEXT-ODD') { $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); } else if ($type == 'NEXT-EVEN') { $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); } else { $this->mpdf->AddPage($orient, '', $resetpagenum, $pagenumstyle, $suppress, $mgl, $mgr, $mgt, $mgb, $mgh, $mgf, $ohname, $ehname, $ofname, $efname, $ohvalue, $ehvalue, $ofvalue, $efvalue, $pagesel, $newformat); } /* -- TOC -- */ if ($tag == 'TOCPAGEBREAK') { if ($toc_id) { $this->mpdf->tocontents->m_TOC[$toc_id]['TOCmark'] = $this->mpdf->page; } else { $this->mpdf->tocontents->TOCmark = $this->mpdf->page; } } /* -- END TOC -- */ // mPDF 6 pagebreaktype $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl); $this->mpdf->InlineProperties = $save_ilp; $this->mpdf->InlineBDF = $save_bflp; $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6 $this->mpdf->restoreInlineProperties($save_silp); break; /* -- TOC -- */ case 'TOCENTRY': if (isset($attr['CONTENT']) && $attr['CONTENT']) { $objattr = array(); $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES); $objattr['type'] = 'toc'; $objattr['vertical-align'] = 'T'; if (isset($attr['LEVEL']) && $attr['LEVEL']) { $objattr['toclevel'] = $attr['LEVEL']; } else { $objattr['toclevel'] = 0; } if (isset($attr['NAME']) && $attr['NAME']) { $objattr['toc_id'] = $attr['NAME']; } else { $objattr['toc_id'] = 0; } $e = "\xbb\xa4\xactype=toc,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; if ($this->mpdf->tableLevel) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); } // *TABLES* else { // *TABLES* $this->mpdf->textbuffer[] = array($e); } // *TABLES* } break; /* -- END TOC -- */ /* -- INDEX -- */ case 'INDEXENTRY': if (isset($attr['CONTENT']) && $attr['CONTENT']) { if (isset($attr['XREF']) && $attr['XREF']) { $this->mpdf->IndexEntry(htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES), $attr['XREF']); break; } $objattr = array(); $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES); $objattr['type'] = 'indexentry'; $objattr['vertical-align'] = 'T'; $e = "\xbb\xa4\xactype=indexentry,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; if ($this->mpdf->tableLevel) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); } // *TABLES* else { // *TABLES* $this->mpdf->textbuffer[] = array($e); } // *TABLES* } break; case 'INDEXINSERT': if (isset($attr['COLLATION'])) { $indexCollationLocale = $attr['COLLATION']; } else { $indexCollationLocale = ''; } if (isset($attr['COLLATION-GROUP'])) { $indexCollationGroup = $attr['COLLATION-GROUP']; } else { $indexCollationGroup = ''; } if (isset($attr['USEDIVLETTERS']) && (strtoupper($attr['USEDIVLETTERS']) == 'OFF' || $attr['USEDIVLETTERS'] == -1 || $attr['USEDIVLETTERS'] === '0')) { $usedivletters = 0; } else { $usedivletters = 1; } if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' || $attr['LINKS'] == 1)) { $links = true; } else { $links = false; } $this->mpdf->InsertIndex($usedivletters, $links, $indexCollationLocale, $indexCollationGroup); break; /* -- END INDEX -- */ /* -- WATERMARK -- */ case 'WATERMARKTEXT': if (isset($attr['CONTENT']) && $attr['CONTENT']) { $txt = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES); } else { $txt = ''; } if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) { $alpha = $attr['ALPHA']; } else { $alpha = -1; } $this->mpdf->SetWatermarkText($txt, $alpha); break; case 'WATERMARKIMAGE': if (isset($attr['SRC'])) { $src = $attr['SRC']; } else { $src = ''; } if (isset($attr['ALPHA']) && $attr['ALPHA'] > 0) { $alpha = $attr['ALPHA']; } else { $alpha = -1; } if (isset($attr['SIZE']) && $attr['SIZE']) { $size = $attr['SIZE']; if (strpos($size, ',')) { $size = explode(',', $size); } } else { $size = 'D'; } if (isset($attr['POSITION']) && $attr['POSITION']) { // mPDF 5.7.2 $pos = $attr['POSITION']; if (strpos($pos, ',')) { $pos = explode(',', $pos); } } else { $pos = 'P'; } $this->mpdf->SetWatermarkImage($src, $alpha, $size, $pos); break; /* -- END WATERMARK -- */ /* -- BOOKMARKS -- */ case 'BOOKMARK': if (isset($attr['CONTENT'])) { $objattr = array(); $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES); $objattr['type'] = 'bookmark'; if (isset($attr['LEVEL']) && $attr['LEVEL']) { $objattr['bklevel'] = $attr['LEVEL']; } else { $objattr['bklevel'] = 0; } $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; if ($this->mpdf->tableLevel) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); } // *TABLES* else { // *TABLES* $this->mpdf->textbuffer[] = array($e); } // *TABLES* } break; /* -- END BOOKMARKS -- */ /* -- ANNOTATIONS -- */ case 'ANNOTATION': //if (isset($attr['CONTENT']) && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) { // Stops annotations in FixedPos if (isset($attr['CONTENT'])) { $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES); $objattr['type'] = 'annot'; $objattr['POPUP'] = ''; } else { break; } if (isset($attr['POS-X'])) { $objattr['POS-X'] = $attr['POS-X']; } else { $objattr['POS-X'] = 0; } if (isset($attr['POS-Y'])) { $objattr['POS-Y'] = $attr['POS-Y']; } else { $objattr['POS-Y'] = 0; } if (isset($attr['ICON'])) { $objattr['ICON'] = $attr['ICON']; } else { $objattr['ICON'] = 'Note'; } if (isset($attr['AUTHOR'])) { $objattr['AUTHOR'] = $attr['AUTHOR']; } else if (isset($attr['TITLE'])) { $objattr['AUTHOR'] = $attr['TITLE']; } else { $objattr['AUTHOR'] = ''; } if (isset($attr['FILE'])) { $objattr['FILE'] = $attr['FILE']; } else { $objattr['FILE'] = ''; } if (isset($attr['SUBJECT'])) { $objattr['SUBJECT'] = $attr['SUBJECT']; } else { $objattr['SUBJECT'] = ''; } if (isset($attr['OPACITY']) && $attr['OPACITY'] > 0 && $attr['OPACITY'] <= 1) { $objattr['OPACITY'] = $attr['OPACITY']; } else if ($this->mpdf->annotMargin) { $objattr['OPACITY'] = 1; } else { $objattr['OPACITY'] = $this->mpdf->annotOpacity; } if (isset($attr['COLOR'])) { $cor = $this->mpdf->ConvertColor($attr['COLOR']); if ($cor) { $objattr['COLOR'] = $cor; } else { $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow'); } } else { $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow'); } if (isset($attr['POPUP']) && !empty($attr['POPUP'])) { $pop = preg_split('/\s+/', trim($attr['POPUP'])); if (count($pop) > 1) { $objattr['POPUP'] = $pop; } else { $objattr['POPUP'] = true; } } $e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; if ($this->mpdf->tableLevel) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); } // *TABLES* else { // *TABLES* $this->mpdf->textbuffer[] = array($e); } // *TABLES* break; /* -- END ANNOTATIONS -- */ /* -- COLUMNS -- */ case 'COLUMNS': //added custom-tag if (isset($attr['COLUMN-COUNT']) && ($attr['COLUMN-COUNT'] || $attr['COLUMN-COUNT'] === '0')) { // Close any open block tags for ($b = $this->mpdf->blklvl; $b > 0; $b--) { $this->CloseTag($this->mpdf->blk[$b]['tag'], $ahtml, $ihtml); } if (!empty($this->mpdf->textbuffer)) { //Output previously buffered content $this->mpdf->printbuffer($this->mpdf->textbuffer); $this->mpdf->textbuffer = array(); } if (isset($attr['VALIGN']) && $attr['VALIGN']) { if ($attr['VALIGN'] == 'J') { $valign = 'J'; } else { $valign = $align[$attr['VALIGN']]; } } else { $valign = ''; } if (isset($attr['COLUMN-GAP']) && $attr['COLUMN-GAP']) { $this->mpdf->SetColumns($attr['COLUMN-COUNT'], $valign, $attr['COLUMN-GAP']); } else { $this->mpdf->SetColumns($attr['COLUMN-COUNT'], $valign); } } $this->mpdf->ignorefollowingspaces = true; break; case 'COLUMN_BREAK': //custom-tag case 'COLUMNBREAK': //custom-tag case 'NEWCOLUMN': //custom-tag $this->mpdf->ignorefollowingspaces = true; $this->mpdf->NewColumn(); $this->mpdf->ColumnAdjust = false; // disables all column height adjustment for the page. break; /* -- END COLUMNS -- */ case 'TTZ': $this->mpdf->ttz = true; $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); $this->mpdf->setCSS(array('FONT-FAMILY' => 'czapfdingbats', 'FONT-WEIGHT' => 'normal', 'FONT-STYLE' => 'normal'), 'INLINE'); break; case 'TTS': $this->mpdf->tts = true; $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); $this->mpdf->setCSS(array('FONT-FAMILY' => 'csymbol', 'FONT-WEIGHT' => 'normal', 'FONT-STYLE' => 'normal'), 'INLINE'); break; case 'TTA': $this->mpdf->tta = true; $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); if (in_array($this->mpdf->FontFamily, $this->mpdf->mono_fonts)) { $this->mpdf->setCSS(array('FONT-FAMILY' => 'ccourier'), 'INLINE'); } else if (in_array($this->mpdf->FontFamily, $this->mpdf->serif_fonts)) { $this->mpdf->setCSS(array('FONT-FAMILY' => 'ctimes'), 'INLINE'); } else { $this->mpdf->setCSS(array('FONT-FAMILY' => 'chelvetica'), 'INLINE'); } break; // INLINE PHRASES OR STYLES case 'SUB': case 'SUP': case 'ACRONYM': case 'BIG': case 'SMALL': case 'INS': case 'S': case 'STRIKE': case 'DEL': case 'STRONG': case 'CITE': case 'Q': case 'EM': case 'B': case 'I': case 'U': case 'SAMP': case 'CODE': case 'KBD': case 'TT': case 'VAR': case 'FONT': case 'MARK': case 'TIME': case 'BDO': // mPDF 6 case 'BDI': // mPDF 6 case 'SPAN': /* -- ANNOTATIONS -- */ if ($this->mpdf->title2annots && isset($attr['TITLE'])) { $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['CONTENT'] = $attr['TITLE']; $objattr['type'] = 'annot'; $objattr['POS-X'] = 0; $objattr['POS-Y'] = 0; $objattr['ICON'] = 'Comment'; $objattr['AUTHOR'] = ''; $objattr['SUBJECT'] = ''; $objattr['OPACITY'] = $this->mpdf->annotOpacity; $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow'); $annot = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; } /* -- END ANNOTATIONS -- */ // mPDF 5.7.3 Inline tags if (!isset($this->mpdf->InlineProperties[$tag])) { $this->mpdf->InlineProperties[$tag] = array($this->mpdf->saveInlineProperties()); } else { $this->mpdf->InlineProperties[$tag][] = $this->mpdf->saveInlineProperties(); } if (isset($annot)) { // *ANNOTATIONS* if (!isset($this->mpdf->InlineAnnots[$tag])) { $this->mpdf->InlineAnnots[$tag] = array($annot); } // *ANNOTATIONS* else { $this->mpdf->InlineAnnots[$tag][] = $annot; } // *ANNOTATIONS* } // *ANNOTATIONS* $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr); if (!empty($properties)) $this->mpdf->setCSS($properties, 'INLINE'); // mPDF 6 Bidirectional formatting for inline elements $bdf = false; $bdf2 = ''; $popd = ''; // Get current direction if (isset($this->mpdf->blk[$this->mpdf->blklvl]['direction'])) { $currdir = $this->mpdf->blk[$this->mpdf->blklvl]['direction']; } else { $currdir = 'ltr'; } 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') { $currdir = 'rtl'; } if (isset($attr['DIR']) and $attr['DIR'] != '') { $currdir = strtolower($attr['DIR']); } if (isset($properties['DIRECTION'])) { $currdir = strtolower($properties['DIRECTION']); } // mPDF 6 bidi // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi if ($tag == 'BDO') { if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') { $bdf = 0x202E; $popd = 'RLOPDF'; } // U+202E RLO else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') { $bdf = 0x202D; $popd = 'LROPDF'; } // U+202D LRO } else if ($tag == 'BDI') { if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') { $bdf = 0x2067; $popd = 'RLIPDI'; } // U+2067 RLI else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') { $bdf = 0x2066; $popd = 'LRIPDI'; } // U+2066 LRI else { $bdf = 0x2068; $popd = 'FSIPDI'; } // U+2068 FSI } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'bidi-override') { if ($currdir == 'rtl') { $bdf = 0x202E; $popd = 'RLOPDF'; } // U+202E RLO else { $bdf = 0x202D; $popd = 'LROPDF'; } // U+202D LRO } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'embed') { if ($currdir == 'rtl') { $bdf = 0x202B; $popd = 'RLEPDF'; } // U+202B RLE else { $bdf = 0x202A; $popd = 'LREPDF'; } // U+202A LRE } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate') { if ($currdir == 'rtl') { $bdf = 0x2067; $popd = 'RLIPDI'; } // U+2067 RLI else { $bdf = 0x2066; $popd = 'LRIPDI'; } // U+2066 LRI } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'isolate-override') { if ($currdir == 'rtl') { $bdf = 0x2067; $bdf2 = 0x202E; $popd = 'RLIRLOPDFPDI'; } // U+2067 RLI // U+202E RLO else { $bdf = 0x2066; $bdf2 = 0x202D; $popd = 'LRILROPDFPDI'; } // U+2066 LRI // U+202D LRO } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') { $bdf = 0x2068; $popd = 'FSIPDI'; // U+2068 FSI } else { if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'rtl') { $bdf = 0x202B; $popd = 'RLEPDF'; } // U+202B RLE else if (isset($attr['DIR']) and strtolower($attr['DIR']) == 'ltr') { $bdf = 0x202A; $popd = 'LREPDF'; } // U+202A LRE } if ($bdf) { // mPDF 5.7.3 Inline tags if (!isset($this->mpdf->InlineBDF[$tag])) { $this->mpdf->InlineBDF[$tag] = array(array($popd, $this->mpdf->InlineBDFctr)); } else { $this->mpdf->InlineBDF[$tag][] = array($popd, $this->mpdf->InlineBDFctr); } $this->mpdf->InlineBDFctr++; if ($bdf2) { $bdf2 = code2utf($bdf); } $this->mpdf->OTLdata = array(); if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer(code2utf($bdf) . $bdf2); } else { $this->mpdf->_saveTextBuffer(code2utf($bdf) . $bdf2); } $this->mpdf->biDirectional = true; } break; case 'A': if (isset($attr['NAME']) and $attr['NAME'] != '') { $e = ''; /* -- BOOKMARKS -- */ if ($this->mpdf->anchor2Bookmark) { $objattr = array(); $objattr['CONTENT'] = htmlspecialchars_decode($attr['NAME'], ENT_QUOTES); $objattr['type'] = 'bookmark'; if (isset($attr['LEVEL']) && $attr['LEVEL']) { $objattr['bklevel'] = $attr['LEVEL']; } else { $objattr['bklevel'] = 0; } $e = "\xbb\xa4\xactype=bookmark,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; } /* -- END BOOKMARKS -- */ if ($this->mpdf->tableLevel) { // *TABLES* $this->mpdf->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES* } // *TABLES* else { // *TABLES* $this->mpdf->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition) } // *TABLES* } if (isset($attr['HREF'])) { $this->mpdf->InlineProperties['A'] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr); if (!empty($properties)) $this->mpdf->setCSS($properties, 'INLINE'); $this->mpdf->HREF = $attr['HREF']; // mPDF 5.7.4 URLs } break; case 'LEGEND': $this->mpdf->InlineProperties['LEGEND'] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr); if (!empty($properties)) $this->mpdf->setCSS($properties, 'INLINE'); break; case 'PROGRESS': case 'METER': $this->mpdf->inMeter = true; if (isset($attr['MAX']) && $attr['MAX']) { $max = $attr['MAX']; } else { $max = 1; } if (isset($attr['MIN']) && $attr['MIN'] && $tag == 'METER') { $min = $attr['MIN']; } else { $min = 0; } if ($max < $min) { $max = $min; } if (isset($attr['VALUE']) && ($attr['VALUE'] || $attr['VALUE'] === '0')) { $value = $attr['VALUE']; if ($value < $min) { $value = $min; } else if ($value > $max) { $value = $max; } } else { $value = ''; } if (isset($attr['LOW']) && $attr['LOW']) { $low = $attr['LOW']; } else { $low = $min; } if ($low < $min) { $low = $min; } else if ($low > $max) { $low = $max; } if (isset($attr['HIGH']) && $attr['HIGH']) { $high = $attr['HIGH']; } else { $high = $max; } if ($high < $low) { $high = $low; } else if ($high > $max) { $high = $max; } if (isset($attr['OPTIMUM']) && $attr['OPTIMUM']) { $optimum = $attr['OPTIMUM']; } else { $optimum = $min + (($max - $min) / 2); } if ($optimum < $min) { $optimum = $min; } else if ($optimum > $max) { $optimum = $max; } if (isset($attr['TYPE']) && $attr['TYPE']) { $type = $attr['TYPE']; } else { $type = ''; } $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['padding_top'] = 0; $objattr['padding_bottom'] = 0; $objattr['padding_left'] = 0; $objattr['padding_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr); if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') { return; } $objattr['visibility'] = 'visible'; if (isset($properties['VISIBILITY'])) { $v = strtolower($properties['VISIBILITY']); if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') { $objattr['visibility'] = $v; } } if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-TOP'])) { $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']); } if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']); } if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']); } if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); } if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; } $w = 0; $h = 0; if (isset($properties['WIDTH'])) $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['WIDTH'])) $w = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['HEIGHT'])) $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['HEIGHT'])) $h = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; } if ($this->mpdf->HREF) { if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) { $href = $this->mpdf->HREF; while (array_key_exists($href, $this->mpdf->internallink)) $href = "#" . $href; $this->mpdf->internallink[$href] = $this->mpdf->AddLink(); $objattr['link'] = $this->mpdf->internallink[$href]; } else { $objattr['link'] = $this->mpdf->HREF; } } $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w']; $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w']; // Image file if (!class_exists('meter', false)) { include(_MPDF_PATH . 'classes/meter.php'); } $this->mpdf->meter = new meter(); $svg = $this->mpdf->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high); //Save to local file $srcpath = _MPDF_TEMP_PATH . '_tempSVG' . uniqid(rand(1, 100000), true) . '_' . strtolower($tag) . '.svg'; file_put_contents($srcpath, $svg); $orig_srcpath = $srcpath; $this->mpdf->GetFullPath($srcpath); $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath); if (!$info) { $info = $this->mpdf->_getImage($this->mpdf->noImageFile); if ($info) { $srcpath = $this->mpdf->noImageFile; $w = ($info['w'] * (25.4 / $this->mpdf->dpi)); $h = ($info['h'] * (25.4 / $this->mpdf->dpi)); } } if (!$info) break; $objattr['file'] = $srcpath; //Default width and height calculation if needed if ($w == 0 and $h == 0) { // SVG units are pixels $w = $this->mpdf->FontSize / (10 / _MPDFK) * abs($info['w']) / _MPDFK; $h = $this->mpdf->FontSize / (10 / _MPDFK) * abs($info['h']) / _MPDFK; } // IF WIDTH OR HEIGHT SPECIFIED if ($w == 0) $w = abs($h * $info['w'] / $info['h']); if ($h == 0) $h = abs($w * $info['h'] / $info['w']); // Resize to maximum dimensions of page $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']; $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 1); if ($this->mpdf->fullImageHeight) { $maxHeight = $this->mpdf->fullImageHeight; } if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth $w = $maxWidth - $extrawidth; $h = abs($w * $info['h'] / $info['w']); } if ($h + $extraheight > $maxHeight) { $h = $maxHeight - $extraheight; $w = abs($h * $info['w'] / $info['h']); } $objattr['type'] = 'image'; $objattr['itype'] = $info['type']; $objattr['orig_h'] = $info['h']; $objattr['orig_w'] = $info['w']; $objattr['wmf_x'] = $info['x']; $objattr['wmf_y'] = $info['y']; $objattr['height'] = $h + $extraheight; $objattr['width'] = $w + $extrawidth; $objattr['image_height'] = $h; $objattr['image_width'] = $w; $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; $properties = array(); if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF); $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; } else { $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF); } break; case 'BR': // Added mPDF 3.0 Float DIV - CLEAR if (isset($attr['STYLE'])) { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['STYLE']); if (isset($properties['CLEAR'])) { $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl); } // *CSS-FLOAT* } // mPDF 6 bidi // Inline // 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 $blockpre = ''; $blockpost = ''; if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) { $blockpre = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']); $blockpost = $this->mpdf->_setBidiCodes('start', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']); } // Inline // 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 $inlinepre = ''; $inlinepost = ''; $iBDF = array(); if (count($this->mpdf->InlineBDF)) { foreach ($this->mpdf->InlineBDF AS $k => $ib) { foreach ($ib AS $ib2) { $iBDF[$ib2[1]] = $ib2[0]; } } if (count($iBDF)) { ksort($iBDF); for ($i = count($iBDF) - 1; $i >= 0; $i--) { $inlinepre .= $this->mpdf->_setBidiCodes('end', $iBDF[$i]); } for ($i = 0; $i < count($iBDF); $i++) { $inlinepost .= $this->mpdf->_setBidiCodes('start', $iBDF[$i]); } } } /* -- TABLES -- */ if ($this->mpdf->tableLevel) { if ($this->mpdf->blockjustfinished) { $this->mpdf->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost); } $this->mpdf->_saveCellTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost); if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset } else { /* -- END TABLES -- */ if (count($this->mpdf->textbuffer)) { $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0] = preg_replace('/ $/', '', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0]); if (!empty($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18])) { $this->mpdf->otl->trimOTLdata($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18], false, true); } // *OTL* } $this->mpdf->_saveTextBuffer($blockpre . $inlinepre . "\n" . $inlinepost . $blockpost); } // *TABLES* $this->mpdf->ignorefollowingspaces = true; $this->mpdf->blockjustfinished = false; $this->mpdf->linebreakjustfinished = true; break; // *********** BLOCKS ******************** case 'PRE': $this->mpdf->ispre = true; // ADDED - Prevents left trim of textbuffer in printbuffer() case 'DIV': case 'FORM': case 'CENTER': case 'BLOCKQUOTE': case 'ADDRESS': case 'CAPTION': case 'P': case 'H1': case 'H2': case 'H3': case 'H4': case 'H5': case 'H6': case 'DL': case 'DT': case 'DD': case 'UL': // mPDF 6 Lists case 'OL': // mPDF 6 case 'LI': // mPDF 6 case 'FIELDSET': case 'DETAILS': case 'SUMMARY': case 'ARTICLE': case 'ASIDE': case 'FIGURE': case 'FIGCAPTION': case 'FOOTER': case 'HEADER': case 'HGROUP': case 'NAV': case 'SECTION': case 'MAIN': // mPDF 6 Lists $this->mpdf->lastoptionaltag = ''; // mPDF 6 bidi // Block // If unicode-bidi set on current clock, any embedding levels, isolates, or overrides are closed (not inherited) if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) { $blockpost = $this->mpdf->_setBidiCodes('end', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']); if ($blockpost) { $this->mpdf->OTLdata = array(); if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer($blockpost); } else { $this->mpdf->_saveTextBuffer($blockpost); } } } $p = $this->mpdf->cssmgr->PreviewBlockCSS($tag, $attr); if (isset($p['DISPLAY']) && strtolower($p['DISPLAY']) == 'none') { $this->mpdf->blklvl++; $this->mpdf->blk[$this->mpdf->blklvl]['hide'] = true; $this->mpdf->blk[$this->mpdf->blklvl]['tag'] = $tag; // mPDF 6 return; } if ($tag == 'CAPTION') { // position is written in AdjstHTML if (isset($attr['POSITION']) && strtolower($attr['POSITION']) == 'bottom') { $divpos = 'B'; } else { $divpos = 'T'; } if (isset($attr['ALIGN']) && strtolower($attr['ALIGN']) == 'bottom') { $cappos = 'B'; } else if (isset($p['CAPTION-SIDE']) && strtolower($p['CAPTION-SIDE']) == 'bottom') { $cappos = 'B'; } else { $cappos = 'T'; } if (isset($attr['ALIGN'])) { unset($attr['ALIGN']); } if ($cappos != $divpos) { $this->mpdf->blklvl++; $this->mpdf->blk[$this->mpdf->blklvl]['hide'] = true; $this->mpdf->blk[$this->mpdf->blklvl]['tag'] = $tag; // mPDF 6 return; } } /* -- FORMS -- */ if ($tag == 'FORM') { if (isset($attr['METHOD']) && strtolower($attr['METHOD']) == 'get') { $this->mpdf->mpdfform->formMethod = 'GET'; } else { $this->mpdf->mpdfform->formMethod = 'POST'; } if (isset($attr['ACTION'])) { $this->mpdf->mpdfform->formAction = $attr['ACTION']; } else { $this->mpdf->mpdfform->formAction = ''; } } /* -- END FORMS -- */ /* -- CSS-POSITION -- */ if ((isset($p['POSITION']) && (strtolower($p['POSITION']) == 'fixed' || strtolower($p['POSITION']) == 'absolute')) && $this->mpdf->blklvl == 0) { if ($this->mpdf->inFixedPosBlock) { throw new MpdfException("Cannot nest block with position:fixed or position:absolute"); } $this->mpdf->inFixedPosBlock = true; return; } /* -- END CSS-POSITION -- */ // Start Block $this->mpdf->ignorefollowingspaces = true; if ($this->mpdf->blockjustfinished && !count($this->mpdf->textbuffer) && $this->mpdf->y != $this->mpdf->tMargin && $this->mpdf->collapseBlockMargins) { $lastbottommargin = $this->mpdf->lastblockbottommargin; } else { $lastbottommargin = 0; } $this->mpdf->lastblockbottommargin = 0; $this->mpdf->blockjustfinished = false; $this->mpdf->InlineBDF = array(); // mPDF 6 $this->mpdf->InlineBDFctr = 0; // mPDF 6 $this->mpdf->InlineProperties = array(); $this->mpdf->divbegin = true; $this->mpdf->linebreakjustfinished = false; /* -- TABLES -- */ if ($this->mpdf->tableLevel) { // If already something on the line if ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] > 0 && !$this->mpdf->nestedtablejustfinished) { $this->mpdf->_saveCellTextBuffer("\n"); if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset } // Cannot set block properties inside table - use Bold to indicate h1-h6 if ($tag == 'CENTER' && $this->mpdf->tdbegin) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['a'] = $align['center']; } $this->mpdf->InlineProperties['BLOCKINTABLE'] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); if (!empty($properties)) $this->mpdf->setCSS($properties, 'INLINE'); // mPDF 6 Lists if ($tag == 'UL' || $tag == 'OL') { $this->mpdf->listlvl++; if (isset($attr['START'])) { $this->mpdf->listcounter[$this->mpdf->listlvl] = intval($attr['START']) - 1; } else { $this->mpdf->listcounter[$this->mpdf->listlvl] = 0; } $this->mpdf->listitem = array(); if ($tag == 'OL') $this->mpdf->listtype[$this->mpdf->listlvl] = 'decimal'; else if ($tag == 'UL') { if ($this->mpdf->listlvl % 3 == 1) $this->mpdf->listtype[$this->mpdf->listlvl] = 'disc'; elseif ($this->mpdf->listlvl % 3 == 2) $this->mpdf->listtype[$this->mpdf->listlvl] = 'circle'; else $this->mpdf->listtype[$this->mpdf->listlvl] = 'square'; } } // mPDF 6 Lists - in Tables if ($tag == 'LI') { if ($this->mpdf->listlvl == 0) { //in case of malformed HTML code. Example:(...)
Paragraph1
(...) $this->mpdf->listlvl++; // first depth level $this->mpdf->listcounter[$this->mpdf->listlvl] = 0; } $this->mpdf->listcounter[$this->mpdf->listlvl] ++; $this->mpdf->listitem = array(); //if in table - output here as a tabletextbuffer //position:inside OR position:outside (always output in table as position:inside) switch ($this->mpdf->listtype[$this->mpdf->listlvl]) { case 'upper-alpha': case 'upper-latin': case 'A': $blt = $this->mpdf->dec2alpha($this->mpdf->listcounter[$this->mpdf->listlvl], true) . $this->mpdf->list_number_suffix; break; case 'lower-alpha': case 'lower-latin': case 'a': $blt = $this->mpdf->dec2alpha($this->mpdf->listcounter[$this->mpdf->listlvl], false) . $this->mpdf->list_number_suffix; break; case 'upper-roman': case 'I': $blt = $this->mpdf->dec2roman($this->mpdf->listcounter[$this->mpdf->listlvl], true) . $this->mpdf->list_number_suffix; break; case 'lower-roman': case 'i': $blt = $this->mpdf->dec2roman($this->mpdf->listcounter[$this->mpdf->listlvl], false) . $this->mpdf->list_number_suffix; break; case 'decimal': case '1': $blt = $this->mpdf->listcounter[$this->mpdf->listlvl] . $this->mpdf->list_number_suffix; break; default: if ($this->mpdf->listlvl % 3 == 1 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 8226)) { $blt = "\xe2\x80\xa2"; } // • else if ($this->mpdf->listlvl % 3 == 2 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9900)) { $blt = "\xe2\x9a\xac"; } // ⚬ else if ($this->mpdf->listlvl % 3 == 0 && $this->mpdf->_charDefined($this->mpdf->CurrentFont['cw'], 9642)) { $blt = "\xe2\x96\xaa"; } // ▪ else { $blt = '-'; } break; } // change to spaces if ($this->mpdf->usingCoreFont) { $ls = str_repeat(chr(160) . chr(160), ($this->mpdf->listlvl - 1) * 2) . $blt . ' '; } else { $ls = str_repeat("\xc2\xa0\xc2\xa0", ($this->mpdf->listlvl - 1) * 2) . $blt . ' '; } $this->mpdf->_saveCellTextBuffer($ls); $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $this->mpdf->GetStringWidth($ls); } break; } /* -- END TABLES -- */ if ($this->mpdf->lastblocklevelchange == 1) { $blockstate = 1; } // Top margins/padding only else if ($this->mpdf->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding $this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate); $this->mpdf->textbuffer = array(); $save_blklvl = $this->mpdf->blklvl; $save_blk = $this->mpdf->blk; $this->mpdf->Reset(); $pagesel = ''; /* -- CSS-PAGE -- */ if (isset($p['PAGE'])) { $pagesel = $p['PAGE']; } // mPDF 6 (uses $p - preview of properties so blklvl can be incremented after page-break) /* -- END CSS-PAGE -- */ // If page-box has changed AND/OR PAGE-BREAK-BEFORE // mPDF 6 (uses $p - preview of properties so blklvl can be imcremented after page-break) 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']))) { // mPDF 6 pagebreaktype $startpage = $this->mpdf->page; $pagebreaktype = $this->mpdf->defaultPagebreakType; $this->mpdf->lastblocklevelchange = -1; if ($this->mpdf->ColActive) { $pagebreaktype = 'cloneall'; } if ($pagesel && (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current'])) { $pagebreaktype = 'cloneall'; } $this->mpdf->_preForcedPagebreak($pagebreaktype); if (isset($p['PAGE-BREAK-BEFORE'])) { if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'RIGHT') { $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel); } else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'LEFT') { $this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel); } else if (strtoupper($p['PAGE-BREAK-BEFORE']) == 'ALWAYS') { $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel); } else if ($this->mpdf->page_box['current'] != $pagesel) { $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel); } // *CSS-PAGE* } /* -- CSS-PAGE -- */ // Must Add new page if changed page properties else if (!isset($this->mpdf->page_box['current']) || $pagesel != $this->mpdf->page_box['current']) { $this->mpdf->AddPage($this->mpdf->CurOrientation, '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0, 0, 0, 0, $pagesel); } /* -- END CSS-PAGE -- */ // mPDF 6 pagebreaktype $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl); } // mPDF 6 pagebreaktype - moved after pagebreak $this->mpdf->blklvl++; $currblk = & $this->mpdf->blk[$this->mpdf->blklvl]; $this->mpdf->initialiseBlock($currblk); $prevblk = & $this->mpdf->blk[$this->mpdf->blklvl - 1]; $currblk['tag'] = $tag; $currblk['attr'] = $attr; $properties = $this->mpdf->cssmgr->MergeCSS('BLOCK', $tag, $attr); // mPDF 6 - moved to after page-break-before // mPDF 6 page-break-inside:avoid 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 $currblk['keep_block_together'] = 1; $currblk['array_i'] = $ihtml; // mPDF 6 $this->mpdf->kt_y00 = $this->mpdf->y; $this->mpdf->kt_p00 = $this->mpdf->page; $this->mpdf->keep_block_together = 1; } if ($lastbottommargin && isset($properties['MARGIN-TOP']) && $properties['MARGIN-TOP'] && empty($properties['FLOAT'])) { $currblk['lastbottommargin'] = $lastbottommargin; } if (isset($properties['Z-INDEX']) && $this->mpdf->current_layer == 0) { $v = intval($properties['Z-INDEX']); if ($v > 0) { $currblk['z-index'] = $v; $this->mpdf->BeginLayer($v); } } // mPDF 6 Lists // List-type set by attribute if ($tag == 'OL' || $tag == 'UL' || $tag == 'LI') { if (isset($attr['TYPE']) && $attr['TYPE']) { $listtype = $attr['TYPE']; switch ($listtype) { case 'A': $listtype = 'upper-latin'; break; case 'a': $listtype = 'lower-latin'; break; case 'I': $listtype = 'upper-roman'; break; case 'i': $listtype = 'lower-roman'; break; case '1': $listtype = 'decimal'; break; } $currblk['list_style_type'] = $listtype; } } $this->mpdf->setCSS($properties, 'BLOCK', $tag); //name(id/class/style) found in the CSS array! $currblk['InlineProperties'] = $this->mpdf->saveInlineProperties(); if (isset($properties['VISIBILITY'])) { $v = strtolower($properties['VISIBILITY']); if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible' && !$this->mpdf->tableLevel) { $currblk['visibility'] = $v; $this->mpdf->SetVisibility($v); } } // mPDF 6 if (isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower($attr['ALIGN'])]; } if (isset($properties['HEIGHT'])) { $currblk['css_set_height'] = $this->mpdf->ConvertSize($properties['HEIGHT'], ($this->mpdf->h - $this->mpdf->tMargin - $this->mpdf->bMargin), $this->mpdf->FontSize, false); 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))) { $this->mpdf->AddPage($this->mpdf->CurOrientation); } } else { $currblk['css_set_height'] = false; } // Added mPDF 3.0 Float DIV if (isset($prevblk['blockContext'])) { $currblk['blockContext'] = $prevblk['blockContext']; } // *CSS-FLOAT* if (isset($properties['CLEAR'])) { $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl - 1); } // *CSS-FLOAT* $container_w = $prevblk['inner_width']; $bdr = $currblk['border_right']['w']; $bdl = $currblk['border_left']['w']; $pdr = $currblk['padding_right']; $pdl = $currblk['padding_left']; if (isset($currblk['css_set_width'])) { $setwidth = $currblk['css_set_width']; } else { $setwidth = 0; } /* -- CSS-FLOAT -- */ if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'RIGHT' && !$this->mpdf->ColActive) { // Cancel Keep-Block-together $currblk['keep_block_together'] = false; $this->mpdf->kt_y00 = ''; $this->mpdf->keep_block_together = 0; $this->mpdf->blockContext++; $currblk['blockContext'] = $this->mpdf->blockContext; list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1); // DIV is too narrow for text to fit! $maxw = $container_w - $l_width - $r_width; if (($setwidth + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) { // Too narrow to fit - try to move down past L or R float 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))) { $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1); } 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))) { $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1); } else { $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1); } list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1); } if ($r_exists) { $currblk['margin_right'] += $r_width; } $currblk['float'] = 'R'; $currblk['float_start_y'] = $this->mpdf->y; if ($currblk['css_set_width']) { $currblk['margin_left'] = $container_w - ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']); $currblk['float_width'] = ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']); } else { // *** If no width set - would need to buffer and keep track of max width, then Right-align if not full width // and do borders and backgrounds - For now - just set to maximum width left if ($l_exists) { $currblk['margin_left'] += $l_width; } $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr); $currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_right']); } } else if (isset($properties['FLOAT']) && strtoupper($properties['FLOAT']) == 'LEFT' && !$this->mpdf->ColActive) { // Cancel Keep-Block-together $currblk['keep_block_together'] = false; $this->mpdf->kt_y00 = ''; $this->mpdf->keep_block_together = 0; $this->mpdf->blockContext++; $currblk['blockContext'] = $this->mpdf->blockContext; list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1); // DIV is too narrow for text to fit! $maxw = $container_w - $l_width - $r_width; if (($setwidth + $currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr) > $maxw || ($maxw - ($currblk['margin_left'] + $bdl + $pdl + $bdr + $pdr)) < (2 * $this->mpdf->GetCharWidth('W', false))) { // Too narrow to fit - try to move down past L or R float 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))) { $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1); } 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))) { $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1); } else { $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1); } list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1); } if ($l_exists) { $currblk['margin_left'] += $l_width; } $currblk['float'] = 'L'; $currblk['float_start_y'] = $this->mpdf->y; if ($setwidth) { $currblk['margin_right'] = $container_w - ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']); $currblk['float_width'] = ($setwidth + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']); } else { // *** If no width set - would need to buffer and keep track of max width, then Right-align if not full width // and do borders and backgrounds - For now - just set to maximum width left if ($r_exists) { $currblk['margin_right'] += $r_width; } $currblk['css_set_width'] = $container_w - ($currblk['margin_left'] + $currblk['margin_right'] + $bdl + $pdl + $bdr + $pdr); $currblk['float_width'] = ($currblk['css_set_width'] + $bdl + $pdl + $bdr + $pdr + $currblk['margin_left']); } } else { // Don't allow overlap - if floats present - adjust padding to avoid overlap with Floats list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1); $maxw = $container_w - $l_width - $r_width; 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))) { // Too narrow to fit - try to move down past L or R float 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))) { $this->mpdf->ClearFloats('LEFT', $this->mpdf->blklvl - 1); } 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))) { $this->mpdf->ClearFloats('RIGHT', $this->mpdf->blklvl - 1); } else { $this->mpdf->ClearFloats('BOTH', $this->mpdf->blklvl - 1); } list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->mpdf->GetFloatDivInfo($this->mpdf->blklvl - 1); } if ($r_exists) { $currblk['padding_right'] = max(($r_width - $currblk['margin_right'] - $bdr), $pdr); } if ($l_exists) { $currblk['padding_left'] = max(($l_width - $currblk['margin_left'] - $bdl), $pdl); } } /* -- END CSS-FLOAT -- */ /* -- BORDER-RADIUS -- */ // Automatically increase padding if required for border-radius if ($this->mpdf->autoPadding && !$this->mpdf->ColActive) { if ($currblk['border_radius_TL_H'] > $currblk['padding_left'] && $currblk['border_radius_TL_V'] > $currblk['padding_top']) { if ($currblk['border_radius_TL_H'] > $currblk['border_radius_TL_V']) { $this->mpdf->_borderPadding($currblk['border_radius_TL_H'], $currblk['border_radius_TL_V'], $currblk['padding_left'], $currblk['padding_top']); } else { $this->mpdf->_borderPadding($currblk['border_radius_TL_V'], $currblk['border_radius_TL_H'], $currblk['padding_top'], $currblk['padding_left']); } } if ($currblk['border_radius_TR_H'] > $currblk['padding_right'] && $currblk['border_radius_TR_V'] > $currblk['padding_top']) { if ($currblk['border_radius_TR_H'] > $currblk['border_radius_TR_V']) { $this->mpdf->_borderPadding($currblk['border_radius_TR_H'], $currblk['border_radius_TR_V'], $currblk['padding_right'], $currblk['padding_top']); } else { $this->mpdf->_borderPadding($currblk['border_radius_TR_V'], $currblk['border_radius_TR_H'], $currblk['padding_top'], $currblk['padding_right']); } } if ($currblk['border_radius_BL_H'] > $currblk['padding_left'] && $currblk['border_radius_BL_V'] > $currblk['padding_bottom']) { if ($currblk['border_radius_BL_H'] > $currblk['border_radius_BL_V']) { $this->mpdf->_borderPadding($currblk['border_radius_BL_H'], $currblk['border_radius_BL_V'], $currblk['padding_left'], $currblk['padding_bottom']); } else { $this->mpdf->_borderPadding($currblk['border_radius_BL_V'], $currblk['border_radius_BL_H'], $currblk['padding_bottom'], $currblk['padding_left']); } } if ($currblk['border_radius_BR_H'] > $currblk['padding_right'] && $currblk['border_radius_BR_V'] > $currblk['padding_bottom']) { if ($currblk['border_radius_BR_H'] > $currblk['border_radius_BR_V']) { $this->mpdf->_borderPadding($currblk['border_radius_BR_H'], $currblk['border_radius_BR_V'], $currblk['padding_right'], $currblk['padding_bottom']); } else { $this->mpdf->_borderPadding($currblk['border_radius_BR_V'], $currblk['border_radius_BR_H'], $currblk['padding_bottom'], $currblk['padding_right']); } } } /* -- END BORDER-RADIUS -- */ // Hanging indent - if negative indent: ensure padding is >= indent if (!isset($currblk['text_indent'])) { $currblk['text_indent'] = null; } if (!isset($currblk['inner_width'])) { $currblk['inner_width'] = null; } $cbti = $this->mpdf->ConvertSize($currblk['text_indent'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if ($cbti < 0) { $hangind = -($cbti); if (isset($currblk['direction']) && $currblk['direction'] == 'rtl') { // *OTL* $currblk['padding_right'] = max($currblk['padding_right'], $hangind); // *OTL* } // *OTL* else { // *OTL* $currblk['padding_left'] = max($currblk['padding_left'], $hangind); } // *OTL* } if (isset($currblk['css_set_width'])) { if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT']) == 'auto' && strtolower($properties['MARGIN-RIGHT']) == 'auto') { // Try to reduce margins to accomodate - if still too wide, set margin-right/left=0 (reduces width) $anyextra = $prevblk['inner_width'] - ($currblk['css_set_width'] + $currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']); if ($anyextra > 0) { $currblk['margin_left'] = $currblk['margin_right'] = $anyextra / 2; } else { $currblk['margin_left'] = $currblk['margin_right'] = 0; } } else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') { // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width) $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']); if ($currblk['margin_left'] < 0) { $currblk['margin_left'] = 0; } } else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') { // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width) $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']); if ($currblk['margin_right'] < 0) { $currblk['margin_right'] = 0; } } else { if ($currblk['direction'] == 'rtl') { // *OTL* // Try to reduce margin-left to accomodate - if still too wide, set margin-left=0 (reduces width) $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* if ($currblk['margin_left'] < 0) { // *OTL* $currblk['margin_left'] = 0; // *OTL* } // *OTL* } // *OTL* else { // *OTL* // Try to reduce margin-right to accomodate - if still too wide, set margin-right=0 (reduces width) $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']); if ($currblk['margin_right'] < 0) { $currblk['margin_right'] = 0; } } // *OTL* } } $currblk['outer_left_margin'] = $prevblk['outer_left_margin'] + $currblk['margin_left'] + $prevblk['border_left']['w'] + $prevblk['padding_left']; $currblk['outer_right_margin'] = $prevblk['outer_right_margin'] + $currblk['margin_right'] + $prevblk['border_right']['w'] + $prevblk['padding_right']; $currblk['width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']); $currblk['inner_width'] = $currblk['width'] - ($currblk['border_left']['w'] + $currblk['padding_left'] + $currblk['border_right']['w'] + $currblk['padding_right']); // Check DIV is not now too narrow to fit text $mw = 2 * $this->mpdf->GetCharWidth('W', false); if ($currblk['inner_width'] < $mw) { $currblk['padding_left'] = 0; $currblk['padding_right'] = 0; $currblk['border_left']['w'] = 0.2; $currblk['border_right']['w'] = 0.2; $currblk['margin_left'] = 0; $currblk['margin_right'] = 0; $currblk['outer_left_margin'] = $prevblk['outer_left_margin'] + $currblk['margin_left'] + $prevblk['border_left']['w'] + $prevblk['padding_left']; $currblk['outer_right_margin'] = $prevblk['outer_right_margin'] + $currblk['margin_right'] + $prevblk['border_right']['w'] + $prevblk['padding_right']; $currblk['width'] = $this->mpdf->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']); $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']); // if ($currblk['inner_width'] < $mw) { throw new MpdfException("DIV is too narrow for text to fit!"); } } $this->mpdf->x = $this->mpdf->lMargin + $currblk['outer_left_margin']; /* -- BACKGROUNDS -- */ if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->mpdf->kwt && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together) { $ret = $this->mpdf->SetBackground($properties, $currblk['inner_width']); if ($ret) { $currblk['background-image'] = $ret; } } /* -- END BACKGROUNDS -- */ /* -- TABLES -- */ if ($this->mpdf->use_kwt && isset($attr['KEEP-WITH-TABLE']) && !$this->mpdf->ColActive && !$this->mpdf->keep_block_together) { $this->mpdf->kwt = true; $this->mpdf->kwt_y0 = $this->mpdf->y; //$this->mpdf->kwt_x0 = $this->mpdf->x; $this->mpdf->kwt_x0 = $this->mpdf->lMargin; // mPDF 6 $this->mpdf->kwt_height = 0; $this->mpdf->kwt_buffer = array(); $this->mpdf->kwt_Links = array(); $this->mpdf->kwt_Annots = array(); $this->mpdf->kwt_moved = false; $this->mpdf->kwt_saved = false; $this->mpdf->kwt_Reference = array(); $this->mpdf->kwt_BMoutlines = array(); $this->mpdf->kwt_toc = array(); } else { /* -- END TABLES -- */ $this->mpdf->kwt = false; } // *TABLES* //Save x,y coords in case we need to print borders... $currblk['y0'] = $this->mpdf->y; $currblk['initial_y0'] = $this->mpdf->y; // mPDF 6 $currblk['x0'] = $this->mpdf->x; $currblk['initial_x0'] = $this->mpdf->x; // mPDF 6 $currblk['initial_startpage'] = $this->mpdf->page; $currblk['startpage'] = $this->mpdf->page; // mPDF 6 $this->mpdf->oldy = $this->mpdf->y; $this->mpdf->lastblocklevelchange = 1; // mPDF 6 Lists if ($tag == 'OL' || $tag == 'UL') { $this->mpdf->listlvl++; if (isset($attr['START']) && $attr['START']) { $this->mpdf->listcounter[$this->mpdf->listlvl] = intval($attr['START']) - 1; } else { $this->mpdf->listcounter[$this->mpdf->listlvl] = 0; } $this->mpdf->listitem = array(); // List-type if (!isset($currblk['list_style_type']) || !$currblk['list_style_type']) { if ($tag == 'OL') $currblk['list_style_type'] = 'decimal'; else if ($tag == 'UL') { if ($this->mpdf->listlvl % 3 == 1) $currblk['list_style_type'] = 'disc'; elseif ($this->mpdf->listlvl % 3 == 2) $currblk['list_style_type'] = 'circle'; else $currblk['list_style_type'] = 'square'; } } // List-image if (!isset($currblk['list_style_image']) || !$currblk['list_style_image']) { $currblk['list_style_image'] = 'none'; } // List-position if (!isset($currblk['list_style_position']) || !$currblk['list_style_position']) { $currblk['list_style_position'] = 'outside'; } // Default indentation using padding 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']))) { $autopadding = $this->mpdf->_getListMarkerWidth($currblk, $ahtml, $ihtml); if ($this->mpdf->listlvl > 1 || $this->mpdf->list_indent_first_level) { $autopadding += $this->mpdf->ConvertSize($this->mpdf->list_indent_default_mpdf, $currblk['inner_width'], $this->mpdf->FontSize, false); } // autopadding value is applied to left or right according // to dir of block. Once a CSS value is set for padding it overrides this default value. if (isset($properties['PADDING-RIGHT']) && $properties['PADDING-RIGHT'] == 'auto' && isset($currblk['direction']) && $currblk['direction'] == 'rtl') { $currblk['padding_right'] = $autopadding; } else if (isset($properties['PADDING-LEFT']) && $properties['PADDING-LEFT'] == 'auto') { $currblk['padding_left'] = $autopadding; } } else { // Initial default value is set by $this->mpdf->list_indent_default in config.php; this value is applied to left or right according // to dir of block. Once a CSS value is set for padding it overrides this default value. if (isset($properties['PADDING-RIGHT']) && $properties['PADDING-RIGHT'] == 'auto' && isset($currblk['direction']) && $currblk['direction'] == 'rtl') { $currblk['padding_right'] = $this->mpdf->ConvertSize($this->mpdf->list_indent_default, $currblk['inner_width'], $this->mpdf->FontSize, false); } else if (isset($properties['PADDING-LEFT']) && $properties['PADDING-LEFT'] == 'auto') { $currblk['padding_left'] = $this->mpdf->ConvertSize($this->mpdf->list_indent_default, $currblk['inner_width'], $this->mpdf->FontSize, false); } } } // mPDF 6 Lists if ($tag == 'LI') { if ($this->mpdf->listlvl == 0) { //in case of malformed HTML code. Example:(...)Paragraph1
(...) $this->mpdf->listlvl++; // first depth level $this->mpdf->listcounter[$this->mpdf->listlvl] = 0; } $this->mpdf->listcounter[$this->mpdf->listlvl] ++; $this->mpdf->listitem = array(); // Listitem-type $this->mpdf->_setListMarker($currblk['list_style_type'], $currblk['list_style_image'], $currblk['list_style_position']); } // mPDF 6 Bidirectional formatting for block elements $bdf = false; $bdf2 = ''; $popd = ''; // Get current direction if (isset($currblk['direction'])) { $currdir = $currblk['direction']; } else { $currdir = 'ltr'; } if (isset($attr['DIR']) and $attr['DIR'] != '') { $currdir = strtolower($attr['DIR']); } if (isset($properties['DIRECTION'])) { $currdir = strtolower($properties['DIRECTION']); } // mPDF 6 bidi // cf. http://www.w3.org/TR/css3-writing-modes/#unicode-bidi if (isset($properties ['UNICODE-BIDI']) && (strtolower($properties ['UNICODE-BIDI']) == 'bidi-override' || strtolower($properties ['UNICODE-BIDI']) == 'isolate-override')) { if ($currdir == 'rtl') { $bdf = 0x202E; $popd = 'RLOPDF'; } // U+202E RLO else { $bdf = 0x202D; $popd = 'LROPDF'; } // U+202D LRO } else if (isset($properties ['UNICODE-BIDI']) && strtolower($properties ['UNICODE-BIDI']) == 'plaintext') { $bdf = 0x2068; $popd = 'FSIPDI'; // U+2068 FSI } if ($bdf) { if ($bdf2) { $bdf2 = code2utf($bdf); } $this->mpdf->OTLdata = array(); if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer(code2utf($bdf) . $bdf2); } else { $this->mpdf->_saveTextBuffer(code2utf($bdf) . $bdf2); } $this->mpdf->biDirectional = true; $currblk['bidicode'] = $popd; } break; case 'HR': // Added mPDF 3.0 Float DIV - CLEAR if (isset($attr['STYLE'])) { $properties = $this->mpdf->cssmgr->readInlineCSS($attr['STYLE']); if (isset($properties['CLEAR'])) { $this->mpdf->ClearFloats(strtoupper($properties['CLEAR']), $this->mpdf->blklvl); } // *CSS-FLOAT* } $this->mpdf->ignorefollowingspaces = true; $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['WIDTH'])) { $objattr['width'] = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); } else if (isset($attr['WIDTH']) && $attr['WIDTH'] != '') $objattr['width'] = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); if (isset($properties['TEXT-ALIGN'])) { $objattr['align'] = $align[strtolower($properties['TEXT-ALIGN'])]; } else if (isset($attr['ALIGN']) && $attr['ALIGN'] != '') $objattr['align'] = $align[strtolower($attr['ALIGN'])]; if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') { $objattr['align'] = 'R'; } if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto') { $objattr['align'] = 'L'; if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT']) == 'auto' && isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT']) == 'auto') { $objattr['align'] = 'C'; } } if (isset($properties['COLOR'])) { $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']); } else if (isset($attr['COLOR']) && $attr['COLOR'] != '') $objattr['color'] = $this->mpdf->ConvertColor($attr['COLOR']); if (isset($properties['HEIGHT'])) { $objattr['linewidth'] = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } /* -- TABLES -- */ if ($this->mpdf->tableLevel) { $objattr['W-PERCENT'] = 100; if (isset($properties['WIDTH']) && stristr($properties['WIDTH'], '%')) { $properties['WIDTH'] += 0; //make "90%" become simply "90" $objattr['W-PERCENT'] = $properties['WIDTH']; } if (isset($attr['WIDTH']) && stristr($attr['WIDTH'], '%')) { $attr['WIDTH'] += 0; //make "90%" become simply "90" $objattr['W-PERCENT'] = $attr['WIDTH']; } } /* -- END TABLES -- */ $objattr['type'] = 'hr'; $objattr['height'] = $objattr['linewidth'] + $objattr['margin_top'] + $objattr['margin_bottom']; $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; // Clear properties - tidy up $properties = array(); /* -- TABLES -- */ // Output it to buffers if ($this->mpdf->tableLevel) { if (!isset($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'])) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } elseif ($this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] < $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']) { $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['maxs'] = $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s']; } $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] = 0; // reset $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF); } else { /* -- END TABLES -- */ $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF); } // *TABLES* break; /* -- BARCODES -- */ case 'BARCODE': $this->mpdf->ignorefollowingspaces = false; if (isset($attr['CODE']) && $attr['CODE']) { $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['padding_top'] = 0; $objattr['padding_bottom'] = 0; $objattr['padding_left'] = 0; $objattr['padding_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['code'] = $attr['CODE']; if (isset($attr['TYPE'])) { $objattr['btype'] = trim(strtoupper($attr['TYPE'])); } else { $objattr['btype'] = 'EAN13'; } // default if (preg_match('/^(EAN13|ISBN|ISSN|EAN8|UPCA|UPCE)P([25])$/', $objattr['btype'], $m)) { $objattr['btype'] = $m[1]; $objattr['bsupp'] = $m[2]; if (preg_match('/^(\S+)\s+(.*)$/', $objattr['code'], $mm)) { $objattr['code'] = $mm[1]; $objattr['bsupp_code'] = $mm[2]; } } else { $objattr['bsupp'] = 0; } if (isset($attr['TEXT']) && $attr['TEXT'] == 1) { $objattr['showtext'] = 1; } else { $objattr['showtext'] = 0; } if (isset($attr['SIZE']) && $attr['SIZE'] > 0) { $objattr['bsize'] = $attr['SIZE']; } else { $objattr['bsize'] = 1; } if (isset($attr['HEIGHT']) && $attr['HEIGHT'] > 0) { $objattr['bheight'] = $attr['HEIGHT']; } else { $objattr['bheight'] = 1; } if (isset($attr['PR']) && $attr['PR'] > 0) { $objattr['pr_ratio'] = $attr['PR']; } else { $objattr['pr_ratio'] = ''; } $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') { return; } if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-TOP'])) { $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']); } if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']); } if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']); } if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); } if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; } if (isset($properties['COLOR']) && $properties['COLOR'] != '') { $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']); } else { $objattr['color'] = false; } if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']); } else { $objattr['bgcolor'] = false; } if (!class_exists('PDFBarcode', false)) { include(_MPDF_PATH . 'classes/barcode.php'); } $this->mpdf->barcode = new PDFBarcode(); if ($objattr['btype'] == 'EAN13' || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN' || $objattr['btype'] == 'UPCA' || $objattr['btype'] == 'UPCE' || $objattr['btype'] == 'EAN8') { $code = preg_replace('/\-/', '', $objattr['code']); if ($objattr['btype'] == 'ISSN' || $objattr['btype'] == 'ISBN') { $arrcode = $this->mpdf->barcode->getBarcodeArray($code, 'EAN13'); } else { $arrcode = $this->mpdf->barcode->getBarcodeArray($code, $objattr['btype']); } if ($arrcode === false) { throw new MpdfException('Error in barcode string.'); } if ($objattr['bsupp'] == 2 || $objattr['bsupp'] == 5) { // EAN-2 or -5 Supplement $supparrcode = $this->mpdf->barcode->getBarcodeArray($objattr['bsupp_code'], 'EAN' . $objattr['bsupp']); $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR'] + $supparrcode["maxw"] + $supparrcode['sepM']) * $arrcode['nom-X'] * $objattr['bsize']; } else { $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize']; } $h = $arrcode['nom-H'] * $objattr['bsize'] * $objattr['bheight']; // Add height for ISBN string + margin from top of bars if (($objattr['showtext'] && $objattr['btype'] == 'EAN13') || $objattr['btype'] == 'ISBN' || $objattr['btype'] == 'ISSN') { $tisbnm = 1.5 * $objattr['bsize']; // Top margin between TOP TEXT (isbn - if shown) & bars $isbn_fontsize = 2.1 * $objattr['bsize']; $h += $isbn_fontsize + $tisbnm; } } // QR-code else if ($objattr['btype'] == 'QR') { $w = $h = $objattr['bsize'] * 25; // Factor of 25mm (default) $objattr['errorlevel'] = 'L'; if (isset($attr['ERROR'])) { $objattr['errorlevel'] = $attr['ERROR']; } } else if ($objattr['btype'] == 'IMB' || $objattr['btype'] == 'RM4SCC' || $objattr['btype'] == 'KIX' || $objattr['btype'] == 'POSTNET' || $objattr['btype'] == 'PLANET') { $arrcode = $this->mpdf->barcode->getBarcodeArray($objattr['code'], $objattr['btype']); if ($arrcode === false) { throw new MpdfException('Error in barcode string.'); } $w = ($arrcode["maxw"] * $arrcode['nom-X'] * $objattr['bsize']) + $arrcode['quietL'] + $arrcode['quietR']; $h = ($arrcode['nom-H'] * $objattr['bsize']) + (2 * $arrcode['quietTB']); } 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'))) { $arrcode = $this->mpdf->barcode->getBarcodeArray($objattr['code'], $objattr['btype'], $objattr['pr_ratio']); if ($arrcode === false) { throw new MpdfException('Error in barcode string.'); } $w = ($arrcode["maxw"] + $arrcode['lightmL'] + $arrcode['lightmR']) * $arrcode['nom-X'] * $objattr['bsize']; $h = ((2 * $arrcode['lightTB'] * $arrcode['nom-X']) + $arrcode['nom-H']) * $objattr['bsize'] * $objattr['bheight']; } else { break; } $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w']; $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w']; $objattr['type'] = 'barcode'; $objattr['height'] = $h + $extraheight; $objattr['width'] = $w + $extrawidth; $objattr['barcode_height'] = $h; $objattr['barcode_width'] = $w; /* -- CSS-IMAGE-FLOAT -- */ if (!$this->mpdf->ColActive && !$this->mpdf->tableLevel && !$this->mpdf->listlvl && !$this->mpdf->kwt) { if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) { $objattr['float'] = substr(strtoupper($properties['FLOAT']), 0, 1); } } /* -- END CSS-IMAGE-FLOAT -- */ $e = "\xbb\xa4\xactype=barcode,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; // Clear properties - tidy up $properties = array(); /* -- TABLES -- */ // Output it to buffers if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF); $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; } else { /* -- END TABLES -- */ $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF); } // *TABLES* } break; /* -- END BARCODES -- */ // *********** FORM ELEMENTS ******************** /* -- FORMS -- */ case 'SELECT': $this->mpdf->lastoptionaltag = ''; // Save current HTML specified optional endtag $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); if (isset($properties['FONT-FAMILY'])) { $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false); } if (isset($properties['FONT-SIZE'])) { $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK); $this->mpdf->SetFontSize($mmsize * _MPDFK, false); } if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') { $this->mpdf->selectoption['SPELLCHECK'] = true; } if (isset($properties['COLOR'])) { $this->mpdf->selectoption['COLOR'] = $this->mpdf->ConvertColor($properties['COLOR']); } $this->mpdf->specialcontent = "type=select"; if (isset($attr['DISABLED'])) { $this->mpdf->selectoption['DISABLED'] = $attr['DISABLED']; } if (isset($attr['READONLY'])) { $this->mpdf->selectoption['READONLY'] = $attr['READONLY']; } if (isset($attr['REQUIRED'])) { $this->mpdf->selectoption['REQUIRED'] = $attr['REQUIRED']; } if (isset($attr['EDITABLE'])) { $this->mpdf->selectoption['EDITABLE'] = $attr['EDITABLE']; } if (isset($attr['TITLE'])) { $this->mpdf->selectoption['TITLE'] = $attr['TITLE']; } if (isset($attr['MULTIPLE'])) { $this->mpdf->selectoption['MULTIPLE'] = $attr['MULTIPLE']; } if (isset($attr['SIZE']) && $attr['SIZE'] > 1) { $this->mpdf->selectoption['SIZE'] = $attr['SIZE']; } if ($this->mpdf->useActiveForms) { if (isset($attr['NAME'])) { $this->mpdf->selectoption['NAME'] = $attr['NAME']; } if (isset($attr['ONCHANGE'])) { $this->mpdf->selectoption['ONCHANGE'] = $attr['ONCHANGE']; } } $properties = array(); break; case 'OPTION': $this->mpdf->lastoptionaltag = ''; $this->mpdf->selectoption['ACTIVE'] = true; $this->mpdf->selectoption['currentSEL'] = false; if (empty($this->mpdf->selectoption)) { $this->mpdf->selectoption['MAXWIDTH'] = ''; $this->mpdf->selectoption['SELECTED'] = ''; } if (isset($attr['SELECTED'])) { $this->mpdf->selectoption['SELECTED'] = ''; $this->mpdf->selectoption['currentSEL'] = true; } if (isset($attr['VALUE'])) { $attr['VALUE'] = strcode2utf($attr['VALUE']); $attr['VALUE'] = $this->mpdf->lesser_entity_decode($attr['VALUE']); if ($this->mpdf->onlyCoreFonts) $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8'); } $this->mpdf->selectoption['currentVAL'] = $attr['VALUE']; break; case 'TEXTAREA': $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; if (isset($attr['DISABLED'])) { $objattr['disabled'] = true; } if (isset($attr['READONLY'])) { $objattr['readonly'] = true; } if (isset($attr['REQUIRED'])) { $objattr['required'] = true; } if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') { $objattr['spellcheck'] = true; } if (isset($attr['TITLE'])) { $objattr['title'] = $attr['TITLE']; if ($this->mpdf->onlyCoreFonts) $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mpdf->mb_enc, 'UTF-8'); } if ($this->mpdf->useActiveForms) { if (isset($attr['NAME'])) { $objattr['fieldname'] = $attr['NAME']; } $this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['v'] = 0; $this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['v'] = 0; if (isset($attr['ONCALCULATE'])) { $objattr['onCalculate'] = $attr['ONCALCULATE']; } else if (isset($attr['ONCHANGE'])) { $objattr['onCalculate'] = $attr['ONCHANGE']; } if (isset($attr['ONVALIDATE'])) { $objattr['onValidate'] = $attr['ONVALIDATE']; } if (isset($attr['ONKEYSTROKE'])) { $objattr['onKeystroke'] = $attr['ONKEYSTROKE']; } if (isset($attr['ONFORMAT'])) { $objattr['onFormat'] = $attr['ONFORMAT']; } } $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); if (isset($properties['FONT-FAMILY'])) { $this->mpdf->SetFont($properties['FONT-FAMILY'], '', 0, false); } if (isset($properties['FONT-SIZE'])) { $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], $this->mpdf->default_font_size / _MPDFK); $this->mpdf->SetFontSize($mmsize * _MPDFK, false); } if (isset($properties['COLOR'])) { $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']); } $objattr['fontfamily'] = $this->mpdf->FontFamily; $objattr['fontsize'] = $this->mpdf->FontSizePt; if ($this->mpdf->useActiveForms) { if (isset($properties['TEXT-ALIGN'])) { $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])]; } else if (isset($attr['ALIGN'])) { $objattr['text_align'] = $align[strtolower($attr['ALIGN'])]; } if (isset($properties['OVERFLOW']) && strtolower($properties['OVERFLOW']) == 'hidden') { $objattr['donotscroll'] = true; } if (isset($properties['BORDER-TOP-COLOR'])) { $objattr['border-col'] = $this->mpdf->ConvertColor($properties['BORDER-TOP-COLOR']); } if (isset($properties['BACKGROUND-COLOR'])) { $objattr['background-col'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']); } } $this->mpdf->SetLineHeight('', $this->mpdf->mpdfform->textarea_lineheight); $w = 0; $h = 0; if (isset($properties['WIDTH'])) $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['HEIGHT'])) $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; } $colsize = 20; //HTML default value $rowsize = 2; //HTML default value if (isset($attr['COLS'])) $colsize = intval($attr['COLS']); if (isset($attr['ROWS'])) $rowsize = intval($attr['ROWS']); $charsize = $this->mpdf->GetCharWidth('w', false); if ($w) { $colsize = round(($w - ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['h'] * 2) - ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['h'] * 2)) / $charsize); } if ($h) { $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); } $objattr['type'] = 'textarea'; $objattr['width'] = ($colsize * $charsize) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['textarea']['inner']['h'] * 2); $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); $objattr['rows'] = $rowsize; $objattr['cols'] = $colsize; $this->mpdf->specialcontent = serialize($objattr); if ($this->mpdf->tableLevel) { // *TABLES* $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; // *TABLES* } // *TABLES* // Clear properties - tidy up $properties = array(); break; // *********** FORM - INPUT ******************** case 'INPUT': $this->mpdf->ignorefollowingspaces = false; if (!isset($attr['TYPE'])) $attr['TYPE'] == 'TEXT'; $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['type'] = 'input'; if (isset($attr['DISABLED'])) { $objattr['disabled'] = true; } if (isset($attr['READONLY'])) { $objattr['readonly'] = true; } if (isset($attr['REQUIRED'])) { $objattr['required'] = true; } if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK']) == 'true') { $objattr['spellcheck'] = true; } if (isset($attr['TITLE'])) { $objattr['title'] = $attr['TITLE']; } else if (isset($attr['ALT'])) { $objattr['title'] = $attr['ALT']; } else $objattr['title'] = ''; $objattr['title'] = strcode2utf($objattr['title']); $objattr['title'] = $this->mpdf->lesser_entity_decode($objattr['title']); if ($this->mpdf->onlyCoreFonts) $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mpdf->mb_enc, 'UTF-8'); if ($this->mpdf->useActiveForms) { if (isset($attr['NAME'])) { $objattr['fieldname'] = $attr['NAME']; } } if (isset($attr['VALUE'])) { $attr['VALUE'] = strcode2utf($attr['VALUE']); $attr['VALUE'] = $this->mpdf->lesser_entity_decode($attr['VALUE']); if ($this->mpdf->onlyCoreFonts) $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mpdf->mb_enc, 'UTF-8'); $objattr['value'] = $attr['VALUE']; } $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); $objattr['vertical-align'] = ''; if (isset($properties['FONT-FAMILY'])) { $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false); } if (isset($properties['FONT-SIZE'])) { $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], ($this->mpdf->default_font_size / _MPDFK)); $this->mpdf->SetFontSize($mmsize * _MPDFK, false); } if (isset($properties['COLOR'])) { $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']); } $objattr['fontfamily'] = $this->mpdf->FontFamily; $objattr['fontsize'] = $this->mpdf->FontSizePt; if ($this->mpdf->useActiveForms) { if (isset($attr['ALIGN'])) { $objattr['text_align'] = $align[strtolower($attr['ALIGN'])]; } else if (isset($properties['TEXT-ALIGN'])) { $objattr['text_align'] = $align[strtolower($properties['TEXT-ALIGN'])]; } if (isset($properties['BORDER-TOP-COLOR'])) { $objattr['border-col'] = $this->mpdf->ConvertColor($properties['BORDER-TOP-COLOR']); } if (isset($properties['BACKGROUND-COLOR'])) { $objattr['background-col'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']); } } $type = ''; $texto = ''; $height = $this->mpdf->FontSize; $width = 0; $spacesize = $this->mpdf->GetCharWidth(' ', false); $w = 0; if (isset($properties['WIDTH'])) $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); if ($properties['VERTICAL-ALIGN']) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; } switch (strtoupper($attr['TYPE'])) { case 'HIDDEN': $this->mpdf->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces if ($this->mpdf->useActiveForms) { $this->mpdf->mpdfform->SetFormText(0, 0, $objattr['fieldname'], $objattr['value'], $objattr['value'], '', 0, '', true); } if ($this->mpdf->InlineProperties[$tag]) { $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]); } unset($this->mpdf->InlineProperties[$tag]); break 2; case 'CHECKBOX': //Draw Checkbox $type = 'CHECKBOX'; if (isset($attr['CHECKED'])) { $objattr['checked'] = true; } else { $objattr['checked'] = false; } $width = $this->mpdf->FontSize; $height = $this->mpdf->FontSize; break; case 'RADIO': //Draw Radio button $type = 'RADIO'; if (isset($attr['CHECKED'])) $objattr['checked'] = true; $width = $this->mpdf->FontSize; $height = $this->mpdf->FontSize; break; /* -- IMAGES-CORE -- */ case 'IMAGE': // Draw an Image button if (isset($attr['SRC'])) { $type = 'IMAGE'; $srcpath = $attr['SRC']; $orig_srcpath = $attr['ORIG_SRC']; // VSPACE and HSPACE converted to margins in MergeCSS if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']); } if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']); } if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']); } if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); } $objattr['padding_top'] = 0; $objattr['padding_bottom'] = 0; $objattr['padding_left'] = 0; $objattr['padding_right'] = 0; if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; } $w = 0; $h = 0; if (isset($properties['WIDTH'])) $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); if (isset($properties['HEIGHT'])) $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); $extraheight = $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w']; $extrawidth = $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w']; // Image file $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath); if (!$info) { $info = $this->mpdf->_getImage($this->mpdf->noImageFile); if ($info) { $srcpath = $this->mpdf->noImageFile; $w = ($info['w'] * (25.4 / $this->mpdf->dpi)); $h = ($info['h'] * (25.4 / $this->mpdf->dpi)); } } if (!$info) break; if ($info['cs'] == 'Indexed') { $objattr['Indexed'] = true; } $objattr['file'] = $srcpath; //Default width and height calculation if needed if ($w == 0 and $h == 0) { /* -- IMAGES-WMF -- */ if ($info['type'] == 'wmf') { // WMF units are twips (1/20pt) // divide by 20 to get points // divide by k to get user units $w = abs($info['w']) / (20 * _MPDFK); $h = abs($info['h']) / (20 * _MPDFK); } else /* -- END IMAGES-WMF -- */ if ($info['type'] == 'svg') { // SVG units are pixels $w = abs($info['w']) / _MPDFK; $h = abs($info['h']) / _MPDFK; } else { //Put image at default image dpi $w = ($info['w'] / _MPDFK) * (72 / $this->mpdf->img_dpi); $h = ($info['h'] / _MPDFK) * (72 / $this->mpdf->img_dpi); } if (isset($properties['IMAGE-RESOLUTION'])) { if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi'] > 0) { $w *= $this->mpdf->img_dpi / $info['set-dpi']; $h *= $this->mpdf->img_dpi / $info['set-dpi']; } else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) { $dpi = $m[1]; if ($dpi > 0) { $w *= $this->mpdf->img_dpi / $dpi; $h *= $this->mpdf->img_dpi / $dpi; } } } } // IF WIDTH OR HEIGHT SPECIFIED if ($w == 0) $w = $h * $info['w'] / $info['h']; if ($h == 0) $h = $w * $info['h'] / $info['w']; // Resize to maximum dimensions of page $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']; $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 10); if ($this->mpdf->fullImageHeight) { $maxHeight = $this->mpdf->fullImageHeight; } if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth $w = $maxWidth - $extrawidth; $h = $w * $info['h'] / $info['w']; } if ($h + $extraheight > $maxHeight) { $h = $maxHeight - $extraheight; $w = $h * $info['w'] / $info['h']; } $height = $h + $extraheight; $width = $w + $extrawidth; $objattr['type'] = 'image'; $objattr['itype'] = $info['type']; $objattr['orig_h'] = $info['h']; $objattr['orig_w'] = $info['w']; /* -- IMAGES-WMF -- */ if ($info['type'] == 'wmf') { $objattr['wmf_x'] = $info['x']; $objattr['wmf_y'] = $info['y']; } else /* -- END IMAGES-WMF -- */ if ($info['type'] == 'svg') { $objattr['wmf_x'] = $info['x']; $objattr['wmf_y'] = $info['y']; } $objattr['height'] = $h + $extraheight; $objattr['width'] = $w + $extrawidth; $objattr['image_height'] = $h; $objattr['image_width'] = $w; $objattr['ID'] = $info['i']; $texto = 'X'; if ($this->mpdf->useActiveForms) { if (isset($attr['ONCLICK'])) { $objattr['onClick'] = $attr['ONCLICK']; } $objattr['type'] = 'input'; $type = 'IMAGE'; } break; } /* -- END IMAGES-CORE -- */ case 'BUTTON': // Draw a button case 'SUBMIT': case 'RESET': $type = strtoupper($attr['TYPE']); if ($type == 'IMAGE') { $type = 'BUTTON'; } // src path not found if (isset($attr['NOPRINT'])) { $objattr['noprint'] = true; } if (!isset($attr['VALUE'])) { $objattr['value'] = ucfirst(strtolower($type)); } $texto = " " . $objattr['value'] . " "; $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); $height = $this->mpdf->FontSize + ($this->mpdf->mpdfform->form_element_spacing['button']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['button']['inner']['v'] * 2); if ($this->mpdf->useActiveForms) { if (isset($attr['ONCLICK'])) { $objattr['onClick'] = $attr['ONCLICK']; } } break; case 'PASSWORD': case 'TEXT': default: if ($type == '') { $type = 'TEXT'; } if (strtoupper($attr['TYPE']) == 'PASSWORD') { $type = 'PASSWORD'; } if (isset($attr['VALUE'])) { if ($type == 'PASSWORD') { $num_stars = mb_strlen($attr['VALUE'], $this->mpdf->mb_enc); $texto = str_repeat('*', $num_stars); } else { $texto = $attr['VALUE']; } } $xw = ($this->mpdf->mpdfform->form_element_spacing['input']['outer']['h'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['input']['inner']['h'] * 2); $xh = ($this->mpdf->mpdfform->form_element_spacing['input']['outer']['v'] * 2) + ($this->mpdf->mpdfform->form_element_spacing['input']['inner']['v'] * 2); if ($w) { $width = $w + $xw; } else { $width = (20 * $spacesize) + $xw; } // Default width in chars if (isset($attr['SIZE']) and ctype_digit($attr['SIZE'])) $width = ($attr['SIZE'] * $spacesize) + $xw; $height = $this->mpdf->FontSize + $xh; if (isset($attr['MAXLENGTH']) and ctype_digit($attr['MAXLENGTH'])) $objattr['maxlength'] = $attr['MAXLENGTH']; if ($this->mpdf->useActiveForms) { if (isset($attr['ONCALCULATE'])) { $objattr['onCalculate'] = $attr['ONCALCULATE']; } else if (isset($attr['ONCHANGE'])) { $objattr['onCalculate'] = $attr['ONCHANGE']; } if (isset($attr['ONVALIDATE'])) { $objattr['onValidate'] = $attr['ONVALIDATE']; } if (isset($attr['ONKEYSTROKE'])) { $objattr['onKeystroke'] = $attr['ONKEYSTROKE']; } if (isset($attr['ONFORMAT'])) { $objattr['onFormat'] = $attr['ONFORMAT']; } } break; } $objattr['subtype'] = $type; $objattr['text'] = $texto; $objattr['width'] = $width; $objattr['height'] = $height; $e = "\xbb\xa4\xactype=input,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; // Clear properties - tidy up $properties = array(); /* -- TABLES -- */ // Output it to buffers if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF); $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; } else { /* -- END TABLES -- */ $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF); } // *TABLES* if ($this->mpdf->InlineProperties[$tag]) { $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]); } unset($this->mpdf->InlineProperties[$tag]); break; // END of INPUT /* -- END FORMS -- */ // *********** GRAPH ******************** case 'JPGRAPH': if (!$this->mpdf->useGraphs) { break; } if ($attr['TABLE']) { $gid = strtoupper($attr['TABLE']); } else { $gid = '0'; } if (!is_array($this->mpdf->graphs[$gid]) || count($this->mpdf->graphs[$gid]) == 0) { break; } $this->mpdf->ignorefollowingspaces = false; include_once(_MPDF_PATH . 'graph.php'); $this->mpdf->graphs[$gid]['attr'] = $attr; if (isset($this->mpdf->graphs[$gid]['attr']['WIDTH']) && $this->mpdf->graphs[$gid]['attr']['WIDTH']) { $this->mpdf->graphs[$gid]['attr']['cWIDTH'] = $this->mpdf->ConvertSize($this->mpdf->graphs[$gid]['attr']['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); } // mm if (isset($this->mpdf->graphs[$gid]['attr']['HEIGHT']) && $this->mpdf->graphs[$gid]['attr']['HEIGHT']) { $this->mpdf->graphs[$gid]['attr']['cHEIGHT'] = $this->mpdf->ConvertSize($this->mpdf->graphs[$gid]['attr']['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); } $graph_img = print_graph($this->mpdf->graphs[$gid], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']); if ($graph_img) { if (isset($attr['ROTATE'])) { if ($attr['ROTATE'] == 90 || $attr['ROTATE'] == -90) { $tmpw = $graph_img['w']; $graph_img['w'] = $graph_img['h']; $graph_img['h'] = $tmpw; } } $attr['SRC'] = $graph_img['file']; $attr['WIDTH'] = $graph_img['w']; $attr['HEIGHT'] = $graph_img['h']; } else { break; } // *********** IMAGE ******************** /* -- IMAGES-CORE -- */ case 'IMG': $this->mpdf->ignorefollowingspaces = false; if ($this->mpdf->progressBar) { $this->mpdf->UpdateProgressBar(1, '', 'IMG'); } // *PROGRESS-BAR* $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['padding_top'] = 0; $objattr['padding_bottom'] = 0; $objattr['padding_left'] = 0; $objattr['padding_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; if (isset($attr['SRC'])) { $srcpath = $attr['SRC']; $orig_srcpath = (isset($attr['ORIG_SRC']) ? $attr['ORIG_SRC'] : ''); $properties = $this->mpdf->cssmgr->MergeCSS('', $tag, $attr); if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') { return; } if (isset($properties['Z-INDEX']) && $this->mpdf->current_layer == 0) { $v = intval($properties['Z-INDEX']); if ($v > 0) { $objattr['z-index'] = $v; } } $objattr['visibility'] = 'visible'; if (isset($properties['VISIBILITY'])) { $v = strtolower($properties['VISIBILITY']); if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') { $objattr['visibility'] = $v; } } // VSPACE and HSPACE converted to margins in MergeCSS if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-TOP'])) { $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']); } if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']); } if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']); } if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); } if (isset($properties['VERTICAL-ALIGN'])) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; } $w = 0; $h = 0; if (isset($properties['WIDTH'])) $w = $this->mpdf->ConvertSize($properties['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['WIDTH'])) $w = $this->mpdf->ConvertSize($attr['WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['HEIGHT'])) $h = $this->mpdf->ConvertSize($properties['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['HEIGHT'])) $h = $this->mpdf->ConvertSize($attr['HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); $maxw = $maxh = $minw = $minh = false; if (isset($properties['MAX-WIDTH'])) $maxw = $this->mpdf->ConvertSize($properties['MAX-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['MAX-WIDTH'])) $maxw = $this->mpdf->ConvertSize($attr['MAX-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['MAX-HEIGHT'])) $maxh = $this->mpdf->ConvertSize($properties['MAX-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['MAX-HEIGHT'])) $maxh = $this->mpdf->ConvertSize($attr['MAX-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['MIN-WIDTH'])) $minw = $this->mpdf->ConvertSize($properties['MIN-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['MIN-WIDTH'])) $minw = $this->mpdf->ConvertSize($attr['MIN-WIDTH'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['MIN-HEIGHT'])) $minh = $this->mpdf->ConvertSize($properties['MIN-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); else if (isset($attr['MIN-HEIGHT'])) $minh = $this->mpdf->ConvertSize($attr['MIN-HEIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; } if ($this->mpdf->HREF) { if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) { $href = $this->mpdf->HREF; while (array_key_exists($href, $this->mpdf->internallink)) $href = "#" . $href; $this->mpdf->internallink[$href] = $this->mpdf->AddLink(); $objattr['link'] = $this->mpdf->internallink[$href]; } else { $objattr['link'] = $this->mpdf->HREF; } } $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w']; $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w']; // mPDF 5.7.3 TRANSFORMS if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']); } /* -- BACKGROUNDS -- */ if (isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/', $properties['GRADIENT-MASK'])) { $objattr['GRADIENT-MASK'] = $properties['GRADIENT-MASK']; } /* -- END BACKGROUNDS -- */ // mPDF 6 $interpolation = false; if (isset($properties['IMAGE-RENDERING']) && $properties['IMAGE-RENDERING']) { if (strtolower($properties['IMAGE-RENDERING']) == 'crisp-edges') { $interpolation = false; } else if (strtolower($properties['IMAGE-RENDERING']) == 'optimizequality') { $interpolation = true; } else if (strtolower($properties['IMAGE-RENDERING']) == 'smooth') { $interpolation = true; } else if (strtolower($properties['IMAGE-RENDERING']) == 'auto') { $interpolation = $this->mpdf->interpolateImages; } else { $interpolation = false; } $info['interpolation'] = $interpolation; } // Image file $info = $this->mpdf->_getImage($srcpath, true, true, $orig_srcpath, $interpolation); // mPDF 6 if (!$info) { $info = $this->mpdf->_getImage($this->mpdf->noImageFile); if ($info) { $srcpath = $this->mpdf->noImageFile; $w = ($info['w'] * (25.4 / $this->mpdf->dpi)); $h = ($info['h'] * (25.4 / $this->mpdf->dpi)); } } if (!$info) break; if (isset($attr['ROTATE'])) { $image_orientation = $attr['ROTATE']; } else if (isset($properties['IMAGE-ORIENTATION'])) { $image_orientation = $properties['IMAGE-ORIENTATION']; } else { $image_orientation = 0; } if ($image_orientation) { if ($image_orientation == 90 || $image_orientation == -90 || $image_orientation == 270) { $tmpw = $info['w']; $info['w'] = $info['h']; $info['h'] = $tmpw; } $objattr['ROTATE'] = $image_orientation; } $objattr['file'] = $srcpath; //Default width and height calculation if needed if ($w == 0 and $h == 0) { /* -- IMAGES-WMF -- */ if ($info['type'] == 'wmf') { // WMF units are twips (1/20pt) // divide by 20 to get points // divide by k to get user units $w = abs($info['w']) / (20 * _MPDFK); $h = abs($info['h']) / (20 * _MPDFK); } else /* -- END IMAGES-WMF -- */ if ($info['type'] == 'svg') { // SVG units are pixels $w = abs($info['w']) / _MPDFK; $h = abs($info['h']) / _MPDFK; } else { //Put image at default image dpi $w = ($info['w'] / _MPDFK) * (72 / $this->mpdf->img_dpi); $h = ($info['h'] / _MPDFK) * (72 / $this->mpdf->img_dpi); } if (isset($properties['IMAGE-RESOLUTION'])) { if (preg_match('/from-image/i', $properties['IMAGE-RESOLUTION']) && isset($info['set-dpi']) && $info['set-dpi'] > 0) { $w *= $this->mpdf->img_dpi / $info['set-dpi']; $h *= $this->mpdf->img_dpi / $info['set-dpi']; } else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) { $dpi = $m[1]; if ($dpi > 0) { $w *= $this->mpdf->img_dpi / $dpi; $h *= $this->mpdf->img_dpi / $dpi; } } } } // IF WIDTH OR HEIGHT SPECIFIED if ($w == 0) $w = abs($h * $info['w'] / $info['h']); if ($h == 0) $h = abs($w * $info['h'] / $info['w']); if ($minw && $w < $minw) { $w = $minw; $h = abs($w * $info['h'] / $info['w']); } if ($maxw && $w > $maxw) { $w = $maxw; $h = abs($w * $info['h'] / $info['w']); } if ($minh && $h < $minh) { $h = $minh; $w = abs($h * $info['w'] / $info['h']); } if ($maxh && $h > $maxh) { $h = $maxh; $w = abs($h * $info['w'] / $info['h']); } // Resize to maximum dimensions of page $maxWidth = $this->mpdf->blk[$this->mpdf->blklvl]['inner_width']; $maxHeight = $this->mpdf->h - ($this->mpdf->tMargin + $this->mpdf->bMargin + 1); if ($this->mpdf->fullImageHeight) { $maxHeight = $this->mpdf->fullImageHeight; } if (($w + $extrawidth) > ($maxWidth + 0.0001)) { // mPDF 5.7.4 0.0001 to allow for rounding errors when w==maxWidth $w = $maxWidth - $extrawidth; $h = abs($w * $info['h'] / $info['w']); } if ($h + $extraheight > $maxHeight) { $h = $maxHeight - $extraheight; $w = abs($h * $info['w'] / $info['h']); } $objattr['type'] = 'image'; $objattr['itype'] = $info['type']; $objattr['orig_h'] = $info['h']; $objattr['orig_w'] = $info['w']; /* -- IMAGES-WMF -- */ if ($info['type'] == 'wmf') { $objattr['wmf_x'] = $info['x']; $objattr['wmf_y'] = $info['y']; } else /* -- END IMAGES-WMF -- */ if ($info['type'] == 'svg') { $objattr['wmf_x'] = $info['x']; $objattr['wmf_y'] = $info['y']; } $objattr['height'] = $h + $extraheight; $objattr['width'] = $w + $extrawidth; $objattr['image_height'] = $h; $objattr['image_width'] = $w; /* -- CSS-IMAGE-FLOAT -- */ if (!$this->mpdf->ColActive && !$this->mpdf->tableLevel && !$this->mpdf->listlvl && !$this->mpdf->kwt) { if (isset($properties['FLOAT']) && (strtoupper($properties['FLOAT']) == 'RIGHT' || strtoupper($properties['FLOAT']) == 'LEFT')) { $objattr['float'] = substr(strtoupper($properties['FLOAT']), 0, 1); } } /* -- END CSS-IMAGE-FLOAT -- */ // mPDF 5.7.3 TRANSFORMS if (isset($properties['TRANSFORM']) && !$this->mpdf->ColActive && !$this->mpdf->kwt) { $objattr['transform'] = $properties['TRANSFORM']; } $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; // Clear properties - tidy up $properties = array(); /* -- TABLES -- */ // Output it to buffers if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF); $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; } else { /* -- END TABLES -- */ $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF); } // *TABLES* /* -- ANNOTATIONS -- */ if ($this->mpdf->title2annots && isset($attr['TITLE'])) { $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['CONTENT'] = $attr['TITLE']; $objattr['type'] = 'annot'; $objattr['POS-X'] = 0; $objattr['POS-Y'] = 0; $objattr['ICON'] = 'Comment'; $objattr['AUTHOR'] = ''; $objattr['SUBJECT'] = ''; $objattr['OPACITY'] = $this->mpdf->annotOpacity; $objattr['COLOR'] = $this->mpdf->ConvertColor('yellow'); $e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; if ($this->mpdf->tableLevel) { // *TABLES* $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = array($e); // *TABLES* } // *TABLES* else { // *TABLES* $this->mpdf->textbuffer[] = array($e); } // *TABLES* } /* -- END ANNOTATIONS -- */ } break; /* -- END IMAGES-CORE -- */ // *********** CIRCULAR TEXT = TEXTCIRCLE ******************** case 'TEXTCIRCLE': $objattr = array(); $objattr['margin_top'] = 0; $objattr['margin_bottom'] = 0; $objattr['margin_left'] = 0; $objattr['margin_right'] = 0; $objattr['padding_top'] = 0; $objattr['padding_bottom'] = 0; $objattr['padding_left'] = 0; $objattr['padding_right'] = 0; $objattr['width'] = 0; $objattr['height'] = 0; $objattr['border_top']['w'] = 0; $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; $objattr['top-text'] = ''; $objattr['bottom-text'] = ''; $objattr['r'] = 20; // radius (default value here for safety) $objattr['space-width'] = 120; $objattr['char-width'] = 100; $this->mpdf->InlineProperties[$tag] = $this->mpdf->saveInlineProperties(); $properties = $this->mpdf->cssmgr->MergeCSS('INLINE', $tag, $attr); if (isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY']) == 'none') { return; } if (isset($attr['R'])) { $objattr['r'] = $this->mpdf->ConvertSize($attr['R'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($attr['TOP-TEXT'])) { $objattr['top-text'] = strcode2utf($attr['TOP-TEXT']); $objattr['top-text'] = $this->mpdf->lesser_entity_decode($objattr['top-text']); if ($this->mpdf->onlyCoreFonts) $objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mpdf->mb_enc, 'UTF-8'); } if (isset($attr['BOTTOM-TEXT'])) { $objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']); $objattr['bottom-text'] = $this->mpdf->lesser_entity_decode($objattr['bottom-text']); if ($this->mpdf->onlyCoreFonts) $objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->mpdf->mb_enc, 'UTF-8'); } if (isset($attr['SPACE-WIDTH']) && $attr['SPACE-WIDTH']) { $objattr['space-width'] = $attr['SPACE-WIDTH']; } if (isset($attr['CHAR-WIDTH']) && $attr['CHAR-WIDTH']) { $objattr['char-width'] = $attr['CHAR-WIDTH']; } // VISIBILITY $objattr['visibility'] = 'visible'; if (isset($properties['VISIBILITY'])) { $v = strtolower($properties['VISIBILITY']); if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->mpdf->visibility == 'visible') { $objattr['visibility'] = $v; } } if (isset($properties['FONT-SIZE'])) { if (strtolower($properties['FONT-SIZE']) == 'auto') { if ($objattr['top-text'] && $objattr['bottom-text']) { $objattr['fontsize'] = -2; } else { $objattr['fontsize'] = -1; } } else { $mmsize = $this->mpdf->ConvertSize($properties['FONT-SIZE'], ($this->mpdf->default_font_size / _MPDFK)); $this->mpdf->SetFontSize($mmsize * _MPDFK, false); $objattr['fontsize'] = $this->mpdf->FontSizePt; } } if (isset($attr['DIVIDER'])) { $objattr['divider'] = strcode2utf($attr['DIVIDER']); $objattr['divider'] = $this->mpdf->lesser_entity_decode($objattr['divider']); if ($this->mpdf->onlyCoreFonts) $objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mpdf->mb_enc, 'UTF-8'); } if (isset($properties['COLOR'])) { $objattr['color'] = $this->mpdf->ConvertColor($properties['COLOR']); } $objattr['fontstyle'] = ''; if (isset($properties['FONT-WEIGHT'])) { if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $objattr['fontstyle'] .= 'B'; } } if (isset($properties['FONT-STYLE'])) { if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $objattr['fontstyle'] .= 'I'; } } if (isset($properties['FONT-FAMILY'])) { $this->mpdf->SetFont($properties['FONT-FAMILY'], $this->mpdf->FontStyle, 0, false); } $objattr['fontfamily'] = $this->mpdf->FontFamily; // VSPACE and HSPACE converted to margins in MergeCSS if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->mpdf->ConvertSize($properties['MARGIN-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->mpdf->ConvertSize($properties['MARGIN-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->mpdf->ConvertSize($properties['MARGIN-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->mpdf->ConvertSize($properties['MARGIN-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-TOP'])) { $objattr['padding_top'] = $this->mpdf->ConvertSize($properties['PADDING-TOP'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->mpdf->ConvertSize($properties['PADDING-BOTTOM'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->mpdf->ConvertSize($properties['PADDING-LEFT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->mpdf->ConvertSize($properties['PADDING-RIGHT'], $this->mpdf->blk[$this->mpdf->blklvl]['inner_width'], $this->mpdf->FontSize, false); } if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->mpdf->border_details($properties['BORDER-TOP']); } if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->mpdf->border_details($properties['BORDER-BOTTOM']); } if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->mpdf->border_details($properties['BORDER-LEFT']); } if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->mpdf->border_details($properties['BORDER-RIGHT']); } if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; } if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->mpdf->ConvertColor($properties['BACKGROUND-COLOR']); } else { $objattr['bgcolor'] = false; } if ($this->mpdf->HREF) { if (strpos($this->mpdf->HREF, ".") === false && strpos($this->mpdf->HREF, "@") !== 0) { $href = $this->mpdf->HREF; while (array_key_exists($href, $this->mpdf->internallink)) $href = "#" . $href; $this->mpdf->internallink[$href] = $this->mpdf->AddLink(); $objattr['link'] = $this->mpdf->internallink[$href]; } else { $objattr['link'] = $this->mpdf->HREF; } } $extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w']; $extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w']; $w = $objattr['r'] * 2; $h = $w; $objattr['height'] = $h + $extraheight; $objattr['width'] = $w + $extrawidth; $objattr['type'] = 'textcircle'; $e = "\xbb\xa4\xactype=image,objattr=" . serialize($objattr) . "\xbb\xa4\xac"; // Clear properties - tidy up $properties = array(); /* -- TABLES -- */ // Output it to buffers if ($this->mpdf->tableLevel) { $this->mpdf->_saveCellTextBuffer($e, $this->mpdf->HREF); $this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['s'] += $objattr['width']; } else { /* -- END TABLES -- */ $this->mpdf->_saveTextBuffer($e, $this->mpdf->HREF); } // *TABLES* if ($this->mpdf->InlineProperties[$tag]) { $this->mpdf->restoreInlineProperties($this->mpdf->InlineProperties[$tag]); } unset($this->mpdf->InlineProperties[$tag]); break; /* -- TABLES -- */ case 'TABLE': // TABLE-BEGIN $this->mpdf->tdbegin = false; $this->mpdf->lastoptionaltag = ''; // Disable vertical justification in columns if ($this->mpdf->ColActive) { $this->mpdf->colvAlign = ''; } // *COLUMNS* if ($this->mpdf->lastblocklevelchange == 1) { $blockstate = 1; } // Top margins/padding only else if ($this->mpdf->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding // called from block after new div e.g.