which is positioned absolutely/fixed
+ // top/left/right/bottom/width/height/background*/border*/padding*/margin* are taken from bounding
+ // font*[family/size/style/weight]/line-height/text*[align/decoration/transform/indent]/color are transferred to $inner
+ // as an enclosing
(after having checked ID/CLASS)
+ // $x, $y, $w, $h are inside of $bbox_ = containing box for $inner_
+ // $inner_ InnerHTML is the contents of that block to be output
+ $tag = $bounding[0];
+ $attr = $bounding[1];
+ $orig_x0 = $bounding[2];
+ $orig_y0 = $bounding[3];
+
+ // As in WriteHTML() initialising
+ $this->blklvl = 0;
+ $this->lastblocklevelchange = 0;
+ $this->blk = array();
+ $this->initialiseBlock($this->blk[0]);
+
+ $this->blk[0]['width'] =& $this->pgwidth;
+ $this->blk[0]['inner_width'] =& $this->pgwidth;
+
+ $this->blk[0]['blockContext'] = $this->blockContext;
+
+ $properties = $this->cssmgr->MergeCSS('BLOCK','BODY','');
+ $this->setCSS($properties,'','BODY');
+ $this->blklvl = 1;
+ $this->initialiseBlock($this->blk[1]);
+ $this->blk[1]['tag'] = $tag;
+ $this->blk[1]['attr'] = $attr;
+ $this->Reset();
+ $p = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr);
+ if (isset($p['ROTATE']) && ($p['ROTATE']==90 || $p['ROTATE']==-90)) { $rotate = $p['ROTATE']; }
+ else { $rotate = 0; }
+ if (isset($p['OVERFLOW'])) { $overflow = strtolower($p['OVERFLOW']); }
+ if (strtolower($p['POSITION']) == 'fixed') {
+ $cont_w = $this->pgwidth; // $this->blk[0]['inner_width'];
+ $cont_h = $this->h - $this->tMargin - $this->bMargin;
+ $cont_x = $this->lMargin;
+ $cont_y = $this->tMargin;
+ }
+ else {
+ $cont_w = $this->w; // ABSOLUTE;
+ $cont_h = $this->h;
+ $cont_x = 0;
+ $cont_y = 0;
+ }
+
+ // Pass on in-line properties to the innerhtml
+ $css = '';
+ if (isset($p['TEXT-ALIGN'])) { $css .= 'text-align: '.strtolower($p['TEXT-ALIGN']).'; '; }
+ if (isset($p['TEXT-TRANSFORM'])) { $css .= 'text-transform: '.strtolower($p['TEXT-TRANSFORM']).'; '; }
+ if (isset($p['TEXT-INDENT'])) { $css .= 'text-indent: '.strtolower($p['TEXT-INDENT']).'; '; }
+ if (isset($p['TEXT-DECORATION'])) { $css .= 'text-decoration: '.strtolower($p['TEXT-DECORATION']).'; '; }
+ if (isset($p['FONT-FAMILY'])) { $css .= 'font-family: '.strtolower($p['FONT-FAMILY']).'; '; }
+ if (isset($p['FONT-STYLE'])) { $css .= 'font-style: '.strtolower($p['FONT-STYLE']).'; '; }
+ if (isset($p['FONT-WEIGHT'])) { $css .= 'font-weight: '.strtolower($p['FONT-WEIGHT']).'; '; }
+ if (isset($p['FONT-SIZE'])) { $css .= 'font-size: '.strtolower($p['FONT-SIZE']).'; '; }
+ if (isset($p['LINE-HEIGHT'])) { $css .= 'line-height: '.strtolower($p['LINE-HEIGHT']).'; '; }
+ if (isset($p['TEXT-SHADOW'])) { $css .= 'text-shadow: '.strtolower($p['TEXT-SHADOW']).'; '; }
+ if (isset($p['LETTER-SPACING'])) { $css .= 'letter-spacing: '.strtolower($p['LETTER-SPACING']).'; '; }
+ if (isset($p['FONT-VARIANT'])) { $css .= 'font-variant: '.strtolower($p['FONT-VARIANT']).'; '; }
+ if (isset($p['COLOR'])) { $css .= 'color: '.strtolower($p['COLOR']).'; '; }
+ if (isset($p['Z-INDEX'])) { $css .= 'z-index: '.$p['Z-INDEX'].'; '; } // mPDF 5.6.01
+ if ($css) {
+ $html = '
'.$html.'
';
+ }
+ // Copy over (only) the properties to set for border and background
+ $pb = array();
+ $pb['MARGIN-TOP'] = $p['MARGIN-TOP'];
+ $pb['MARGIN-RIGHT'] = $p['MARGIN-RIGHT'];
+ $pb['MARGIN-BOTTOM'] = $p['MARGIN-BOTTOM'];
+ $pb['MARGIN-LEFT'] = $p['MARGIN-LEFT'];
+ $pb['PADDING-TOP'] = $p['PADDING-TOP'];
+ $pb['PADDING-RIGHT'] = $p['PADDING-RIGHT'];
+ $pb['PADDING-BOTTOM'] = $p['PADDING-BOTTOM'];
+ $pb['PADDING-LEFT'] = $p['PADDING-LEFT'];
+ $pb['BORDER-TOP'] = $p['BORDER-TOP'];
+ $pb['BORDER-RIGHT'] = $p['BORDER-RIGHT'];
+ $pb['BORDER-BOTTOM'] = $p['BORDER-BOTTOM'];
+ $pb['BORDER-LEFT'] = $p['BORDER-LEFT'];
+ $pb['BORDER-TOP-LEFT-RADIUS-H'] = $p['BORDER-TOP-LEFT-RADIUS-H'];
+ $pb['BORDER-TOP-LEFT-RADIUS-V'] = $p['BORDER-TOP-LEFT-RADIUS-V'];
+ $pb['BORDER-TOP-RIGHT-RADIUS-H'] = $p['BORDER-TOP-RIGHT-RADIUS-H'];
+ $pb['BORDER-TOP-RIGHT-RADIUS-V'] = $p['BORDER-TOP-RIGHT-RADIUS-V'];
+ $pb['BORDER-BOTTOM-LEFT-RADIUS-H'] = $p['BORDER-BOTTOM-LEFT-RADIUS-H'];
+ $pb['BORDER-BOTTOM-LEFT-RADIUS-V'] = $p['BORDER-BOTTOM-LEFT-RADIUS-V'];
+ $pb['BORDER-BOTTOM-RIGHT-RADIUS-H'] = $p['BORDER-BOTTOM-RIGHT-RADIUS-H'];
+ $pb['BORDER-BOTTOM-RIGHT-RADIUS-V'] = $p['BORDER-BOTTOM-RIGHT-RADIUS-V'];
+ if (isset($p['BACKGROUND-COLOR'])) { $pb['BACKGROUND-COLOR'] = $p['BACKGROUND-COLOR']; }
+ if (isset($p['BOX-SHADOW'])) { $pb['BOX-SHADOW'] = $p['BOX-SHADOW']; }
+/*-- BACKGROUNDS --*/
+ if (isset($p['BACKGROUND-IMAGE'])) { $pb['BACKGROUND-IMAGE'] = $p['BACKGROUND-IMAGE']; }
+ if (isset($p['BACKGROUND-IMAGE-RESIZE'])) { $pb['BACKGROUND-IMAGE-RESIZE'] = $p['BACKGROUND-IMAGE-RESIZE']; }
+ if (isset($p['BACKGROUND-IMAGE-OPACITY'])) { $pb['BACKGROUND-IMAGE-OPACITY'] = $p['BACKGROUND-IMAGE-OPACITY']; }
+ if (isset($p['BACKGROUND-REPEAT'])) { $pb['BACKGROUND-REPEAT'] = $p['BACKGROUND-REPEAT']; }
+ if (isset($p['BACKGROUND-POSITION'])) { $pb['BACKGROUND-POSITION'] = $p['BACKGROUND-POSITION']; }
+ if (isset($p['BACKGROUND-GRADIENT'])) { $pb['BACKGROUND-GRADIENT'] = $p['BACKGROUND-GRADIENT']; }
+ if (isset($p['BACKGROUND-SIZE'])) { $pb['BACKGROUND-SIZE'] = $p['BACKGROUND-SIZE']; } // mPDF 5.6.12
+ if (isset($p['BACKGROUND-ORIGIN'])) { $pb['BACKGROUND-ORIGIN'] = $p['BACKGROUND-ORIGIN']; } // mPDF 5.6.12
+ if (isset($p['BACKGROUND-CLIP'])) { $pb['BACKGROUND-CLIP'] = $p['BACKGROUND-CLIP']; } // mPDF 5.6.12
+
+/*-- END BACKGROUNDS --*/
+
+ $this->setCSS($pb,'BLOCK',$tag);
+
+ //================================================================
+ $bbox_br = $this->blk[1]['border_right']['w'];
+ $bbox_bl = $this->blk[1]['border_left']['w'];
+ $bbox_bt = $this->blk[1]['border_top']['w'];
+ $bbox_bb = $this->blk[1]['border_bottom']['w'];
+ $bbox_pr = $this->blk[1]['padding_right'];
+ $bbox_pl = $this->blk[1]['padding_left'];
+ $bbox_pt = $this->blk[1]['padding_top'];
+ $bbox_pb = $this->blk[1]['padding_bottom'];
+ $bbox_mr = $this->blk[1]['margin_right'];
+ if (strtolower($p['MARGIN-RIGHT'])=='auto') { $bbox_mr = 'auto'; }
+ $bbox_ml = $this->blk[1]['margin_left'];
+ if (strtolower($p['MARGIN-LEFT'])=='auto') { $bbox_ml = 'auto'; }
+ $bbox_mt = $this->blk[1]['margin_top'];
+ if (strtolower($p['MARGIN-TOP'])=='auto') { $bbox_mt = 'auto'; }
+ $bbox_mb = $this->blk[1]['margin_bottom'];
+ if (strtolower($p['MARGIN-BOTTOM'])=='auto') { $bbox_mb = 'auto'; }
+ if (isset($p['LEFT']) && strtolower($p['LEFT'])!='auto') { $bbox_left = $this->ConvertSize($p['LEFT'], $cont_w, $this->FontSize,false); }
+ else { $bbox_left = 'auto'; }
+ if (isset($p['TOP']) && strtolower($p['TOP'])!='auto') { $bbox_top = $this->ConvertSize($p['TOP'], $cont_h, $this->FontSize,false); }
+ else { $bbox_top = 'auto'; }
+ if (isset($p['RIGHT']) && strtolower($p['RIGHT'])!='auto') { $bbox_right = $this->ConvertSize($p['RIGHT'], $cont_w, $this->FontSize,false); }
+ else { $bbox_right = 'auto'; }
+ if (isset($p['BOTTOM']) && strtolower($p['BOTTOM'])!='auto') { $bbox_bottom = $this->ConvertSize($p['BOTTOM'], $cont_h, $this->FontSize,false); }
+ else { $bbox_bottom = 'auto'; }
+ if (isset($p['WIDTH']) && strtolower($p['WIDTH'])!='auto') { $inner_w = $this->ConvertSize($p['WIDTH'], $cont_w, $this->FontSize,false); }
+ else { $inner_w = 'auto'; }
+ if (isset($p['HEIGHT']) && strtolower($p['HEIGHT'])!='auto') { $inner_h = $this->ConvertSize($p['HEIGHT'], $cont_h, $this->FontSize,false); }
+ else { $inner_h = 'auto'; }
+
+ // If bottom or right pos are set and not left / top - save this to adjust rotated block later
+ if ($rotate) {
+ if ($bbox_left === 'auto' && $bbox_right !== 'auto') { $rot_rpos = $bbox_right; }
+ else { $rot_rpos = false; }
+ if ($bbox_top === 'auto' && $bbox_bottom !== 'auto') { $rot_bpos = $bbox_bottom; }
+ else { $rot_bpos = false; }
+ }
+
+ //================================================================
+ if ($checkinnerhtml=='' && $inner_h==='auto') { $inner_h = 0.0001; }
+ if ($checkinnerhtml=='' && $inner_w==='auto') { $inner_w = 2*$this->GetCharWidth('W',false); }
+ //================================================================
+ // Algorithm from CSS2.1 See http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height
+ // mPD 5.3.14
+ // Special case (not CSS) if all not specified, centre vertically on page
+ if ($bbox_top==='auto' && $inner_h==='auto' && $bbox_bottom==='auto' && $bbox_mt==='auto' && $bbox_mb==='auto') {
+ $bbox_top_orig = $bbox_top;
+ if ($bbox_mt==='auto') { $bbox_mt = 0; }
+ if ($bbox_mb==='auto') { $bbox_mb = 0; }
+ $bbox_top = $orig_y0 - $bbox_mt - $cont_y;
+ // solve for $bbox_bottom when content_h known - $inner_h=='auto' && $bbox_bottom=='auto'
+ }
+ // mPD 5.3.14
+ else if ($bbox_top==='auto' && $inner_h==='auto' && $bbox_bottom==='auto') {
+ $bbox_top_orig = $bbox_top = $orig_y0 - $cont_y;
+ if ($bbox_mt==='auto') { $bbox_mt = 0; }
+ if ($bbox_mb==='auto') { $bbox_mb = 0; }
+ // solve for $bbox_bottom when content_h known - $inner_h=='auto' && $bbox_bottom=='auto'
+ }
+ else if ($bbox_top!=='auto' && $inner_h!=='auto' && $bbox_bottom!=='auto') {
+ if ($bbox_mt==='auto' && $bbox_mb==='auto') {
+ $x = $cont_h - $bbox_top - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_bottom;
+ $bbox_mt = $bbox_mb = ($x/2);
+ }
+ else if ($bbox_mt==='auto') {
+ $bbox_mt = $cont_h - $bbox_top - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mb - $bbox_bottom;
+ }
+ else if ($bbox_mb==='auto') {
+ $bbox_mb = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_bottom;
+ }
+ else {
+ $bbox_bottom = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mt;
+ }
+ }
+ else {
+ if ($bbox_mt==='auto') { $bbox_mt = 0; }
+ if ($bbox_mb==='auto') { $bbox_mb = 0; }
+ if ($bbox_top==='auto' && $inner_h==='auto' && $bbox_bottom!=='auto') {
+ // solve for $bbox_top when content_h known - $inner_h=='auto' && $bbox_top =='auto'
+ }
+ else if ($bbox_top==='auto' && $bbox_bottom==='auto' && $inner_h!=='auto') {
+ $bbox_top = $orig_y0 - $bbox_mt - $cont_y;
+ $bbox_bottom = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mt;
+ }
+ else if ($inner_h==='auto' && $bbox_bottom==='auto' && $bbox_top!=='auto') {
+ // solve for $bbox_bottom when content_h known - $inner_h=='auto' && $bbox_bottom=='auto'
+ }
+ else if ($bbox_top==='auto' && $inner_h!=='auto' && $bbox_bottom!=='auto') {
+ $bbox_top = $cont_h - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mt - $bbox_bottom;
+ }
+ else if ($inner_h==='auto' && $bbox_top!=='auto' && $bbox_bottom!=='auto') {
+ $inner_h = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $bbox_pb - $bbox_bb - $bbox_mt - $bbox_bottom;
+ }
+ else if ($bbox_bottom==='auto' && $bbox_top!=='auto' && $inner_h!=='auto') {
+ $bbox_bottom = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mt;
+ }
+ }
+
+ // THEN DO SAME FOR WIDTH
+ // http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width
+ if ($bbox_left==='auto' && $inner_w==='auto' && $bbox_right==='auto') {
+ if ($bbox_ml==='auto') { $bbox_ml = 0; }
+ if ($bbox_mr==='auto') { $bbox_mr = 0; }
+ // IF containing element RTL, should set $bbox_right
+ $bbox_left = $orig_x0 - $bbox_ml - $cont_x;
+ // solve for $bbox_right when content_w known - $inner_w=='auto' && $bbox_right=='auto'
+ }
+ else if ($bbox_left!=='auto' && $inner_w!=='auto' && $bbox_right!=='auto') {
+ if ($bbox_ml==='auto' && $bbox_mr==='auto') {
+ $x = $cont_w - $bbox_left - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_right;
+ $bbox_ml = $bbox_mr = ($x/2);
+ }
+ else if ($bbox_ml==='auto') {
+ $bbox_ml = $cont_w - $bbox_left - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_mr - $bbox_right;
+ }
+ else if ($bbox_mr==='auto') {
+ $bbox_mr = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_right;
+ }
+ else {
+ $bbox_right = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_ml;
+ }
+ }
+ else {
+ if ($bbox_ml==='auto') { $bbox_ml = 0; }
+ if ($bbox_mr==='auto') { $bbox_mr = 0; }
+ if ($bbox_left==='auto' && $inner_w==='auto' && $bbox_right!=='auto') {
+ // solve for $bbox_left when content_w known - $inner_w=='auto' && $bbox_left =='auto'
+ }
+ else if ($bbox_left==='auto' && $bbox_right==='auto' && $inner_w!=='auto') {
+ // IF containing element RTL, should set $bbox_right
+ $bbox_left = $orig_x0 - $bbox_ml - $cont_x;
+ $bbox_right = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_ml;
+ }
+ else if ($inner_w==='auto' && $bbox_right==='auto' && $bbox_left!=='auto') {
+ // solve for $bbox_right when content_w known - $inner_w=='auto' && $bbox_right=='auto'
+ }
+ else if ($bbox_left==='auto' && $inner_w!=='auto' && $bbox_right!=='auto') {
+ $bbox_left = $cont_w - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_ml - $bbox_right;
+ }
+ else if ($inner_w==='auto' && $bbox_left!=='auto' && $bbox_right!=='auto') {
+ $inner_w = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $bbox_pr - $bbox_br - $bbox_ml - $bbox_right;
+ }
+ else if ($bbox_right==='auto' && $bbox_left!=='auto' && $inner_w!=='auto') {
+ $bbox_right = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_ml;
+ }
+ }
+
+ //================================================================
+ //================================================================
+/*-- BACKGROUNDS --*/
+ if (isset($pb['BACKGROUND-IMAGE']) && $pb['BACKGROUND-IMAGE']) {
+ $ret = $this->SetBackground($pb, $this->blk[1]['inner_width']);
+ if ($ret) { $this->blk[1]['background-image'] = $ret; }
+ }
+/*-- END BACKGROUNDS --*/
+
+ //================================================================
+ $y = $cont_y + $bbox_top + $bbox_mt + $bbox_bt + $bbox_pt;
+ $h = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $bbox_pb - $bbox_bb - $bbox_mb - $bbox_bottom;
+ $x = $cont_x + $bbox_left + $bbox_ml + $bbox_bl + $bbox_pl;
+ $w = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $bbox_pr - $bbox_br - $bbox_mr - $bbox_right;
+ // Set (temporary) values for x y w h to do first paint, if values are auto
+ if ($inner_h==='auto' && $bbox_top==='auto') {
+ $y = $cont_y + $bbox_mt + $bbox_bt + $bbox_pt;
+ $h = $cont_h - ($bbox_bottom + $bbox_mt + $bbox_mb + $bbox_bt + $bbox_bb + $bbox_pt + $bbox_pb);
+ }
+ else if ($inner_h==='auto' && $bbox_bottom==='auto') {
+ $y = $cont_y + $bbox_top + $bbox_mt + $bbox_bt + $bbox_pt;
+ $h = $cont_h - ($bbox_top + $bbox_mt + $bbox_mb + $bbox_bt + $bbox_bb + $bbox_pt + $bbox_pb);
+ }
+ if ($inner_w==='auto' && $bbox_left==='auto') {
+ $x = $cont_x + $bbox_ml + $bbox_bl + $bbox_pl;
+ $w = $cont_w - ($bbox_right + $bbox_ml + $bbox_mr + $bbox_bl + $bbox_br + $bbox_pl + $bbox_pr);
+ }
+ else if ($inner_w==='auto' && $bbox_right==='auto') {
+ $x = $cont_x + $bbox_left + $bbox_ml + $bbox_bl + $bbox_pl;
+ $w = $cont_w - ($bbox_left + $bbox_ml + $bbox_mr + $bbox_bl + $bbox_br + $bbox_pl + $bbox_pr);
+ }
+ $bbox_y = $cont_y + $bbox_top + $bbox_mt;
+ $bbox_x = $cont_x + $bbox_left + $bbox_ml;
+ $saved_block1 = $this->blk[1];
+ unset($p);
+ unset($pb);
+ //================================================================
+ if ($inner_w==='auto') { // do a first write
+ $this->lMargin=$x;
+ $this->rMargin=$this->w - $w - $x;
+ // SET POSITION & FONT VALUES
+ $this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
+ $this->pageoutput[$this->page]=array();
+ $this->x = $x;
+ $this->y = $y;
+ $this->HTMLheaderPageLinks = array();
+ $this->HTMLheaderPageAnnots = array();
+ $this->HTMLheaderPageForms = array();
+ $this->pageBackgrounds = array();
+ $this->maxPosR = 0;
+ $this->maxPosL = $this->w; // For RTL
+ $this->WriteHTML($html , 4);
+ $inner_w = $this->maxPosR - $this->lMargin;
+ if ($bbox_right==='auto') {
+ $bbox_right = $cont_w - $bbox_left - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_ml;
+ }
+ else if ($bbox_left==='auto') {
+ $bbox_left = $cont_w - $bbox_ml - $bbox_bl - $bbox_pl - $inner_w - $bbox_pr - $bbox_br - $bbox_ml - $bbox_right;
+ $bbox_x = $cont_x + $bbox_left + $bbox_ml ;
+ $inner_x = $bbox_x + $bbox_bl + $bbox_pl;
+ $x = $inner_x;
+ }
+ $w = $inner_w;
+ $bbox_y = $cont_y + $bbox_top + $bbox_mt;
+ $bbox_x = $cont_x + $bbox_left + $bbox_ml;
+ }
+
+ if ($inner_h==='auto') { // do a first write
+ $this->lMargin=$x;
+ $this->rMargin=$this->w - $w - $x;
+ // SET POSITION & FONT VALUES
+ $this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
+ $this->pageoutput[$this->page]=array();
+ $this->x = $x;
+ $this->y = $y;
+ $this->HTMLheaderPageLinks = array();
+ $this->HTMLheaderPageAnnots = array();
+ $this->HTMLheaderPageForms = array();
+ $this->pageBackgrounds = array();
+ $this->WriteHTML($html , 4);
+ $inner_h = $this->y - $y;
+ if ($overflow!='hidden' && $overflow!='visible') { // constrained
+ if (($this->y + $bbox_pb + $bbox_bb) > ($cont_y + $cont_h)) {
+ $adj = ($this->y + $bbox_pb + $bbox_bb) - ($cont_y + $cont_h);
+ $inner_h -= $adj;
+ }
+ }
+ if ($bbox_bottom==='auto' && $bbox_top_orig==='auto') {
+ $bbox_bottom = $bbox_top = ($cont_h - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mb)/2;
+ if ($overflow!='hidden' && $overflow!='visible') { // constrained
+ if ($bbox_top < 0) {
+ $bbox_top = 0;
+ $inner_h = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $bbox_pb - $bbox_bb - $bbox_mb - $bbox_bottom;
+ }
+ }
+ $bbox_y = $cont_y + $bbox_top + $bbox_mt;
+ $inner_y = $bbox_y + $bbox_bt + $bbox_pt;
+ $y = $inner_y;
+
+ }
+ else if ($bbox_bottom==='auto') {
+ $bbox_bottom = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mb;
+ }
+ else if ($bbox_top==='auto') {
+ $bbox_top = $cont_h - $bbox_mt - $bbox_bt - $bbox_pt - $inner_h - $bbox_pb - $bbox_bb - $bbox_mb - $bbox_bottom;
+ if ($overflow!='hidden' && $overflow!='visible') { // constrained
+ if ($bbox_top < 0) {
+ $bbox_top = 0;
+ $inner_h = $cont_h - $bbox_top - $bbox_mt - $bbox_bt - $bbox_pt - $bbox_pb - $bbox_bb - $bbox_mb - $bbox_bottom;
+ }
+ }
+ $bbox_y = $cont_y + $bbox_top + $bbox_mt;
+ $inner_y = $bbox_y + $bbox_bt + $bbox_pt;
+ $y = $inner_y;
+ }
+ $h = $inner_h;
+ $bbox_y = $cont_y + $bbox_top + $bbox_mt;
+ $bbox_x = $cont_x + $bbox_left + $bbox_ml;
+ }
+ $inner_w = $w;
+ $inner_h = $h;
+
+ }
+ $this->lMargin=$x;
+ $this->rMargin=$this->w - $w - $x;
+ // SET POSITION & FONT VALUES
+ $this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
+ $this->pageoutput[$this->page]=array();
+ $this->x = $x;
+ $this->y = $y;
+ $this->HTMLheaderPageLinks = array();
+ $this->HTMLheaderPageAnnots = array();
+ $this->HTMLheaderPageForms = array();
+ $this->pageBackgrounds = array();
+ $this->WriteHTML($html , 4); // parameter 4 saves output to $this->headerbuffer
+ $actual_h = $this->y - $y;
+ $use_w = $w;
+ $use_h = $h;
+ $ratio = $actual_h / $use_w;
+
+ if ($overflow!='hidden' && $overflow!='visible') {
+ $target = $h/$w;
+ if (($ratio / $target ) > 1) {
+ $nl = CEIL($actual_h / $this->lineheight);
+ $l = $use_w * $nl;
+ $est_w = sqrt(($l * $this->lineheight) / $target) * 0.8;
+ $use_w += ($est_w - $use_w) - ($w/100);
+ }
+ $bpcstart = ($ratio / $target);
+ $bpcctr = 1;
+ while(($ratio / $target ) > 1) {
+
+ if ($this->progressBar) { $this->UpdateProgressBar(4,intval(100/($ratio/$target)),('Auto-sizing fixed-position block: '.$bpcctr++)); } // *PROGRESS-BAR*
+
+ $this->x = $x;
+ $this->y = $y;
+
+ if (($ratio / $target) > 1.5 || ($ratio / $target) < 0.6) {
+ $use_w += ($w/$this->incrementFPR1);
+ }
+ else if (($ratio / $target) > 1.2 || ($ratio / $target) < 0.85) {
+ $use_w += ($w/$this->incrementFPR2);
+ }
+ else if (($ratio / $target) > 1.1 || ($ratio / $target) < 0.91) {
+ $use_w += ($w/$this->incrementFPR3);
+ }
+ else {
+ $use_w += ($w/$this->incrementFPR4);
+ }
+
+ $use_h = $use_w * $target ;
+ $this->rMargin=$this->w - $use_w - $x;
+ $this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
+ $this->HTMLheaderPageLinks = array();
+ $this->HTMLheaderPageAnnots = array();
+ $this->HTMLheaderPageForms = array();
+ $this->pageBackgrounds = array();
+ $this->WriteHTML($html , 4); // parameter 4 saves output to $this->headerbuffer
+ $actual_h = $this->y - $y;
+ $ratio = $actual_h / $use_w;
+ }
+ if ($this->progressBar) { $this->UpdateProgressBar(4,'100',' '); } // *PROGRESS-BAR*
+ }
+ $shrink_f = $w/$use_w;
+
+ //================================================================
+
+ $this->pages[$this->page] .= '___BEFORE_BORDERS___';
+ $block_s = $this->PrintPageBackgrounds(); // Save to print later inside clipping path
+ $this->pageBackgrounds = array();
+
+ //================================================================
+
+ if ($rotate) {
+ $prerotw = $bbox_bl + $bbox_pl + $inner_w + $bbox_pr + $bbox_br;
+ $preroth = $bbox_bt + $bbox_pt + $inner_h + $bbox_pb + $bbox_bb;
+ $rot_start = " q\n";
+ if ($rotate == 90) {
+ if ($rot_rpos !== false) { $adjw = $prerotw; } // width before rotation
+ else { $adjw = $preroth; } // height before rotation
+ if ($rot_bpos !== false) { $adjh = -$prerotw + $preroth; }
+ else { $adjh = 0; }
+ }
+ else {
+ if ($rot_rpos !== false) { $adjw = $prerotw - $preroth; }
+ else { $adjw = 0; }
+ if ($rot_bpos !== false) { $adjh = $preroth; } // height before rotation
+ else { $adjh = $prerotw; } // width before rotation
+ }
+ $rot_start .= $this->transformTranslate($adjw, $adjh, true)."\n";
+ $rot_start .= $this->transformRotate($rotate, $bbox_x, $bbox_y, true)."\n";
+ $rot_end = " Q\n";
+ }
+ else {
+ $rot_start = '';
+ $rot_end = '';
+ }
+
+ //================================================================
+ if (!empty($bounding)) {
+ // WHEN HEIGHT // BOTTOM EDGE IS KNOWN and $this->y is set to the bottom
+ // Re-instate saved $this->blk[1]
+ $this->blk[1] = $saved_block1;
+
+ // These are only needed when painting border/background
+ $this->blk[1]['width'] = $bbox_w = $cont_w - $bbox_left - $bbox_ml - $bbox_mr - $bbox_right;
+ $this->blk[1]['x0'] = $bbox_x;
+ $this->blk[1]['y0'] = $bbox_y;
+ $this->blk[1]['startpage'] = $this->page;
+ $this->blk[1]['y1'] = $bbox_y + $bbox_bt + $bbox_pt + $inner_h + $bbox_pb + $bbox_bb ;
+ $this->_out($rot_start); // mPDF 5.0
+ $this->PaintDivBB('',0,1); // Prints borders and sets backgrounds in $this->pageBackgrounds
+ $this->_out($rot_end);
+ }
+
+ $s = $this->PrintPageBackgrounds();
+ $s = $rot_start.$s.$rot_end;
+ $this->pages[$this->page] = preg_replace('/___BEFORE_BORDERS___/', "\n".$s."\n", $this->pages[$this->page]);
+ $this->pageBackgrounds = array();
+
+ $this->_out($rot_start);
+
+ // Clipping Output
+ if ($overflow=='hidden') {
+ //Bounding rectangle to clip
+ $clip_y1 = $this->y;
+ if (!empty($bounding) && ($this->y + $bbox_pb + $bbox_bb) > ($bbox_y + $bbox_bt + $bbox_pt + $inner_h + $bbox_pb + $bbox_bb )) {
+ $clip_y1 = ($bbox_y + $bbox_bt + $bbox_pt + $inner_h + $bbox_pb + $bbox_bb ) - ($bbox_pb + $bbox_bb);
+ }
+ //$op = 'W* n'; // Clipping
+ $op = 'W n'; // Clipping alternative mode
+ $this->_out("q");
+ $ch = $clip_y1 - $y;
+ $this->_out(sprintf('%.3F %.3F %.3F %.3F re %s',$x*_MPDFK,($this->h-$y)*_MPDFK,$w*_MPDFK,-$ch*_MPDFK,$op));
+ if (!empty($block_s)) {
+ $tmp = "q\n".sprintf('%.3F %.3F %.3F %.3F re %s',$x*_MPDFK,($this->h-$y)*_MPDFK,$w*_MPDFK,-$ch*_MPDFK,$op);
+ $tmp .= "\n".$block_s."\nQ";
+ $block_s = $tmp ;
+ }
+ }
+
+
+ if (!empty($block_s)) {
+ if ($shrink_f != 1) { // i.e. autofit has resized the box
+ $tmp = "q\n".$this->transformScale(($shrink_f*100),($shrink_f*100), $x, $y, true);
+ $tmp .= "\n".$block_s."\nQ";
+ $block_s = $tmp ;
+ }
+ $this->_out($block_s);
+ }
+
+
+
+ if ($shrink_f != 1) { // i.e. autofit has resized the box
+ $this->StartTransform();
+ $this->transformScale(($shrink_f*100),($shrink_f*100), $x, $y);
+ }
+
+ $this->_out($this->headerbuffer);
+
+ if ($shrink_f != 1) { // i.e. autofit has resized the box
+ $this->StopTransform();
+ }
+
+ if ($overflow=='hidden') {
+ //End clipping
+ $this->_out("Q");
+ }
+
+ $this->_out($rot_end);
+
+
+ // Page Links
+ foreach($this->HTMLheaderPageLinks AS $lk) {
+ if ($rotate) {
+ $tmp = $lk[2]; // Switch h - w
+ $lk[2] = $lk[3];
+ $lk[3] = $tmp;
+
+ $lx1 = (($lk[0]/_MPDFK));
+ $ly1 = (($this->h-($lk[1]/_MPDFK)));
+ if ($rotate == 90) {
+ $adjx = -($lx1-$bbox_x) + ($preroth - ($ly1-$bbox_y));
+ $adjy = -($ly1-$bbox_y) + ($lx1-$bbox_x);
+ $lk[2] = -$lk[2];
+ }
+ else if ($rotate == -90) {
+ $adjx = -($lx1-$bbox_x) + ($ly1-$bbox_y);
+ $adjy = -($ly1-$bbox_y) - ($lx1-$bbox_x) + $prerotw;
+ $lk[3] = -$lk[3];
+ }
+ if ($rot_rpos !== false) { $adjx += $prerotw - $preroth; }
+ if ($rot_bpos !== false) { $adjy += $preroth - $prerotw; }
+ $lx1 += $adjx;
+ $ly1 += $adjy;
+
+ $lk[0] = $lx1*_MPDFK;
+ $lk[1] = ($this->h-$ly1)*_MPDFK;
+ }
+ if ($shrink_f != 1) { // i.e. autofit has resized the box
+ $lx1 = (($lk[0]/_MPDFK)-$x);
+ $lx2 = $x + ($lx1 * $shrink_f);
+ $lk[0] = $lx2*_MPDFK;
+ $ly1 = (($this->h-($lk[1]/_MPDFK))-$y);
+ $ly2 = $y + ($ly1 * $shrink_f);
+ $lk[1] = ($this->h-$ly2)*_MPDFK;
+ $lk[2] *= $shrink_f; // width
+ $lk[3] *= $shrink_f; // height
+ }
+ $this->PageLinks[$this->page][]=$lk;
+ }
+
+ foreach($this->HTMLheaderPageForms AS $n=>$f) {
+ if ($shrink_f != 1) { // i.e. autofit has resized the box
+ $f['x'] = $x + (($f['x'] -$x) * $shrink_f);
+ $f['y'] = $y + (($f['y'] -$y) * $shrink_f);
+ $f['w'] *= $shrink_f;
+ $f['h'] *= $shrink_f;
+ $f['style']['fontsize'] *= $shrink_f;
+ }
+ $this->form->forms[$f['n']] = $f;
+ }
+ // Page Annotations
+ foreach($this->HTMLheaderPageAnnots AS $lk) {
+ if ($rotate) {
+ if ($rotate == 90) {
+ $adjx = -($lk['x']-$bbox_x) + ($preroth - ($lk['y']-$bbox_y));
+ $adjy = -($lk['y']-$bbox_y) + ($lk['x']-$bbox_x);
+ }
+ else if ($rotate == -90) {
+ $adjx = -($lk['x']-$bbox_x) + ($lk['y']-$bbox_y);
+ $adjy = -($lk['y']-$bbox_y) - ($lk['x']-$bbox_x) + $prerotw;
+ }
+ if ($rot_rpos !== false) { $adjx += $prerotw - $preroth; }
+ if ($rot_bpos !== false) { $adjy += $preroth - $prerotw; }
+ $lk['x'] += $adjx;
+ $lk['y'] += $adjy;
+ }
+ if ($shrink_f != 1) { // i.e. autofit has resized the box
+ $lk['x'] = $x + (($lk['x']-$x) * $shrink_f);
+ $lk['y'] = $y + (($lk['y']-$y) * $shrink_f);
+ }
+ $this->PageAnnots[$this->page][]=$lk;
+ }
+
+ // Restore
+ $this->headerbuffer = '';
+ $this->HTMLheaderPageLinks = array();
+ $this->HTMLheaderPageAnnots = array();
+ $this->HTMLheaderPageForms = array();
+ $this->pageBackgrounds = $save_bgs;
+ $this->writingHTMLheader = false;
+
+ $this->writingHTMLfooter = false;
+ $this->fullImageHeight = false;
+ $this->ResetMargins();
+ $this->pgwidth = $this->w - $this->lMargin - $this->rMargin;
+ $this->SetXY($save_x,$save_y) ;
+ $this->title2annots = $save_annots; // *ANNOTATIONS*
+ $this->InFooter = false; // turns back on autopagebreaks
+ $this->pageoutput[$this->page]=array();
+ $this->pageoutput[$this->page]['Font']='';
+/*-- COLUMNS --*/
+ if ($save_cols) {
+ $this->SetColumns($save_nbcol,$this->colvAlign,$this->ColGap);
+ }
+/*-- END COLUMNS --*/
+}
+/*-- END CSS-POSITION --*/
+
+
+
+function initialiseBlock(&$blk) {
+ $blk['margin_top'] = 0;
+ $blk['margin_left'] = 0;
+ $blk['margin_bottom'] = 0;
+ $blk['margin_right'] = 0;
+ $blk['padding_top'] = 0;
+ $blk['padding_left'] = 0;
+ $blk['padding_bottom'] = 0;
+ $blk['padding_right'] = 0;
+ $blk['border_top']['w'] = 0;
+ $blk['border_left']['w'] = 0;
+ $blk['border_bottom']['w'] = 0;
+ $blk['border_right']['w'] = 0;
+ $blk['hide'] = false;
+ $blk['outer_left_margin'] = 0;
+ $blk['outer_right_margin'] = 0;
+ $blk['cascadeCSS'] = array();
+ $blk['block-align'] = false;
+ $blk['bgcolor'] = false;
+ $blk['page_break_after_avoid'] = false;
+ $blk['keep_block_together'] = false;
+ $blk['float'] = false;
+ $blk['line_height'] = '';
+ $blk['margin_collapse'] = false;
+}
+
+
+function border_details($bd) {
+ $prop = preg_split('/\s+/',trim($bd));
+
+ if (isset($this->blk[$this->blklvl]['inner_width'])) { $refw = $this->blk[$this->blklvl]['inner_width']; }
+ else if (isset($this->blk[$this->blklvl-1]['inner_width'])) { $refw = $this->blk[$this->blklvl-1]['inner_width']; }
+ else { $refw = $this->w; }
+ if ( count($prop) == 1 ) {
+ $bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
+ if ($bsize > 0) {
+ return array('s' => 1, 'w' => $bsize, 'c' => $this->ConvertColor(0), 'style'=>'solid');
+ }
+ else { return array('w' => 0, 's' => 0); }
+ }
+
+ else if (count($prop) == 2 ) {
+ // 1px solid
+ if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $prop[2] = ''; }
+ // solid #000000
+ else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $prop[0] = ''; $prop[1] = $prop[0]; $prop[2] = $prop[1]; }
+ // 1px #000000
+ else { $prop[1] = ''; $prop[2] = $prop[1]; }
+ }
+ else if ( count($prop) == 3 ) {
+ // Change #000000 1px solid to 1px solid #000000 (proper)
+ if (substr($prop[0],0,1) == '#') { $tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $prop[2]; $prop[2] = $tmp; }
+ // Change solid #000000 1px to 1px solid #000000 (proper)
+ else if (substr($prop[0],1,1) == '#') { $tmp = $prop[1]; $prop[0] = $prop[2]; $prop[1] = $prop[0]; $prop[2] = $tmp; }
+ // Change solid 1px #000000 to 1px solid #000000 (proper)
+ else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
+ $tmp = $prop[0]; $prop[0] = $prop[1]; $prop[1] = $tmp;
+ }
+ }
+ else { return array(); }
+ // Size
+ $bsize = $this->ConvertSize($prop[0],$refw,$this->FontSize,false);
+ //color
+ $coul = $this->ConvertColor($prop[2]); // returns array
+ // Style
+ $prop[1] = strtolower($prop[1]);
+ if (in_array($prop[1],$this->borderstyles) && $bsize > 0) { $on = 1; }
+ else if ($prop[1] == 'hidden') { $on = 1; $bsize = 0; $coul = ''; }
+ else if ($prop[1] == 'none') { $on = 0; $bsize = 0; $coul = ''; }
+ else { $on = 0; $bsize = 0; $coul = ''; $prop[1] = ''; }
+ return array('s' => $on, 'w' => $bsize, 'c' => $coul, 'style'=> $prop[1] );
+}
+
+
+
+/*-- END HTML-CSS --*/
+
+
+// Return either a number (factor) - based on current set fontsize (if % or em) - or exact lineheight (with 'mm' after it)
+function fixLineheight($v) {
+ $lh = false;
+ if (preg_match('/^[0-9\.,]*$/',$v) && $v >= 0) { return ($v + 0); }
+ else if (strtoupper($v) == 'NORMAL') {
+ return $this->normalLineheight;
+ }
+ else {
+ $tlh = $this->ConvertSize($v,$this->FontSize,$this->FontSize,true);
+ if ($tlh) { return ($tlh.'mm'); }
+ }
+ return $this->normalLineheight;
+}
+
+
+/*-- BORDER-RADIUS --*/
+function _borderPadding($a, $b, &$px, &$py) {
+ // $px and py are padding long axis (x) and short axis (y)
+ $added = 0; // extra padding
+
+ $x = $a-$px;
+ $y = $b-$py;
+ // Check if Falls within ellipse of border radius
+ if ( ( (($x+$added)*($x+$added))/($a*$a) + (($y+$added)*($y+$added))/($b*$b) ) <=1 ) { return false; }
+
+ $t = atan2($y,$x);
+
+ $newx = $b / sqrt((($b*$b)/($a*$a)) + ( tan($t) * tan($t) ) );
+ $newy = $a / sqrt((($a*$a)/($b*$b)) + ( (1/tan($t)) * (1/tan($t)) ) );
+ $px = max($px, $a - $newx + $added);
+ $py = max($py, $b - $newy + $added);
+}
+/*-- END BORDER-RADIUS --*/
+
+
+
+/*-- HTML-CSS --*/
+
+
+/*-- CSS-PAGE --*/
+function SetPagedMediaCSS($name='', $first, $oddEven) {
+ if ($oddEven == 'E') {
+ if ($this->directionality=='rtl') { $side = 'R'; }
+ else { $side = 'L'; }
+ }
+ else {
+ if ($this->directionality=='rtl') { $side = 'L'; }
+ else { $side = 'R'; }
+ }
+ $name = strtoupper($name);
+ $p = array();
+ $p['SIZE'] = 'AUTO';
+
+ // Uses mPDF original margins as default
+ $p['MARGIN-RIGHT'] = strval($this->orig_rMargin).'mm';
+ $p['MARGIN-LEFT'] = strval($this->orig_lMargin).'mm';
+ $p['MARGIN-TOP'] = strval($this->orig_tMargin).'mm';
+ $p['MARGIN-BOTTOM'] = strval($this->orig_bMargin).'mm';
+ $p['MARGIN-HEADER'] = strval($this->orig_hMargin).'mm';
+ $p['MARGIN-FOOTER'] = strval($this->orig_fMargin).'mm';
+
+ // Basic page + selector
+ if (isset($this->cssmgr->CSS['@PAGE'])) { $zp = $this->cssmgr->CSS['@PAGE']; }
+ else { $zp = array(); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ if (isset($p['EVEN-HEADER-NAME']) && $oddEven=='E') {
+ $p['HEADER'] = $p['EVEN-HEADER-NAME']; unset($p['EVEN-HEADER-NAME']);
+ }
+ if (isset($p['ODD-HEADER-NAME']) && $oddEven!='E') {
+ $p['HEADER'] = $p['ODD-HEADER-NAME']; unset($p['ODD-HEADER-NAME']);
+ }
+ if (isset($p['EVEN-FOOTER-NAME']) && $oddEven=='E') {
+ $p['FOOTER'] = $p['EVEN-FOOTER-NAME']; unset($p['EVEN-FOOTER-NAME']);
+ }
+ if (isset($p['ODD-FOOTER-NAME']) && $oddEven!='E') {
+ $p['FOOTER'] = $p['ODD-FOOTER-NAME']; unset($p['ODD-FOOTER-NAME']);
+ }
+
+ // If right/Odd page
+ if (isset($this->cssmgr->CSS['@PAGE>>PSEUDO>>RIGHT']) && $side=='R') {
+ $zp = $this->cssmgr->CSS['@PAGE>>PSEUDO>>RIGHT'];
+ }
+ else { $zp = array(); }
+ if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
+ if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); }
+ // Disallow margin-left or -right on :LEFT or :RIGHT
+ if (isset($zp['MARGIN-LEFT'])) { unset($zp['MARGIN-LEFT']); }
+ if (isset($zp['MARGIN-RIGHT'])) { unset($zp['MARGIN-RIGHT']); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ // If left/Even page
+ if (isset($this->cssmgr->CSS['@PAGE>>PSEUDO>>LEFT']) && $side=='L') {
+ $zp = $this->cssmgr->CSS['@PAGE>>PSEUDO>>LEFT'];
+ }
+ else { $zp = array(); }
+ if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
+ if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); }
+ // Disallow margin-left or -right on :LEFT or :RIGHT
+ if (isset($zp['MARGIN-LEFT'])) { unset($zp['MARGIN-LEFT']); }
+ if (isset($zp['MARGIN-RIGHT'])) { unset($zp['MARGIN-RIGHT']); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ // If first page
+ if (isset($this->cssmgr->CSS['@PAGE>>PSEUDO>>FIRST']) && $first) { $zp = $this->cssmgr->CSS['@PAGE>>PSEUDO>>FIRST']; }
+ else { $zp = array(); }
+ if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
+ if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ // If named page
+ if ($name) {
+ if (isset($this->cssmgr->CSS['@PAGE>>NAMED>>'.$name])) { $zp = $this->cssmgr->CSS['@PAGE>>NAMED>>'.$name]; }
+ else { $zp = array(); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ if (isset($p['EVEN-HEADER-NAME']) && $oddEven=='E') {
+ $p['HEADER'] = $p['EVEN-HEADER-NAME']; unset($p['EVEN-HEADER-NAME']);
+ }
+ if (isset($p['ODD-HEADER-NAME']) && $oddEven!='E') {
+ $p['HEADER'] = $p['ODD-HEADER-NAME']; unset($p['ODD-HEADER-NAME']);
+ }
+ if (isset($p['EVEN-FOOTER-NAME']) && $oddEven=='E') {
+ $p['FOOTER'] = $p['EVEN-FOOTER-NAME']; unset($p['EVEN-FOOTER-NAME']);
+ }
+ if (isset($p['ODD-FOOTER-NAME']) && $oddEven!='E') {
+ $p['FOOTER'] = $p['ODD-FOOTER-NAME']; unset($p['ODD-FOOTER-NAME']);
+ }
+
+ // If named right/Odd page
+ if (isset($this->cssmgr->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>RIGHT']) && $side=='R') { $zp = $this->cssmgr->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>RIGHT']; }
+ else { $zp = array(); }
+ if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
+ if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); }
+ // Disallow margin-left or -right on :LEFT or :RIGHT
+ if (isset($zp['MARGIN-LEFT'])) { unset($zp['MARGIN-LEFT']); }
+ if (isset($zp['MARGIN-RIGHT'])) { unset($zp['MARGIN-RIGHT']); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ // If named left/Even page
+ if (isset($this->cssmgr->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>LEFT']) && $side=='L') { $zp = $this->cssmgr->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>LEFT']; }
+ else { $zp = array(); }
+ if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
+ if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); }
+ // Disallow margin-left or -right on :LEFT or :RIGHT
+ if (isset($zp['MARGIN-LEFT'])) { unset($zp['MARGIN-LEFT']); }
+ if (isset($zp['MARGIN-RIGHT'])) { unset($zp['MARGIN-RIGHT']); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+
+ // If named first page
+ if (isset($this->cssmgr->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>FIRST']) && $first) { $zp = $this->cssmgr->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>FIRST']; }
+ else { $zp = array(); }
+ if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
+ if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); }
+ if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
+ }
+
+ $orientation = $mgl = $mgr = $mgt = $mgb = $mgh = $mgf = '';
+ $header = $footer = '';
+ $resetpagenum = $pagenumstyle = $suppress = '';
+ $marks = '';
+ $bg = array();
+
+ $newformat = '';
+
+
+ if (isset($p['SHEET-SIZE']) && is_array($p['SHEET-SIZE'])) {
+ $newformat = $p['SHEET-SIZE'];
+ if ($newformat[0] > $newformat[1]) { // landscape
+ $newformat = array_reverse($newformat);
+ $p['ORIENTATION'] = 'L';
+ }
+ else { $p['ORIENTATION'] = 'P'; }
+ $this->_setPageSize($newformat, $p['ORIENTATION']);
+ }
+
+ if (isset($p['SIZE']) && is_array($p['SIZE']) && !$newformat) {
+ if ($p['SIZE']['W'] > $p['SIZE']['H']) { $p['ORIENTATION'] = 'L'; }
+ else { $p['ORIENTATION'] = 'P'; }
+ }
+ if (is_array($p['SIZE'])) {
+ if ($p['SIZE']['W'] > $this->fw) { $p['SIZE']['W'] = $this->fw; } // mPD 4.2 use fw not fPt
+ if ($p['SIZE']['H'] > $this->fh) { $p['SIZE']['H'] = $this->fh; }
+ if (($p['ORIENTATION']==$this->DefOrientation && !$newformat) || ($newformat && $p['ORIENTATION']=='P')) {
+ $outer_width_LR = ($this->fw - $p['SIZE']['W'])/2;
+ $outer_width_TB = ($this->fh - $p['SIZE']['H'])/2;
+ }
+ else {
+ $outer_width_LR = ($this->fh - $p['SIZE']['W'])/2;
+ $outer_width_TB = ($this->fw - $p['SIZE']['H'])/2;
+ }
+ $pgw = $p['SIZE']['W'];
+ $pgh = $p['SIZE']['H'];
+ }
+ else { // AUTO LANDSCAPE PORTRAIT
+ $outer_width_LR = 0;
+ $outer_width_TB = 0;
+ if (!$newformat) {
+ if (strtoupper($p['SIZE']) == 'AUTO') { $p['ORIENTATION']=$this->DefOrientation; }
+ else if (strtoupper($p['SIZE']) == 'LANDSCAPE') { $p['ORIENTATION']='L'; }
+ else { $p['ORIENTATION']='P'; }
+ }
+ if (($p['ORIENTATION']==$this->DefOrientation && !$newformat) || ($newformat && $p['ORIENTATION']=='P')) {
+ $pgw = $this->fw;
+ $pgh = $this->fh;
+ }
+ else {
+ $pgw = $this->fh;
+ $pgh = $this->fw;
+ }
+ }
+
+ if (isset($p['HEADER']) && $p['HEADER']) { $header = $p['HEADER']; }
+ if (isset($p['FOOTER']) && $p['FOOTER']) { $footer = $p['FOOTER']; }
+ if (isset($p['RESETPAGENUM']) && $p['RESETPAGENUM']) { $resetpagenum = $p['RESETPAGENUM']; }
+ if (isset($p['PAGENUMSTYLE']) && $p['PAGENUMSTYLE']) { $pagenumstyle = $p['PAGENUMSTYLE']; }
+ if (isset($p['SUPPRESS']) && $p['SUPPRESS']) { $suppress = $p['SUPPRESS']; }
+
+ if (preg_match('/cross/i', $p['MARKS']) && preg_match('/crop/i', $p['MARKS'])) { $marks = 'CROPCROSS'; }
+ else if (strtoupper($p['MARKS']) == 'CROP') { $marks = 'CROP'; }
+ else if (strtoupper($p['MARKS']) == 'CROSS') { $marks = 'CROSS'; }
+
+
+ if (isset($p['BACKGROUND-COLOR']) && $p['BACKGROUND-COLOR']) { $bg['BACKGROUND-COLOR'] = $p['BACKGROUND-COLOR']; }
+/*-- BACKGROUNDS --*/
+ if (isset($p['BACKGROUND-GRADIENT']) && $p['BACKGROUND-GRADIENT']) { $bg['BACKGROUND-GRADIENT'] = $p['BACKGROUND-GRADIENT']; }
+ if (isset($p['BACKGROUND-IMAGE']) && $p['BACKGROUND-IMAGE']) { $bg['BACKGROUND-IMAGE'] = $p['BACKGROUND-IMAGE']; }
+ if (isset($p['BACKGROUND-REPEAT']) && $p['BACKGROUND-REPEAT']) { $bg['BACKGROUND-REPEAT'] = $p['BACKGROUND-REPEAT']; }
+ if (isset($p['BACKGROUND-POSITION']) && $p['BACKGROUND-POSITION']) { $bg['BACKGROUND-POSITION'] = $p['BACKGROUND-POSITION']; }
+ if (isset($p['BACKGROUND-IMAGE-RESIZE']) && $p['BACKGROUND-IMAGE-RESIZE']) { $bg['BACKGROUND-IMAGE-RESIZE'] = $p['BACKGROUND-IMAGE-RESIZE']; }
+ if (isset($p['BACKGROUND-IMAGE-OPACITY'])) { $bg['BACKGROUND-IMAGE-OPACITY'] = $p['BACKGROUND-IMAGE-OPACITY']; }
+/*-- END BACKGROUNDS --*/
+
+ if (isset($p['MARGIN-LEFT'])) { $mgl = $this->ConvertSize($p['MARGIN-LEFT'],$pgw) + $outer_width_LR; }
+ if (isset($p['MARGIN-RIGHT'])) { $mgr = $this->ConvertSize($p['MARGIN-RIGHT'],$pgw) + $outer_width_LR; }
+ if (isset($p['MARGIN-BOTTOM'])) { $mgb = $this->ConvertSize($p['MARGIN-BOTTOM'],$pgh) + $outer_width_TB; }
+ if (isset($p['MARGIN-TOP'])) { $mgt = $this->ConvertSize($p['MARGIN-TOP'],$pgh) + $outer_width_TB; }
+ if (isset($p['MARGIN-HEADER'])) { $mgh = $this->ConvertSize($p['MARGIN-HEADER'],$pgh) + $outer_width_TB; }
+ if (isset($p['MARGIN-FOOTER'])) { $mgf = $this->ConvertSize($p['MARGIN-FOOTER'],$pgh) + $outer_width_TB; }
+
+ if (isset($p['ORIENTATION']) && $p['ORIENTATION']) { $orientation = $p['ORIENTATION']; }
+ $this->page_box['outer_width_LR'] = $outer_width_LR; // Used in MARKS:crop etc.
+ $this->page_box['outer_width_TB'] = $outer_width_TB;
+
+ return array($orientation,$mgl,$mgr,$mgt,$mgb,$mgh,$mgf,$header,$footer,$bg,$resetpagenum,$pagenumstyle,$suppress,$marks,$newformat);
+}
+/*-- END CSS-PAGE --*/
+
+
+
+/*-- CSS-FLOAT --*/
+// Added mPDF 3.0 Float DIV - CLEAR
+function ClearFloats($clear, $blklvl=0) {
+ list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($blklvl,true);
+ $end = $currpos = ($this->page*1000 + $this->y);
+ if ($clear == 'BOTH' && ($l_exists || $r_exists)) {
+ $this->pageoutput[$this->page] = array();
+ $end = max($l_max, $r_max, $currpos);
+ }
+ else if ($clear == 'RIGHT' && $r_exists) {
+ $this->pageoutput[$this->page] = array();
+ $end = max($r_max, $currpos);
+ }
+ else if ($clear == 'LEFT' && $l_exists ) {
+ $this->pageoutput[$this->page] = array();
+ $end = max($l_max, $currpos);
+ }
+ else { return; }
+ $old_page = $this->page;
+ $new_page = intval($end/1000);
+ if ($old_page != $new_page) {
+ $s = $this->PrintPageBackgrounds();
+ // Writes after the marker so not overwritten later by page background etc.
+ $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+ $this->pageBackgrounds = array();
+ $this->page = $new_page;
+ }
+ $this->ResetMargins();
+ $this->pageoutput[$this->page] = array();
+ $this->y = (($end*1000) % 1000000)/1000; // mod changes operands to integers before processing
+}
+
+
+// Added mPDF 3.0 Float DIV
+function GetFloatDivInfo($blklvl=0,$clear=false) {
+ // If blklvl specified, only returns floats at that level - for ClearFloats
+ $l_exists = false;
+ $r_exists = false;
+ $l_max = 0;
+ $r_max = 0;
+ $l_width = 0;
+ $r_width = 0;
+ if (count($this->floatDivs)) {
+ $currpos = ($this->page*1000 + $this->y);
+ foreach($this->floatDivs AS $f) {
+ if (($clear && $f['blockContext'] == $this->blk[$blklvl]['blockContext']) || (!$clear && $currpos >= $f['startpos'] && $currpos < ($f['endpos']-0.001) && $f['blklvl'] > $blklvl && $f['blockContext'] == $this->blk[$blklvl]['blockContext'])) {
+ if ($f['side']=='L') {
+ $l_exists= true;
+ $l_max = max($l_max, $f['endpos']);
+ $l_width = max($l_width , $f['w']);
+ }
+ if ($f['side']=='R') {
+ $r_exists= true;
+ $r_max = max($r_max, $f['endpos']);
+ $r_width = max($r_width , $f['w']);
+ }
+ }
+ }
+ }
+ return array($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width);
+}
+/*-- END CSS-FLOAT --*/
+
+
+
+
+function OpenTag($tag,$attr)
+{
+
+ // What this gets: < $tag $attr['WIDTH']="90px" > does not get content here
+ // Correct tags where HTML specifies optional end tags,
+ // and/or does not allow nesting e.g. P inside P, or
+ if ($this->allow_html_optional_endtags) {
+ if (($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' ) && $this->lastoptionaltag == 'P') { $this->CloseTag($this->lastoptionaltag ); }
+ if ($tag == 'DD' && $this->lastoptionaltag == 'DD') { $this->CloseTag($this->lastoptionaltag ); }
+ if ($tag == 'DD' && $this->lastoptionaltag == 'DT') { $this->CloseTag($this->lastoptionaltag ); }
+ if ($tag == 'DT' && $this->lastoptionaltag == 'DD') { $this->CloseTag($this->lastoptionaltag ); }
+ if ($tag == 'DT' && $this->lastoptionaltag == 'DT') { $this->CloseTag($this->lastoptionaltag ); }
+ if ($tag == 'LI' && $this->lastoptionaltag == 'LI') { $this->CloseTag($this->lastoptionaltag ); }
+ if (($tag == 'TD' || $tag == 'TH') && $this->lastoptionaltag == 'TD') { $this->CloseTag($this->lastoptionaltag ); } // *TABLES*
+ if (($tag == 'TD' || $tag == 'TH') && $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); } // *TABLES*
+ if ($tag == 'TR' && $this->lastoptionaltag == 'TR') { $this->CloseTag($this->lastoptionaltag ); } // *TABLES*
+ if ($tag == 'TR' && $this->lastoptionaltag == 'TD') { $this->CloseTag($this->lastoptionaltag ); $this->CloseTag('TR'); $this->CloseTag('THEAD'); } // *TABLES*
+ if ($tag == 'TR' && $this->lastoptionaltag == 'TH') { $this->CloseTag($this->lastoptionaltag ); $this->CloseTag('TR'); $this->CloseTag('THEAD'); } // *TABLES*
+ if ($tag == 'OPTION' && $this->lastoptionaltag == 'OPTION') { $this->CloseTag($this->lastoptionaltag ); }
+ }
+
+ $align = array('left'=>'L','center'=>'C','right'=>'R','top'=>'T','text-top'=>'TT','middle'=>'M','baseline'=>'BS','bottom'=>'B','text-bottom'=>'TB','justify'=>'J');
+
+ $this->ignorefollowingspaces=false;
+
+ //Opening tag
+ switch($tag){
+
+ case 'DOTTAB':
+ $objattr = array();
+ $objattr['type'] = 'dottab';
+ $dots=str_repeat('.', 3)." "; // minimum number of dots
+ $objattr['width'] = $this->GetStringWidth($dots);
+ $objattr['margin_top'] = 0;
+ $objattr['margin_bottom'] = 0;
+ $objattr['margin_left'] = 0;
+ $objattr['margin_right'] = 0;
+ $objattr['height'] = 0;
+ $objattr['colorarray'] = $this->colorarray;
+ $objattr['border_top']['w'] = 0;
+ $objattr['border_bottom']['w'] = 0;
+ $objattr['border_left']['w'] = 0;
+ $objattr['border_right']['w'] = 0;
+
+ // mPDF 5.6.19
+ $properties = $this->cssmgr->MergeCSS('INLINE',$tag,$attr); // mPDF 5.6.33
+ if (isset($properties['OUTDENT'])) { // mPDF 5.6.33
+ $objattr['outdent'] = $this->ConvertSize($properties['OUTDENT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ else if (isset($attr['OUTDENT'])) {
+ $objattr['outdent'] = $this->ConvertSize($attr['OUTDENT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ else { $objattr['outdent'] = 0; }
+
+ $objattr['fontfamily'] = $this->FontFamily;
+ $objattr['fontsize'] = $this->FontSizePt;
+
+ $e = "\xbb\xa4\xactype=dottab,objattr=".serialize($objattr)."\xbb\xa4\xac";
+/*-- TABLES --*/
+ // Output it to buffers
+ if ($this->tableLevel) {
+ if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
+ $this->_saveCellTextBuffer($e);
+ }
+ else {
+/*-- END TABLES --*/
+ $this->_saveTextBuffer($e);
+ } // *TABLES*
+ break;
+
+ case 'PAGEHEADER':
+ case 'PAGEFOOTER':
+ $this->ignorefollowingspaces = true;
+ if ($attr['NAME']) { $pname = $attr['NAME']; }
+ else { $pname = '_default'; }
+
+ if ($tag=='PAGEHEADER') { $p = &$this->pageheaders[$pname]; }
+ else { $p = &$this->pagefooters[$pname]; }
+
+ $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->cssmgr->readInlineCSS($attr['HEADER-STYLE']); }
+ else { $properties = $this->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->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
+ $p['C']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * _MPDFK;
+ $p['R']['font-size'] = $this->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->cssmgr->readInlineCSS($attr['HEADER-STYLE-LEFT']); }
+ else { $properties = $this->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->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->cssmgr->readInlineCSS($attr['HEADER-STYLE-CENTER']); }
+ else { $properties = $this->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->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->cssmgr->readInlineCSS($attr['HEADER-STYLE-RIGHT']); }
+ else { $properties = $this->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->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;
+ }
+ break;
+
+
+/*-- HTMLHEADERS-FOOTERS --*/
+ case 'SETHTMLPAGEHEADER':
+ case 'SETHTMLPAGEFOOTER':
+ $this->ignorefollowingspaces = true;
+ if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; }
+ 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') { $write = 1; }
+ else { $write = 0; }
+ if ($side=='odd' || $side=='both') {
+ if ($set && $tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader($this->pageHTMLheaders[$pname],'O',$write); }
+ else if ($set && $tag=='SETHTMLPAGEFOOTER') { $this->SetHTMLFooter($this->pageHTMLfooters[$pname],'O'); }
+ else if ($tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader('','O'); }
+ else { $this->SetHTMLFooter('','O'); }
+ }
+ if ($side=='even' || $side=='both') {
+ if ($set && $tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader($this->pageHTMLheaders[$pname],'E',$write); }
+ else if ($set && $tag=='SETHTMLPAGEFOOTER') { $this->SetHTMLFooter($this->pageHTMLfooters[$pname],'E'); }
+ else if ($tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader('','E'); }
+ else { $this->SetHTMLFooter('','E'); }
+ }
+ break;
+/*-- END HTMLHEADERS-FOOTERS --*/
+
+ case 'SETPAGEHEADER':
+ case 'SETPAGEFOOTER':
+ $this->ignorefollowingspaces = true;
+ if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; }
+ 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 ($side=='odd' || $side=='both') {
+ if ($set && $tag=='SETPAGEHEADER') { $this->headerDetails['odd'] = $this->pageheaders[$pname]; }
+ else if ($set && $tag=='SETPAGEFOOTER') { $this->footerDetails['odd'] = $this->pagefooters[$pname]; }
+ else if ($tag=='SETPAGEHEADER') { $this->headerDetails['odd'] = array(); }
+ else { $this->footerDetails['odd'] = array(); }
+ if (!$this->mirrorMargins || ($this->page)%2!=0) { // ODD
+ if ($tag=='SETPAGEHEADER') { $this->_setAutoHeaderHeight($this->headerDetails['odd'],$this->HTMLHeader); }
+ if ($tag=='SETPAGEFOOTER') { $this->_setAutoFooterHeight($this->footerDetails['odd'],$this->HTMLFooter); }
+ }
+ }
+ if ($side=='even' || $side=='both') {
+ if ($set && $tag=='SETPAGEHEADER') { $this->headerDetails['even'] = $this->pageheaders[$pname]; }
+ else if ($set && $tag=='SETPAGEFOOTER') { $this->footerDetails['even'] = $this->pagefooters[$pname]; }
+ else if ($tag=='SETPAGEHEADER') { $this->headerDetails['even'] = array(); }
+ else { $this->footerDetails['even'] = array(); }
+ if ($this->mirrorMargins && ($this->page)%2==0) { // EVEN
+ if ($tag=='SETPAGEHEADER') { $this->_setAutoHeaderHeight($this->headerDetails['even'],$this->HTMLHeaderE); }
+ if ($tag=='SETPAGEFOOTER') { $this->_setAutoFooterHeight($this->footerDetails['even'],$this->HTMLFooterE); }
+ }
+ }
+ if (isset($attr['SHOW-THIS-PAGE']) && $attr['SHOW-THIS-PAGE'] && $tag=='SETPAGEHEADER') {
+ $this->Header();
+ }
+ 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->tocontents)) { $this->tocontents = new tocontents($this); }
+ $this->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->tocontents)) { $this->tocontents = new tocontents($this); }
+ list($isbreak,$toc_id) = $this->tocontents->openTagTOCPAGEBREAK($attr);
+ if ($isbreak) break;
+ // No break - continues as PAGEBREAK...
+/*-- END TOC --*/
+
+
+ case 'PAGE_BREAK': //custom-tag
+ case 'PAGEBREAK': //custom-tag
+ case 'NEWPAGE': //custom-tag
+ case 'FORMFEED': //custom-tag
+
+ $save_blklvl = $this->blklvl;
+ $save_blk = $this->blk;
+ $save_silp = $this->saveInlineProperties();
+ $save_spanlvl = $this->spanlvl;
+ $save_ilp = $this->InlineProperties;
+
+ // Close any open block tags
+ for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
+ if(!empty($this->textbuffer)) { //Output previously buffered content
+ $this->printbuffer($this->textbuffer);
+ $this->textbuffer=array();
+ }
+ $this->ignorefollowingspaces = true;
+ $save_cols = false;
+/*-- COLUMNS --*/
+ if ($this->ColActive) {
+ $save_cols = true;
+ $save_nbcol = $this->NbCol; // other values of gap and vAlign will not change by setting Columns off
+ $this->SetColumns(0);
+ }
+/*-- END COLUMNS --*/
+
+
+ if (isset($attr['SHEET-SIZE']) && $tag != 'FORMFEED' && !$this->restoreBlockPageBreaks) {
+ // 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->ConvertSize($prop[0]), $this->ConvertSize($prop[1]));
+ }
+ else { $newformat = $attr['SHEET-SIZE']; }
+ }
+ else { $newformat = ''; }
+
+ $mgr = $mgl = $mgt = $mgb = $mgh = $mgf = '';
+ if (isset($attr['MARGIN-RIGHT'])) { $mgr = $this->ConvertSize($attr['MARGIN-RIGHT'],$this->w,$this->FontSize,false); }
+ if (isset($attr['MARGIN-LEFT'])) { $mgl = $this->ConvertSize($attr['MARGIN-LEFT'],$this->w,$this->FontSize,false); }
+ if (isset($attr['MARGIN-TOP'])) { $mgt = $this->ConvertSize($attr['MARGIN-TOP'],$this->w,$this->FontSize,false); }
+ if (isset($attr['MARGIN-BOTTOM'])) { $mgb = $this->ConvertSize($attr['MARGIN-BOTTOM'],$this->w,$this->FontSize,false); }
+ if (isset($attr['MARGIN-HEADER'])) { $mgh = $this->ConvertSize($attr['MARGIN-HEADER'],$this->w,$this->FontSize,false); }
+ if (isset($attr['MARGIN-FOOTER'])) { $mgf = $this->ConvertSize($attr['MARGIN-FOOTER'],$this->w,$this->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->CurOrientation; }
+
+ if (isset($attr['PAGE-SELECTOR']) && $attr['PAGE-SELECTOR']) { $pagesel = $attr['PAGE-SELECTOR']; }
+ else { $pagesel = ''; }
+
+ $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->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->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->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->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->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->tocontents->m_TOC[$toc_id]['TOCmark'] = $this->page; }
+ else { $this->tocontents->TOCmark = $this->page; }
+ }
+/*-- END TOC --*/
+
+/*-- COLUMNS --*/
+ if ($save_cols) {
+ // Restore columns
+ $this->SetColumns($save_nbcol,$this->colvAlign,$this->ColGap);
+ }
+/*-- END COLUMNS --*/
+ if (($tag == 'FORMFEED' || $this->restoreBlockPagebreaks) && !$this->tableLevel && !$this->listlvl) {
+ $this->blk = $save_blk;
+ // Re-open block tags
+ $t = $this->blk[0]['tag'];
+ $a = $this->blk[0]['attr'];
+ $this->blklvl = 0;
+ for ($b=0; $b<=$save_blklvl;$b++) {
+ $tc = $t;
+ $ac = $a;
+ $t = $this->blk[$b+1]['tag'];
+ $a = $this->blk[$b+1]['attr'];
+ unset($this->blk[$b+1]);
+ $this->OpenTag($tc,$ac);
+ }
+ $this->spanlvl = $save_spanlvl;
+ $this->InlineProperties = $save_ilp;
+ $this->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';
+ 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->tableLevel) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e); } // *TABLES*
+ else { // *TABLES*
+ $this->textbuffer[] = array($e);
+ } // *TABLES*
+ }
+ break;
+/*-- END TOC --*/
+
+/*-- INDEX --*/
+ case 'INDEXENTRY':
+ if (isset($attr['CONTENT']) && $attr['CONTENT']) {
+ if (isset($attr['XREF']) && $attr['XREF']) {
+ $this->IndexEntry(htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES),$attr['XREF']);
+ break;
+ }
+ $objattr = array();
+ $objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'],ENT_QUOTES);
+ $objattr['type'] = 'indexentry';
+ $e = "\xbb\xa4\xactype=indexentry,objattr=".serialize($objattr)."\xbb\xa4\xac";
+ if($this->tableLevel) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e); } // *TABLES*
+ else { // *TABLES*
+ $this->textbuffer[] = array($e);
+ } // *TABLES*
+ }
+ break;
+
+
+ case 'INDEXINSERT':
+ if (isset($attr['FONT-SIZE'])) { $reffontsize = $attr['FONT-SIZE']; } else { $reffontsize = ''; }
+ if (isset($attr['LINE-SPACING']) && $attr['LINE-SPACING']) { $linespacing = $attr['LINE-SPACING']; } else { $linespacing = ''; }
+ if (isset($attr['DIV-FONT-SIZE']) && $attr['DIV-FONT-SIZE']) { $divlettfontsize = $attr['DIV-FONT-SIZE']; } else { $divlettfontsize = ''; }
+ if (isset($attr['FONT']) && $attr['FONT']) { $reffont = $attr['FONT']; } else { $reffont = ''; }
+ if (isset($attr['DIV-FONT']) && $attr['DIV-FONT']) { $divlettfont = $attr['DIV-FONT']; } else { $divlettfont = ''; }
+ if (isset($attr['COLS']) && $attr['COLS']) { $cols = $attr['COLS']; } else { $cols = 1; }
+ if (isset($attr['OFFSET']) && $attr['OFFSET']) { $offset = $attr['OFFSET']; } else { $offset = 3; }
+ if (isset($attr['GAP']) && $attr['GAP']) { $gap = $attr['GAP']; } else { $gap = 5; }
+
+ 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->CreateIndex($cols, $reffontsize, $linespacing, $offset, $usedivletters, $divlettfontsize, $gap, $reffont,$divlettfont, $links);
+ 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->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['POS']) && $attr['POS']) {
+ $pos = $attr['POS'];
+ if (strpos($pos,',')) { $pos = explode(',',$pos); }
+ }
+ else { $pos = 'P'; }
+ $this->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->tableLevel) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e); } // *TABLES*
+ else { // *TABLES*
+ $this->textbuffer[] = array($e);
+ } // *TABLES*
+ }
+ break;
+/*-- END BOOKMARKS --*/
+
+/*-- ANNOTATIONS --*/
+ case 'ANNOTATION':
+
+ //if (isset($attr['CONTENT']) && !$this->writingHTMLheader && !$this->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->annotMargin) { $objattr['OPACITY'] = 1; }
+ else { $objattr['OPACITY'] = $this->annotOpacity; }
+ if (isset($attr['COLOR'])) {
+ $cor = $this->ConvertColor($attr['COLOR']);
+ if ($cor) { $objattr['COLOR'] = $cor; }
+ else { $objattr['COLOR'] = $this->ConvertColor('yellow'); }
+ }
+ else { $objattr['COLOR'] = $this->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->tableLevel) { $this->cell[$this->row][$this->col]['textbuffer'][] = array($e); } // *TABLES*
+ else { // *TABLES*
+ $this->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->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
+ if(!empty($this->textbuffer)) { //Output previously buffered content
+ $this->printbuffer($this->textbuffer);
+ $this->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->SetColumns($attr['COLUMN-COUNT'],$valign,$attr['COLUMN-GAP']); }
+ else { $this->SetColumns($attr['COLUMN-COUNT'],$valign); }
+ }
+ $this->ignorefollowingspaces = true;
+ break;
+
+ case 'COLUMN_BREAK': //custom-tag
+ case 'COLUMNBREAK': //custom-tag
+ case 'NEWCOLUMN': //custom-tag
+ $this->ignorefollowingspaces = true;
+ $this->NewColumn();
+ $this->ColumnAdjust = false; // disables all column height adjustment for the page.
+ break;
+
+/*-- END COLUMNS --*/
+
+
+ case 'BDO':
+ // $this->biDirectional = true;
+ break;
+
+
+ case 'TTZ':
+ $this->ttz = true;
+ $this->InlineProperties[$tag] = $this->saveInlineProperties();
+ $this->setCSS(array('FONT-FAMILY'=>'czapfdingbats','FONT-WEIGHT'=>'normal','FONT-STYLE'=>'normal'),'INLINE');
+ break;
+
+ case 'TTS':
+ $this->tts = true;
+ $this->InlineProperties[$tag] = $this->saveInlineProperties();
+ $this->setCSS(array('FONT-FAMILY'=>'csymbol','FONT-WEIGHT'=>'normal','FONT-STYLE'=>'normal'),'INLINE');
+ break;
+
+ case 'TTA':
+ $this->tta = true;
+ $this->InlineProperties[$tag] = $this->saveInlineProperties();
+
+ if (in_array($this->FontFamily,$this->mono_fonts)) {
+ $this->setCSS(array('FONT-FAMILY'=>'ccourier'),'INLINE');
+ }
+ else if (in_array($this->FontFamily,$this->serif_fonts)) {
+ $this->setCSS(array('FONT-FAMILY'=>'ctimes'),'INLINE');
+ }
+ else {
+ $this->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': // mPDF 5.5.09
+ case 'TIME':
+
+ case 'SPAN':
+/*-- ANNOTATIONS --*/
+ if ($this->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->annotOpacity;
+ $objattr['COLOR'] = $this->ConvertColor('yellow');
+ $annot = "\xbb\xa4\xactype=annot,objattr=".serialize($objattr)."\xbb\xa4\xac";
+ }
+/*-- END ANNOTATIONS --*/
+
+ if ($tag == 'SPAN') {
+ $this->spanlvl++;
+ $this->InlineProperties['SPAN'][$this->spanlvl] = $this->saveInlineProperties();
+ if (isset($annot)) { $this->InlineAnnots[$tag][$this->spanlvl] = $annot; } // *ANNOTATIONS*
+ }
+ else {
+ if (!isset($this->InlineProperties[$tag])) $this->InlineProperties[$tag] = $this->saveInlineProperties(); // mPDF 5.4.13
+ if (isset($annot)) { $this->InlineAnnots[$tag] = $annot; } // *ANNOTATIONS*
+ }
+ $properties = $this->cssmgr->MergeCSS('INLINE',$tag,$attr);
+ if (!empty($properties)) $this->setCSS($properties,'INLINE');
+ break;
+
+
+ case 'A':
+ if (isset($attr['NAME']) and $attr['NAME'] != '') {
+ $e = '';
+/*-- BOOKMARKS --*/
+ if ($this->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->tableLevel) { // *TABLES*
+ $this->_saveCellTextBuffer($e, '', $attr['NAME']); // *TABLES*
+ } // *TABLES*
+ else { // *TABLES*
+ $this->_saveTextBuffer($e, '', $attr['NAME']); //an internal link (adds a space for recognition)
+ } // *TABLES*
+ }
+ if (isset($attr['HREF'])) {
+ $this->InlineProperties['A'] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ if (!empty($properties)) $this->setCSS($properties,'INLINE');
+ $this->HREF=htmlspecialchars_decode(urldecode($attr['HREF']));
+ }
+ break;
+
+ case 'LEGEND': // mPDF 5.4.18
+ $this->InlineProperties['LEGEND'] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ if (!empty($properties)) $this->setCSS($properties,'INLINE');
+ break;
+
+
+
+ case 'PROGRESS': // mPDF 5.5.09
+ case 'METER': // mPDF 5.5.09
+ $this->inMeter = true; // mPDF 5.5.09
+
+ 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->cssmgr->MergeCSS('',$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->visibility=='visible') {
+ $objattr['visibility'] = $v;
+ }
+ }
+
+ if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top']=$this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['PADDING-TOP'])) { $objattr['padding_top']=$this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->border_details($properties['BORDER-TOP']); }
+ if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->border_details($properties['BORDER-BOTTOM']); }
+ if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
+ if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->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->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['WIDTH'])) $w = $this->ConvertSize($attr['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+
+ if(isset($properties['HEIGHT'])) $h = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['HEIGHT'])) $h = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+
+ if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; }
+ if ($this->HREF) {
+ if (strpos($this->HREF,".") === false && strpos($this->HREF,"@") !== 0) {
+ $href = $this->HREF;
+ while(array_key_exists($href,$this->internallink)) $href="#".$href;
+ $this->internallink[$href] = $this->AddLink();
+ $objattr['link'] = $this->internallink[$href];
+ }
+ else { $objattr['link'] = $this->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->meter = new meter();
+ $svg = $this->meter->makeSVG(strtolower($tag), $type, $value, $max, $min, $optimum, $low, $high);
+ //Save to local file
+ $srcpath= _MPDF_TEMP_PATH.'_tempSVG'.RAND(1,10000).'_'.strtolower($tag).'.svg';
+ file_put_contents($srcpath, $svg);
+ $orig_srcpath = $srcpath;
+ $this->GetFullPath($srcpath);
+
+ $info=$this->_getImage($srcpath, true, true, $orig_srcpath);
+ if(!$info) {
+ $info = $this->_getImage($this->noImageFile);
+ if ($info) {
+ $srcpath = $this->noImageFile;
+ $w = ($info['w'] * (25.4/$this->dpi));
+ $h = ($info['h'] * (25.4/$this->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->FontSize/(10/_MPDFK) * abs($info['w'])/_MPDFK; // mPDF 5.5.21
+ $h = $this->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->blk[$this->blklvl]['inner_width'];
+ $maxHeight = $this->h - ($this->tMargin + $this->bMargin + 1) ;
+ if ($this->fullImageHeight) { $maxHeight = $this->fullImageHeight; }
+ if ($w + $extrawidth > $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->tableLevel) {
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
+ }
+ else {
+ $this->_saveTextBuffer($e, $this->HREF);
+ }
+
+ break;
+
+
+ case 'BR':
+ // Added mPDF 3.0 Float DIV - CLEAR
+ if (isset($attr['STYLE'])) {
+ $properties = $this->cssmgr->readInlineCSS($attr['STYLE']);
+ if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper($properties['CLEAR']),$this->blklvl); } // *CSS-FLOAT*
+ }
+
+
+/*-- TABLES --*/
+ if($this->tableLevel) {
+
+ if ($this->blockjustfinished || $this->listjustfinished) {
+ $this->_saveCellTextBuffer("\n");
+ }
+
+ $this->_saveCellTextBuffer("\n");
+ if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
+ }
+ else {
+/*-- END TABLES --*/
+ if (count($this->textbuffer)) {
+ $this->textbuffer[count($this->textbuffer)-1][0] = preg_replace('/ $/','',$this->textbuffer[count($this->textbuffer)-1][0]);
+ }
+ $this->_saveTextBuffer("\n");
+ } // *TABLES*
+ $this->ignorefollowingspaces = true;
+ $this->blockjustfinished=false;
+ $this->listjustfinished=false;
+
+ $this->linebreakjustfinished=true;
+ break;
+
+
+ // *********** BLOCKS ********************
+
+
+ case 'PRE':
+ $this->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 'FIELDSET':
+ // mPDF 5.5.22
+ case 'DETAILS':
+ case 'SUMMARY':
+ // mPDF 5.5.09
+ case 'ARTICLE':
+ case 'ASIDE':
+ case 'FIGURE':
+ case 'FIGCAPTION':
+ case 'FOOTER':
+ case 'HEADER':
+ case 'HGROUP':
+ case 'NAV':
+ case 'SECTION':
+ $p = $this->cssmgr->PreviewBlockCSS($tag,$attr);
+ if(isset($p['DISPLAY']) && strtolower($p['DISPLAY'])=='none') {
+ $this->blklvl++;
+ $this->blk[$this->blklvl]['hide'] = true;
+ 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->blklvl++;
+ $this->blk[$this->blklvl]['hide'] = true;
+ return;
+ }
+ }
+
+/*-- FORMS --*/
+ if($tag == 'FORM') {
+ if (isset($attr['METHOD']) && strtolower($attr['METHOD'])=='get') { $this->form->formMethod = 'GET'; }
+ else { $this->form->formMethod = 'POST'; }
+ if (isset($attr['ACTION'])) { $this->form->formAction = $attr['ACTION']; }
+ else { $this->form->formAction = ''; }
+ }
+/*-- END FORMS --*/
+
+
+/*-- CSS-POSITION --*/
+ if ((isset($p['POSITION']) && (strtolower($p['POSITION'])=='fixed' || strtolower($p['POSITION'])=='absolute')) && $this->blklvl==0) {
+ if ($this->inFixedPosBlock) {
+ $this->Error("Cannot nest block with position:fixed or position:absolute");
+ }
+ $this->inFixedPosBlock = true;
+ return;
+ }
+/*-- END CSS-POSITION --*/
+ // Start Block
+ $this->ignorefollowingspaces = true;
+
+ if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
+ else { $lastbottommargin = 0; }
+ $this->lastblockbottommargin = 0;
+ $this->blockjustfinished=false;
+
+/*-- LISTS --*/
+ if ($this->listlvl>0) { return; }
+/*-- END LISTS --*/
+
+ $this->InlineProperties = array();
+ $this->spanlvl = 0;
+ $this->listjustfinished=false;
+ $this->divbegin=true;
+
+ $this->linebreakjustfinished=false;
+
+/*-- TABLES --*/
+ if ($this->tableLevel) {
+
+ // If already something on the line
+ if ($this->cell[$this->row][$this->col]['s'] > 0 && !$this->nestedtablejustfinished ) {
+ $this->_saveCellTextBuffer("\n");
+ if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
+ }
+ // Cannot set block properties inside table - use Bold to indicate h1-h6
+ if ($tag == 'CENTER' && $this->tdbegin) { $this->cell[$this->row][$this->col]['a'] = $align['center']; }
+
+ $this->InlineProperties['BLOCKINTABLE'] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ if (!empty($properties)) $this->setCSS($properties,'INLINE');
+
+
+ break;
+ }
+/*-- END TABLES --*/
+
+ if ($tag == 'P' || $tag == 'DT' || $tag == 'DD') { $this->lastoptionaltag = $tag; } // Save current HTML specified optional endtag
+ else { $this->lastoptionaltag = ''; }
+
+ if ($this->lastblocklevelchange == 1) { $blockstate = 1; } // Top margins/padding only
+ else if ($this->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding
+ $this->printbuffer($this->textbuffer,$blockstate);
+ $this->textbuffer=array();
+
+ $save_blklvl = $this->blklvl;
+ $save_blk = $this->blk;
+ $save_silp = $this->saveInlineProperties();
+ $save_spanlvl = $this->spanlvl;
+ $save_ilp = $this->InlineProperties;
+
+ $this->blklvl++;
+
+ $currblk =& $this->blk[$this->blklvl];
+ $this->initialiseBlock($currblk);
+ $prevblk =& $this->blk[$this->blklvl-1];
+
+ $currblk['tag'] = $tag;
+ $currblk['attr'] = $attr;
+
+ $this->Reset();
+ $properties = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr);
+ $pagesel = '';
+/*-- CSS-PAGE --*/
+
+ if (isset($properties['PAGE'])) { $pagesel = $properties['PAGE']; }
+/*-- END CSS-PAGE --*/
+
+ // If page-box has changed AND/OR PAGE-BREAK-BEFORE
+ $save_cols = false;
+ if (($pagesel && $pagesel != $this->page_box['current']) || (isset($properties['PAGE-BREAK-BEFORE']) && $properties['PAGE-BREAK-BEFORE'])) {
+ if ($this->blklvl>1) {
+ // Close any open block tags
+ for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
+ // Output any text left in buffer
+ if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); $this->textbuffer=array(); }
+ }
+/*-- COLUMNS --*/
+ if ($this->ColActive) {
+ $save_cols = true;
+ $save_nbcol = $this->NbCol; // other values of gap and vAlign will not change by setting Columns off
+ $this->SetColumns(0);
+ }
+/*-- END COLUMNS --*/
+
+
+ // Must Add new page if changed page properties
+ if (isset($properties['PAGE-BREAK-BEFORE'])) {
+ if (strtoupper($properties['PAGE-BREAK-BEFORE']) == 'RIGHT') { $this->AddPage($this->CurOrientation,'NEXT-ODD','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+ else if (strtoupper($properties['PAGE-BREAK-BEFORE']) == 'LEFT') { $this->AddPage($this->CurOrientation,'NEXT-EVEN','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+ else if (strtoupper($properties['PAGE-BREAK-BEFORE']) == 'ALWAYS') { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+ else if ($this->page_box['current'] != $pagesel) { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); } // *CSS-PAGE*
+ }
+/*-- CSS-PAGE --*/
+ else if ($pagesel != $this->page_box['current']) { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+/*-- END CSS-PAGE --*/
+
+ // if using htmlheaders, the headers need to be rewritten when new page
+ // done by calling WriteHTML() within resethtmlheaders
+ // so block is reset to 0 - now we need to resurrect it
+ // As in WriteHTML() initialising
+ if (!($this->restoreBlockPagebreaks && isset($properties['PAGE-BREAK-BEFORE']) && $properties['PAGE-BREAK-BEFORE'])) {
+ $this->blklvl = 0;
+ $this->lastblocklevelchange = 0;
+ $this->blk = array();
+ $this->initialiseBlock($this->blk[0]);
+ $this->blk[0]['width'] =& $this->pgwidth;
+ $this->blk[0]['inner_width'] =& $this->pgwidth;
+ $this->blk[0]['blockContext'] = $this->blockContext;
+ $properties = $this->cssmgr->MergeCSS('BLOCK','BODY','');
+ $this->setCSS($properties,'','BODY');
+ $this->blklvl++;
+ $currblk =& $this->blk[$this->blklvl];
+ $prevblk =& $this->blk[$this->blklvl-1];
+
+ $this->initialiseBlock($currblk);
+ $currblk['tag'] = $tag;
+ $currblk['attr'] = $attr;
+
+ $this->Reset();
+ $properties = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr);
+ }
+/*-- COLUMNS --*/
+ if ($save_cols) {
+ // Restore columns
+ $this->SetColumns($save_nbcol,$this->colvAlign,$this->ColGap);
+ }
+/*-- END COLUMNS --*/
+ if ($this->restoreBlockPagebreaks && isset($properties['PAGE-BREAK-BEFORE']) && $properties['PAGE-BREAK-BEFORE']) {
+ $this->blk = $save_blk;
+ // Re-open block tags
+ $t = $this->blk[0]['tag'];
+ $a = $this->blk[0]['attr'];
+ $this->blklvl = 0;
+ for ($b=0; $b<=$save_blklvl;$b++) {
+ $tc = $t;
+ $ac = $a;
+ $t = $this->blk[$b+1]['tag'];
+ $a = $this->blk[$b+1]['attr'];
+ unset($this->blk[$b+1]);
+ $this->OpenTag($tc,$ac);
+ }
+ $this->spanlvl = $save_spanlvl;
+ $this->InlineProperties = $save_ilp;
+ $this->restoreInlineProperties($save_silp);
+ }
+ }
+
+ if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && !$this->ColActive && !$this->keep_block_together) {
+ $currblk['keep_block_together'] = 1;
+ $this->kt_y00 = $this->y;
+ $this->kt_p00 = $this->page;
+ $this->keep_block_together = 1;
+ $this->divbuffer = array();
+ $this->ktLinks = array();
+ $this->ktAnnots = array();
+ $this->ktForms = array();
+ $this->ktBlock = array();
+ $this->ktReference = array();
+ $this->ktBMoutlines = array();
+ $this->_kttoc = array();
+ }
+ if ($lastbottommargin && isset($properties['MARGIN-TOP']) && $properties['MARGIN-TOP'] && empty($properties['FLOAT'])) { $currblk['lastbottommargin'] = $lastbottommargin; }
+
+ // mPDF 5.6.01 - LAYERS
+ if (isset($properties['Z-INDEX']) && $this->currentlayer==0) {
+ $v = intval($properties['Z-INDEX']);
+ if ($v > 0) {
+ $currblk['z-index'] = $v;
+ $this->BeginLayer($v);
+ }
+ }
+
+ $this->setCSS($properties,'BLOCK',$tag); //name(id/class/style) found in the CSS array!
+ $currblk['InlineProperties'] = $this->saveInlineProperties();
+
+ if (isset($properties['VISIBILITY'])) {
+ $v = strtolower($properties['VISIBILITY']);
+ if (($v == 'hidden' || $v == 'printonly' || $v == 'screenonly') && $this->visibility=='visible' && !$this->tableLevel) {
+ $currblk['visibility'] = $v;
+ $this->SetVisibility($v);
+ }
+ }
+
+ if(isset($attr['DIR']) && $attr['DIR']) { $currblk['direction'] = strtolower($attr['DIR']); }
+ if(isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower($attr['ALIGN'])]; }
+
+ if (isset($properties['HEIGHT'])) {
+ $currblk['css_set_height'] = $this->ConvertSize($properties['HEIGHT'],($this->h - $this->tMargin - $this->bMargin),$this->FontSize,false);
+ if (($currblk['css_set_height'] + $this->y) > $this->PageBreakTrigger && $this->y > $this->tMargin+5 && $currblk['css_set_height'] < ($this->h - ($this->tMargin + $this->bMargin))) { $this->AddPage($this->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->ClearFloats(strtoupper($properties['CLEAR']), $this->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->ColActive) {
+ // Cancel Keep-Block-together
+ $currblk['keep_block_together'] = false;
+ $this->kt_y00 = '';
+ $this->keep_block_together = 0;
+
+ $this->blockContext++;
+ $currblk['blockContext'] = $this->blockContext;
+
+ list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->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->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->GetCharWidth('W',false))) {
+ $this->ClearFloats('LEFT', $this->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->GetCharWidth('W',false))) {
+ $this->ClearFloats('RIGHT', $this->blklvl-1);
+ }
+ else { $this->ClearFloats('BOTH', $this->blklvl-1); }
+ list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl-1);
+ }
+
+ if ($r_exists) { $currblk['margin_right'] += $r_width; }
+
+ $currblk['float'] = 'R';
+ $currblk['float_start_y'] = $this->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->ColActive) {
+ // Cancel Keep-Block-together
+ $currblk['keep_block_together'] = false;
+ $this->kt_y00 = '';
+ $this->keep_block_together = 0;
+
+ $this->blockContext++;
+ $currblk['blockContext'] = $this->blockContext;
+
+ list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->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->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->GetCharWidth('W',false))) {
+ $this->ClearFloats('LEFT', $this->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->GetCharWidth('W',false))) {
+ $this->ClearFloats('RIGHT', $this->blklvl-1);
+ }
+ else { $this->ClearFloats('BOTH', $this->blklvl-1); }
+ list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl-1);
+ }
+
+ if ($l_exists) { $currblk['margin_left'] += $l_width; }
+
+ $currblk['float'] = 'L';
+ $currblk['float_start_y'] = $this->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->GetFloatDivInfo($this->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->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->GetCharWidth('W',false))) {
+ $this->ClearFloats('LEFT', $this->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->GetCharWidth('W',false))) {
+ $this->ClearFloats('RIGHT', $this->blklvl-1);
+ }
+ else { $this->ClearFloats('BOTH', $this->blklvl-1); }
+ list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->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->autoPadding && !$this->ColActive && !$this->keep_block_together) {
+ 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->_borderPadding($currblk['border_radius_TL_H'],$currblk['border_radius_TL_V'], $currblk['padding_left'], $currblk['padding_top']);
+ }
+ else {
+ $this->_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->_borderPadding($currblk['border_radius_TR_H'],$currblk['border_radius_TR_V'], $currblk['padding_right'], $currblk['padding_top']);
+ }
+ else {
+ $this->_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->_borderPadding($currblk['border_radius_BL_H'],$currblk['border_radius_BL_V'], $currblk['padding_left'], $currblk['padding_bottom']);
+ }
+ else {
+ $this->_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->_borderPadding($currblk['border_radius_BR_H'],$currblk['border_radius_BR_V'], $currblk['padding_right'], $currblk['padding_bottom']);
+ }
+ else {
+ $this->_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->ConvertSize($currblk['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if ($cbti < 0) {
+ $hangind = -($cbti);
+ if ($currblk['direction'] == 'rtl') { // *RTL*
+ $currblk['padding_right'] = max($currblk['padding_right'],$hangind); // *RTL*
+ } // *RTL*
+ else { // *RTL*
+ $currblk['padding_left'] = max($currblk['padding_left'],$hangind);
+ } // *RTL*
+ }
+
+ 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') { // *RTL*
+ // 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']); // *RTL*
+ if ($currblk['margin_left'] < 0) { // *RTL*
+ $currblk['margin_left'] = 0; // *RTL*
+ } // *RTL*
+ } // *RTL*
+ else { // *RTL*
+ // 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;
+ }
+ } // *RTL*
+ }
+ }
+
+ $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->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->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->pgwidth - ($currblk['outer_right_margin'] + $currblk['outer_left_margin']);
+ $currblk['inner_width'] = $this->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) { $this->Error("DIV is too narrow for text to fit!"); }
+ }
+
+ $this->x = $this->lMargin + $currblk['outer_left_margin'];
+
+/*-- BACKGROUNDS --*/
+ if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->kwt && !$this->ColActive && !$this->keep_block_together) {
+ $ret = $this->SetBackground($properties, $currblk['inner_width']);
+ if ($ret) { $currblk['background-image'] = $ret; }
+ }
+/*-- END BACKGROUNDS --*/
+
+/*-- TABLES --*/
+ if ($this->use_kwt && isset($attr['KEEP-WITH-TABLE']) && !$this->ColActive && !$this->keep_block_together) {
+ $this->kwt = true;
+ $this->kwt_y0 = $this->y;
+ $this->kwt_x0 = $this->x;
+ $this->kwt_height = 0;
+ $this->kwt_buffer = array();
+ $this->kwt_Links = array();
+ $this->kwt_Annots = array();
+ $this->kwt_moved = false;
+ $this->kwt_saved = false;
+ $this->kwt_Reference = array();
+ $this->kwt_BMoutlines = array();
+ $this->kwt_toc = array();
+ }
+ else {
+/*-- END TABLES --*/
+ $this->kwt = false;
+ } // *TABLES*
+
+ //Save x,y coords in case we need to print borders...
+ $currblk['y0'] = $this->y;
+ $currblk['x0'] = $this->x;
+ $currblk['startpage'] = $this->page;
+ $this->oldy = $this->y;
+
+ $this->lastblocklevelchange = 1 ;
+
+ break;
+
+ case 'HR':
+ // Added mPDF 3.0 Float DIV - CLEAR
+ if (isset($attr['STYLE'])) {
+ $properties = $this->cssmgr->readInlineCSS($attr['STYLE']);
+ if (isset($properties['CLEAR'])) { $this->ClearFloats(strtoupper($properties['CLEAR']),$this->blklvl); } // *CSS-FLOAT*
+ }
+
+ $this->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->cssmgr->MergeCSS('',$tag,$attr);
+ if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top'] = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['WIDTH'])) { $objattr['width'] = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']); }
+ else if(isset($attr['WIDTH']) && $attr['WIDTH'] != '') $objattr['width'] = $this->ConvertSize($attr['WIDTH'],$this->blk[$this->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->ConvertColor($properties['COLOR']); }
+ else if(isset($attr['COLOR']) && $attr['COLOR'] != '') $objattr['color'] = $this->ConvertColor($attr['COLOR']);
+ if (isset($properties['HEIGHT'])) { $objattr['linewidth'] = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+
+/*-- TABLES --*/
+ if ($this->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->tableLevel) {
+ if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ $this->cell[$this->row][$this->col]['s'] = 0 ;// reset
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ }
+ else {
+/*-- END TABLES --*/
+ $this->_saveTextBuffer($e, $this->HREF);
+ } // *TABLES*
+
+ break;
+
+
+/*-- BARCODES --*/
+
+ case 'BARCODE':
+ 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->cssmgr->MergeCSS('',$tag,$attr);
+ if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
+ return;
+ }
+ if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top']=$this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['PADDING-TOP'])) { $objattr['padding_top']=$this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->border_details($properties['BORDER-TOP']); }
+ if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->border_details($properties['BORDER-BOTTOM']); }
+ if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
+ if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->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->ConvertColor($properties['COLOR']); }
+ else { $objattr['color'] = false; }
+ if (isset($properties['BACKGROUND-COLOR']) && $properties['BACKGROUND-COLOR'] != '') { $objattr['bgcolor'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
+ else { $objattr['bgcolor'] = false; }
+
+ if (!class_exists('PDFBarcode', false)) {
+ include(_MPDF_PATH.'classes/barcode.php');
+ }
+ $this->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->barcode->getBarcodeArray($code, 'EAN13');
+ }
+ else { $arrcode = $this->barcode->getBarcodeArray($code, $objattr['btype'] ); }
+ if ($arrcode === false) { $this->Error('Error in barcode string.'); }
+
+ if ($objattr['bsupp'] == 2 || $objattr['bsupp'] == 5) { // EAN-2 or -5 Supplement
+ $supparrcode = $this->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->barcode->getBarcodeArray($objattr['code'], $objattr['btype'] );
+ if ($arrcode === false) { $this->Error('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->barcode->getBarcodeArray($objattr['code'], $objattr['btype'], $objattr['pr_ratio'] );
+ if ($arrcode === false) { $this->Error('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->ColActive && !$this->tableLevel && !$this->listlvl && !$this->kwt && !$this->keep_block_together) {
+ 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->tableLevel) {
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
+ }
+ else {
+/*-- END TABLES --*/
+ $this->_saveTextBuffer($e, $this->HREF);
+
+ } // *TABLES*
+ }
+ break;
+/*-- END BARCODES --*/
+
+
+ // *********** FORM ELEMENTS ********************
+
+/*-- FORMS --*/
+ case 'SELECT':
+ $this->lastoptionaltag = ''; // Save current HTML specified optional endtag
+ $this->InlineProperties[$tag] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ if (isset($properties['FONT-FAMILY'])) {
+ $this->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
+ }
+ if (isset($properties['FONT-SIZE'])) {
+ $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK);
+ $this->SetFontSize($mmsize*_MPDFK,false);
+ }
+ if (isset($attr['SPELLCHECK']) && strtolower($attr['SPELLCHECK'])=='true') {
+ $this->selectoption['SPELLCHECK'] = true;
+ }
+
+ if (isset($properties['COLOR'])) { $this->selectoption['COLOR'] = $this->ConvertColor($properties['COLOR']); }
+ $this->specialcontent = "type=select";
+ if(isset($attr['DISABLED'])) { $this->selectoption['DISABLED'] = $attr['DISABLED']; }
+ if(isset($attr['READONLY'])) { $this->selectoption['READONLY'] = $attr['READONLY']; }
+ if(isset($attr['REQUIRED'])) { $this->selectoption['REQUIRED'] = $attr['REQUIRED']; }
+ if(isset($attr['EDITABLE'])) { $this->selectoption['EDITABLE'] = $attr['EDITABLE']; }
+ if(isset($attr['TITLE'])) { $this->selectoption['TITLE'] = $attr['TITLE']; }
+ if(isset($attr['MULTIPLE'])) { $this->selectoption['MULTIPLE'] = $attr['MULTIPLE']; }
+ if(isset($attr['SIZE']) && $attr['SIZE']>1) { $this->selectoption['SIZE'] = $attr['SIZE']; }
+ if ($this->useActiveForms) {
+ if(isset($attr['NAME'])) { $this->selectoption['NAME'] = $attr['NAME']; }
+ if (isset($attr['ONCHANGE'])) { $this->selectoption['ONCHANGE'] = $attr['ONCHANGE']; }
+ }
+
+ $properties = array();
+ break;
+
+ case 'OPTION':
+ $this->lastoptionaltag = 'OPTION'; // Save current HTML specified optional endtag
+ $this->selectoption['ACTIVE'] = true;
+ $this->selectoption['currentSEL'] = false;
+ if (empty($this->selectoption)) {
+ $this->selectoption['MAXWIDTH'] = '';
+ $this->selectoption['SELECTED'] = '';
+ }
+ if (isset($attr['SELECTED'])) {
+ $this->selectoption['SELECTED'] = '';
+ $this->selectoption['currentSEL'] = true;
+ }
+ if(isset($attr['VALUE'])) {
+ $attr['VALUE'] = strcode2utf($attr['VALUE']);
+ $attr['VALUE'] = $this->lesser_entity_decode($attr['VALUE']);
+ if ($this->onlyCoreFonts)
+ $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mb_enc,'UTF-8');
+ }
+ $this->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->onlyCoreFonts)
+ $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mb_enc,'UTF-8');
+ if ($this->useActiveForms) {
+ if(isset($attr['NAME'])) { $objattr['fieldname'] = $attr['NAME']; }
+ $this->form->form_element_spacing['textarea']['outer']['v'] = 0;
+ $this->form->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->InlineProperties[$tag] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ if (isset($properties['FONT-FAMILY'])) {
+ $this->SetFont($properties['FONT-FAMILY'],'',0,false);
+ }
+ if (isset($properties['FONT-SIZE'])) {
+ $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK);
+ $this->SetFontSize($mmsize*_MPDFK,false);
+ }
+ if (isset($properties['COLOR'])) { $objattr['color'] = $this->ConvertColor($properties['COLOR']); }
+ $objattr['fontfamily'] = $this->FontFamily;
+ $objattr['fontsize'] = $this->FontSizePt;
+ if ($this->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->ConvertColor($properties['BORDER-TOP-COLOR']); }
+ if (isset($properties['BACKGROUND-COLOR'])) { $objattr['background-col'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
+ }
+ $this->SetLineHeight('',$this->form->textarea_lineheight);
+ $formLineHeight = $this->lineheight;
+
+ $w = 0;
+ $h = 0;
+ if(isset($properties['WIDTH'])) $w = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if(isset($properties['HEIGHT'])) $h = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if ($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->GetCharWidth('w',false);
+ if ($w) { $colsize = round(($w-($this->form->form_element_spacing['textarea']['outer']['h']*2)-($this->form->form_element_spacing['textarea']['inner']['h']*2))/$charsize); }
+ if ($h) { $rowsize = round(($h-($this->form->form_element_spacing['textarea']['outer']['v']*2)-($this->form->form_element_spacing['textarea']['inner']['v']*2))/$formLineHeight); }
+
+ $objattr['type'] = 'textarea';
+ $objattr['width'] = ($colsize * $charsize) + ($this->form->form_element_spacing['textarea']['outer']['h']*2)+($this->form->form_element_spacing['textarea']['inner']['h']*2);
+ $objattr['height'] = ($rowsize * $formLineHeight) + ($this->form->form_element_spacing['textarea']['outer']['v']*2)+($this->form->form_element_spacing['textarea']['inner']['v']*2);
+ $objattr['rows'] = $rowsize;
+ $objattr['cols'] = $colsize;
+
+ $this->specialcontent = serialize($objattr);
+
+ if ($this->tableLevel) { // *TABLES*
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ; // *TABLES*
+ } // *TABLES*
+
+ // Clear properties - tidy up
+ $properties = array();
+ break;
+
+
+
+ // *********** FORM - INPUT ********************
+
+ case 'INPUT':
+ 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->lesser_entity_decode($objattr['title']);
+ if ($this->onlyCoreFonts)
+ $objattr['title'] = mb_convert_encoding($objattr['title'], $this->mb_enc,'UTF-8');
+ if ($this->useActiveForms) {
+ if(isset($attr['NAME'])) { $objattr['fieldname'] = $attr['NAME']; }
+ }
+ if(isset($attr['VALUE'])) {
+ $attr['VALUE'] = strcode2utf($attr['VALUE']);
+ $attr['VALUE'] = $this->lesser_entity_decode($attr['VALUE']);
+ if ($this->onlyCoreFonts)
+ $attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mb_enc,'UTF-8');
+ $objattr['value'] = $attr['VALUE'];
+ }
+
+ $this->InlineProperties[$tag] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ $objattr['vertical-align'] = '';
+
+ if (isset($properties['FONT-FAMILY'])) {
+ $this->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
+ }
+ if (isset($properties['FONT-SIZE'])) {
+ $mmsize = $this->ConvertSize($properties['FONT-SIZE'],($this->default_font_size/_MPDFK));
+ $this->SetFontSize($mmsize*_MPDFK,false);
+ }
+ if (isset($properties['COLOR'])) { $objattr['color'] = $this->ConvertColor($properties['COLOR']); }
+ $objattr['fontfamily'] = $this->FontFamily;
+ $objattr['fontsize'] = $this->FontSizePt;
+ if ($this->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->ConvertColor($properties['BORDER-TOP-COLOR']); }
+ if (isset($properties['BACKGROUND-COLOR'])) { $objattr['background-col'] = $this->ConvertColor($properties['BACKGROUND-COLOR']); }
+ }
+
+ $type = '';
+ $texto='';
+ $height = $this->FontSize;
+ $width = 0;
+ $spacesize = $this->GetCharWidth(' ',false);
+
+ $w = 0;
+ if(isset($properties['WIDTH'])) $w = $this->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']);
+
+ if ($properties['VERTICAL-ALIGN']) { $objattr['vertical-align'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+
+ switch(strtoupper($attr['TYPE'])){
+ case 'HIDDEN':
+ $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
+ if ($this->useActiveForms) {
+ $this->form->SetFormText( 0, 0, $objattr['fieldname'], $objattr['value'], $objattr['value'], '', 0, '', true );
+ }
+ if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+ break 2;
+ case 'CHECKBOX': //Draw Checkbox
+ $type = 'CHECKBOX';
+ if (isset($attr['CHECKED'])) { $objattr['checked'] = true; }
+ else { $objattr['checked'] = false; }
+ $width = $this->FontSize;
+ $height = $this->FontSize;
+ break;
+
+ case 'RADIO': //Draw Radio button
+ $type = 'RADIO';
+ if (isset($attr['CHECKED'])) $objattr['checked'] = true;
+ $width = $this->FontSize;
+ $height = $this->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->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+
+ if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->border_details($properties['BORDER-TOP']); }
+ if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->border_details($properties['BORDER-BOTTOM']); }
+ if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
+ if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->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->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width']);
+ if(isset($properties['HEIGHT'])) $h = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->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->_getImage($srcpath, true, true, $orig_srcpath);
+ if(!$info) {
+ $info = $this->_getImage($this->noImageFile);
+ if ($info) {
+ $srcpath = $this->noImageFile;
+ $w = ($info['w'] * (25.4/$this->dpi));
+ $h = ($info['h'] * (25.4/$this->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->img_dpi);
+ $h=($info['h']/_MPDFK) * (72/$this->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->img_dpi / $info['set-dpi'];
+ $h *= $this->img_dpi / $info['set-dpi'];
+ }
+ else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
+ $dpi = $m[1];
+ if ($dpi > 0) {
+ $w *= $this->img_dpi / $dpi;
+ $h *= $this->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->blk[$this->blklvl]['inner_width'];
+ $maxHeight = $this->h - ($this->tMargin + $this->bMargin + 10) ;
+ if ($this->fullImageHeight) { $maxHeight = $this->fullImageHeight; }
+ if ($w + $extrawidth > $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->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->GetStringWidth($texto) + ($this->form->form_element_spacing['button']['outer']['h']*2)+($this->form->form_element_spacing['button']['inner']['h']*2);
+ $height = $this->FontSize + ($this->form->form_element_spacing['button']['outer']['v']*2)+($this->form->form_element_spacing['button']['inner']['v']*2);
+ if ($this->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->mb_enc );
+ $texto = str_repeat('*',$num_stars);
+ }
+ else { $texto = $attr['VALUE']; }
+ }
+ $xw = ($this->form->form_element_spacing['input']['outer']['h']*2)+($this->form->form_element_spacing['input']['inner']['h']*2);
+ $xh = ($this->form->form_element_spacing['input']['outer']['v']*2)+($this->form->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->FontSize + $xh;
+ if (isset($attr['MAXLENGTH']) and ctype_digit($attr['MAXLENGTH']) ) $objattr['maxlength'] = $attr['MAXLENGTH'];
+ if ($this->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->tableLevel) {
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
+
+ }
+ else {
+/*-- END TABLES --*/
+ $this->_saveTextBuffer($e, $this->HREF);
+ } // *TABLES*
+
+ if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+
+ break; // END of INPUT
+/*-- END FORMS --*/
+
+
+ // *********** GRAPH ********************
+ case 'JPGRAPH':
+ if (!$this->useGraphs) { break; }
+ if ($attr['TABLE']) { $gid = strtoupper($attr['TABLE']); }
+ else { $gid = '0'; }
+ if (!is_array($this->graphs[$gid]) || count($this->graphs[$gid])==0 ) { break; }
+ include_once(_MPDF_PATH.'graph.php');
+ $this->graphs[$gid]['attr'] = $attr;
+
+
+ if (isset($this->graphs[$gid]['attr']['WIDTH']) && $this->graphs[$gid]['attr']['WIDTH']) {
+ $this->graphs[$gid]['attr']['cWIDTH']=$this->ConvertSize($this->graphs[$gid]['attr']['WIDTH'],$pgwidth);
+ } // mm
+ if (isset($this->graphs[$gid]['attr']['HEIGHT']) && $this->graphs[$gid]['attr']['HEIGHT']) {
+ $this->graphs[$gid]['attr']['cHEIGHT']=$this->ConvertSize($this->graphs[$gid]['attr']['HEIGHT'],$pgwidth);
+ }
+
+ $graph_img = print_graph($this->graphs[$gid],$this->blk[$this->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':
+ if ($this->progressBar) { $this->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 = $attr['ORIG_SRC'];
+ $properties = $this->cssmgr->MergeCSS('',$tag,$attr);
+ if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
+ return;
+ }
+ // mPDF 5.6.01 - LAYERS
+ if (isset($properties['Z-INDEX']) && $this->currentlayer==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->visibility=='visible') {
+ $objattr['visibility'] = $v;
+ }
+ }
+
+ // VSPACE and HSPACE converted to margins in MergeCSS
+ if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top']=$this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['PADDING-TOP'])) { $objattr['padding_top']=$this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->border_details($properties['BORDER-TOP']); }
+ if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->border_details($properties['BORDER-BOTTOM']); }
+ if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
+ if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->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->ConvertSize($properties['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['WIDTH'])) $w = $this->ConvertSize($attr['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if(isset($properties['HEIGHT'])) $h = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['HEIGHT'])) $h = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ // mPDF 5.5.15 // mPDF 5.6.60
+ $maxw=$maxh=$minw=$minh=false;
+ if(isset($properties['MAX-WIDTH'])) $maxw = $this->ConvertSize($properties['MAX-WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['MAX-WIDTH'])) $maxw = $this->ConvertSize($attr['MAX-WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if(isset($properties['MAX-HEIGHT'])) $maxh = $this->ConvertSize($properties['MAX-HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['MAX-HEIGHT'])) $maxh = $this->ConvertSize($attr['MAX-HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if(isset($properties['MIN-WIDTH'])) $minw = $this->ConvertSize($properties['MIN-WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['MIN-WIDTH'])) $minw = $this->ConvertSize($attr['MIN-WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if(isset($properties['MIN-HEIGHT'])) $minh = $this->ConvertSize($properties['MIN-HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ else if(isset($attr['MIN-HEIGHT'])) $minh = $this->ConvertSize($attr['MIN-HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+
+ if (isset($properties['OPACITY']) && $properties['OPACITY'] > 0 && $properties['OPACITY'] <= 1) { $objattr['opacity'] = $properties['OPACITY']; }
+ if ($this->HREF) {
+ if (strpos($this->HREF,".") === false && strpos($this->HREF,"@") !== 0) {
+ $href = $this->HREF;
+ while(array_key_exists($href,$this->internallink)) $href="#".$href;
+ $this->internallink[$href] = $this->AddLink();
+ $objattr['link'] = $this->internallink[$href];
+ }
+ else { $objattr['link'] = $this->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'];
+
+/*-- BACKGROUNDS --*/
+ if(isset($properties['GRADIENT-MASK']) && preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient/',$properties['GRADIENT-MASK'])) {
+ $objattr['GRADIENT-MASK'] = $properties['GRADIENT-MASK'];
+ }
+/*-- END BACKGROUNDS --*/
+
+ // Image file
+ $info=$this->_getImage($srcpath, true, true, $orig_srcpath);
+ if(!$info) {
+ $info = $this->_getImage($this->noImageFile);
+ if ($info) {
+ $srcpath = $this->noImageFile;
+ $w = ($info['w'] * (25.4/$this->dpi));
+ $h = ($info['h'] * (25.4/$this->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->img_dpi);
+ $h=($info['h']/_MPDFK) * (72/$this->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->img_dpi / $info['set-dpi'];
+ $h *= $this->img_dpi / $info['set-dpi'];
+ }
+ else if (preg_match('/(\d+)dpi/i', $properties['IMAGE-RESOLUTION'], $m)) {
+ $dpi = $m[1];
+ if ($dpi > 0) {
+ $w *= $this->img_dpi / $dpi;
+ $h *= $this->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']);
+
+ // mPDF 5.5.15
+ 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->blk[$this->blklvl]['inner_width'];
+ $maxHeight = $this->h - ($this->tMargin + $this->bMargin + 1) ;
+ if ($this->fullImageHeight) { $maxHeight = $this->fullImageHeight; }
+ if ($w + $extrawidth > $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->ColActive && !$this->tableLevel && !$this->listlvl && !$this->kwt && !$this->keep_block_together) {
+ 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=image,objattr=".serialize($objattr)."\xbb\xa4\xac";
+
+ // Clear properties - tidy up
+ $properties = array();
+
+/*-- TABLES --*/
+ // Output it to buffers
+ if ($this->tableLevel) {
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
+ }
+ else {
+/*-- END TABLES --*/
+ $this->_saveTextBuffer($e, $this->HREF);
+ } // *TABLES*
+/*-- ANNOTATIONS --*/
+ if ($this->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->annotOpacity;
+ $objattr['COLOR'] = $this->ConvertColor('yellow');
+ $e = "\xbb\xa4\xactype=annot,objattr=".serialize($objattr)."\xbb\xa4\xac";
+ if($this->tableLevel) { // *TABLES*
+ $this->cell[$this->row][$this->col]['textbuffer'][] = array($e); // *TABLES*
+ } // *TABLES*
+ else { // *TABLES*
+ $this->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->InlineProperties[$tag] = $this->saveInlineProperties();
+ $properties = $this->cssmgr->MergeCSS('INLINE',$tag,$attr);
+
+ if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
+ return;
+ }
+ if (isset($attr['R'])) { $objattr['r']=$this->ConvertSize($attr['R'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if(isset($attr['TOP-TEXT'])) {
+ $objattr['top-text'] = strcode2utf($attr['TOP-TEXT']);
+ $objattr['top-text'] = $this->lesser_entity_decode($objattr['top-text']);
+ if ($this->onlyCoreFonts)
+ $objattr['top-text'] = mb_convert_encoding($objattr['top-text'], $this->mb_enc,'UTF-8');
+ }
+ if(isset($attr['BOTTOM-TEXT'])) {
+ $objattr['bottom-text'] = strcode2utf($attr['BOTTOM-TEXT']);
+ $objattr['bottom-text'] = $this->lesser_entity_decode($objattr['bottom-text']);
+ if ($this->onlyCoreFonts)
+ $objattr['bottom-text'] = mb_convert_encoding($objattr['bottom-text'], $this->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->visibility=='visible') {
+ $objattr['visibility'] = $v;
+ }
+ }
+ // mPDF 5.5.23
+ 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->ConvertSize($properties['FONT-SIZE'],($this->default_font_size/_MPDFK));
+ $this->SetFontSize($mmsize*_MPDFK,false);
+ $objattr['fontsize'] = $this->FontSizePt;
+ }
+ }
+ // mPDF 5.5.23
+ if(isset($attr['DIVIDER'])) {
+ $objattr['divider'] = strcode2utf($attr['DIVIDER']);
+ $objattr['divider'] = $this->lesser_entity_decode($objattr['divider']);
+ if ($this->onlyCoreFonts)
+ $objattr['divider'] = mb_convert_encoding($objattr['divider'], $this->mb_enc,'UTF-8');
+
+ }
+
+ if (isset($properties['COLOR'])) { $objattr['color'] = $this->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->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
+ }
+ $objattr['fontfamily'] = $this->FontFamily;
+
+ // VSPACE and HSPACE converted to margins in MergeCSS
+ if (isset($properties['MARGIN-TOP'])) { $objattr['margin_top']=$this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-BOTTOM'])) { $objattr['margin_bottom'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-LEFT'])) { $objattr['margin_left'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['MARGIN-RIGHT'])) { $objattr['margin_right'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['PADDING-TOP'])) { $objattr['padding_top']=$this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-BOTTOM'])) { $objattr['padding_bottom'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-LEFT'])) { $objattr['padding_left'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ if (isset($properties['PADDING-RIGHT'])) { $objattr['padding_right'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['BORDER-TOP'])) { $objattr['border_top'] = $this->border_details($properties['BORDER-TOP']); }
+ if (isset($properties['BORDER-BOTTOM'])) { $objattr['border_bottom'] = $this->border_details($properties['BORDER-BOTTOM']); }
+ if (isset($properties['BORDER-LEFT'])) { $objattr['border_left'] = $this->border_details($properties['BORDER-LEFT']); }
+ if (isset($properties['BORDER-RIGHT'])) { $objattr['border_right'] = $this->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->ConvertColor($properties['BACKGROUND-COLOR']); }
+ else { $objattr['bgcolor'] = false; }
+ if ($this->HREF) {
+ if (strpos($this->HREF,".") === false && strpos($this->HREF,"@") !== 0) {
+ $href = $this->HREF;
+ while(array_key_exists($href,$this->internallink)) $href="#".$href;
+ $this->internallink[$href] = $this->AddLink();
+ $objattr['link'] = $this->internallink[$href];
+ }
+ else { $objattr['link'] = $this->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->tableLevel) {
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
+ }
+ else {
+/*-- END TABLES --*/
+ $this->_saveTextBuffer($e, $this->HREF);
+ } // *TABLES*
+
+ if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+
+ break;
+
+
+/*-- TABLES --*/
+
+ case 'TABLE': // TABLE-BEGIN
+ $this->tdbegin = false;
+ $this->lastoptionaltag = '';
+ // Disable vertical justification in columns
+ if ($this->ColActive) { $this->colvAlign = ''; } // *COLUMNS*
+ if ($this->lastblocklevelchange == 1) { $blockstate = 1; } // Top margins/padding only
+ else if ($this->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding
+ // called from block after new div e.g.
...
... Outputs block top margin/border and padding
+ if (count($this->textbuffer) == 0 && $this->lastblocklevelchange == 1 && !$this->tableLevel && !$this->kwt) {
+ $this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,false,1,true, $this->blk[$this->blklvl]['direction']);
+ $this->finishFlowingBlock(true); // true = END of flowing block
+ }
+ else if (!$this->tableLevel && count($this->textbuffer)) { $this->printbuffer($this->textbuffer,$blockstate); }
+
+ $this->textbuffer=array();
+ $this->lastblocklevelchange = -1;
+ if ($this->tableLevel) { // i.e. now a nested table coming...
+ // Save current level table
+ // mPDF 5.4.10
+ $this->cell['PARENTCELL'] = $this->saveInlineProperties();
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['baseProperties']= $this->base_table_properties;
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = $this->cell;
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['currrow'] = $this->row;
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['currcol'] = $this->col;
+ }
+ $this->tableLevel++;
+ $this->cssmgr->tbCSSlvl++;
+
+ if ($this->tableLevel>1) { // inherit table properties from cell in which nested
+ $this->base_table_properties['FONT-KERNING'] = $this->kerning ;
+ $this->base_table_properties['LETTER-SPACING'] = $this->lSpacingCSS ;
+ $this->base_table_properties['WORD-SPACING'] = $this->wSpacingCSS ;
+ }
+
+ if (isset($this->tbctr[$this->tableLevel])) { $this->tbctr[$this->tableLevel]++; }
+ else { $this->tbctr[$this->tableLevel] = 1; }
+
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['level'] = $this->tableLevel;
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['levelid'] = $this->tbctr[$this->tableLevel];
+
+ if ($this->tableLevel > $this->innermostTableLevel) { $this->innermostTableLevel = $this->tableLevel; }
+ if ($this->tableLevel > 1) {
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nestedpos'] = array($this->row,$this->col,$this->tbctr[($this->tableLevel-1)]);
+ }
+ //++++++++++++++++++++++++++++
+
+ $this->cell = array();
+ $this->col=-1; //int
+ $this->row=-1; //int
+ $table = &$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]];
+
+ // New table - any level
+ if ($this->cacheTables) {
+ $this->packTableData = true; // required for cacheTables
+ $this->simpleTables = false; // Cannot co-exist with cacheTables
+ $table['cache'] = _MPDF_TEMP_PATH.'_tempTblCache'.RAND(1,1000000).'.dat';
+ $fh = fopen($table['cache'] , "wb") or $this->Error("When using cacheTables, you must have read/write access to cache files (".$table['cache'] .")");
+ fwrite($fh, "\x00");
+ fclose($fh);
+ $table['ptr'] = 1 ; // Must not be 0
+ }
+
+ $table['direction'] = $this->directionality;
+ $table['bgcolor'] = false;
+ $table['va'] = false;
+ $table['txta'] = false;
+ $table['topntail'] = false;
+ $table['thead-underline'] = false;
+ $table['border'] = false;
+ $table['border_details']['R']['w'] = 0;
+ $table['border_details']['L']['w'] = 0;
+ $table['border_details']['T']['w'] = 0;
+ $table['border_details']['B']['w'] = 0;
+ $table['border_details']['R']['style'] = '';
+ $table['border_details']['L']['style'] = '';
+ $table['border_details']['T']['style'] = '';
+ $table['border_details']['B']['style'] = '';
+ $table['max_cell_border_width']['R'] = 0;
+ $table['max_cell_border_width']['L'] = 0;
+ $table['max_cell_border_width']['T'] = 0;
+ $table['max_cell_border_width']['B'] = 0;
+ $table['padding']['L'] = false;
+ $table['padding']['R'] = false;
+ $table['padding']['T'] = false;
+ $table['padding']['B'] = false;
+ $table['margin']['L'] = false;
+ $table['margin']['R'] = false;
+ $table['margin']['T'] = false;
+ $table['margin']['B'] = false;
+ $table['a'] = false;
+ $table['border_spacing_H'] = false;
+ $table['border_spacing_V'] = false;
+ $table['decimal_align'] = false; // mPDF 5.6.13
+ $this->Reset();
+ $this->InlineProperties = array();
+ $this->spanlvl = 0;
+ $table['nc'] = $table['nr'] = 0;
+ $this->tablethead = 0;
+ $this->tabletfoot = 0;
+ $this->tabletheadjustfinished = false;
+
+
+ if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins && $this->tableLevel==1) { $lastbottommargin = $this->lastblockbottommargin; }
+ else { $lastbottommargin = 0; }
+ $this->lastblockbottommargin = 0;
+ $this->blockjustfinished=false;
+
+ if ($this->tableLevel==1) {
+ $this->tableCJK = false;
+ $this->table_lineheight = $this->normalLineheight;
+ $table['headernrows'] = 0;
+ $table['footernrows'] = 0;
+ $this->base_table_properties = array();
+ }
+
+ // ADDED CSS FUNCIONS FOR TABLE
+ if ($this->cssmgr->tbCSSlvl==1) {
+ $properties = $this->cssmgr->MergeCSS('TOPTABLE',$tag,$attr);
+ }
+ else {
+ $properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
+ }
+ $w = '';
+ if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
+ else if (isset($attr['WIDTH']) && $attr['WIDTH']) { $w = $attr['WIDTH']; }
+
+
+ if(isset($properties['DIRECTION']) && $properties['DIRECTION']) { $table['direction'] = strtolower($properties['DIRECTION']); }
+ else if(isset($attr['DIR']) && $attr['DIR']) { $table['direction'] = strtolower($attr['DIR']); }
+ else if (!isset($table['direction'])){ $table['direction'] = $this->blk[$this->blklvl]['direction']; }
+
+ if (isset($properties['BACKGROUND-COLOR'])) { $table['bgcolor'][-1] = $properties['BACKGROUND-COLOR']; }
+ else if (isset($properties['BACKGROUND'])) { $table['bgcolor'][-1] = $properties['BACKGROUND']; }
+ else if (isset($attr['BGCOLOR'])) { $table['bgcolor'][-1] = $attr['BGCOLOR']; }
+ if (isset($properties['VERTICAL-ALIGN'])) { $table['va'] = $align[strtolower($properties['VERTICAL-ALIGN'])]; }
+ if (isset($properties['TEXT-ALIGN'])) { $table['txta'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
+ if (isset($attr['ALIGN'])) { $table['a'] = $align[strtolower($attr['ALIGN'])]; }
+ if (!$table['a']) {
+ if ($table['direction'] == 'rtl' ) { $table['a'] = 'R'; }
+ else { $table['a'] = 'L'; }
+ }
+
+ if (isset($properties['AUTOSIZE']) && $properties['AUTOSIZE'] && $this->tableLevel ==1) {
+ $this->shrink_this_table_to_fit = $properties['AUTOSIZE'];
+ if ($this->shrink_this_table_to_fit < 1) { $this->shrink_this_table_to_fit = 0; }
+ }
+ if (isset($properties['ROTATE']) && $properties['ROTATE'] && $this->tableLevel ==1) {
+ $this->table_rotate = $properties['ROTATE'];
+ }
+ if (isset($properties['TOPNTAIL'])) { $table['topntail'] = $properties['TOPNTAIL']; }
+ if (isset($properties['THEAD-UNDERLINE'])) { $table['thead-underline'] = $properties['THEAD-UNDERLINE']; }
+
+ if (isset($properties['BORDER'])) {
+ $bord = $this->border_details($properties['BORDER']);
+ if ($bord['s']) {
+ $table['border'] = _BORDER_ALL;
+ $table['border_details']['R'] = $bord;
+ $table['border_details']['L'] = $bord;
+ $table['border_details']['T'] = $bord;
+ $table['border_details']['B'] = $bord;
+ }
+ }
+ if (isset($properties['BORDER-RIGHT'])) {
+ if ($table['direction'] == 'rtl') { // *RTL*
+ $table['border_details']['R'] = $this->border_details($properties['BORDER-LEFT']); // *RTL*
+ } // *RTL*
+ else { // *RTL*
+ $table['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
+ } // *RTL*
+ $this->setBorder($table['border'], _BORDER_RIGHT, $table['border_details']['R']['s']);
+ }
+ if (isset($properties['BORDER-LEFT'])) {
+ if ($table['direction'] == 'rtl') { // *RTL*
+ $table['border_details']['L'] = $this->border_details($properties['BORDER-RIGHT']); // *RTL*
+ } // *RTL*
+ else { // *RTL*
+ $table['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
+ } // *RTL*
+ $this->setBorder($table['border'], _BORDER_LEFT, $table['border_details']['L']['s']);
+ }
+ if (isset($properties['BORDER-BOTTOM'])) {
+ $table['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
+ $this->setBorder($table['border'], _BORDER_BOTTOM, $table['border_details']['B']['s']);
+ }
+ if (isset($properties['BORDER-TOP'])) {
+ $table['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
+ $this->setBorder($table['border'], _BORDER_TOP, $table['border_details']['T']['s']);
+ }
+ if ($table['border']){
+ $this->table_border_css_set = 1;
+ }
+ else {
+ $this->table_border_css_set = 0;
+ }
+
+ if (isset($properties['FONT-FAMILY'])) {
+ $this->default_font = $properties['FONT-FAMILY'];
+ $this->SetFont($this->default_font,'',0,false);
+ }
+ $this->base_table_properties['FONT-FAMILY'] = $this->FontFamily; // mPDF 5.4.10
+
+ if (isset($properties['FONT-SIZE'])) {
+ // mPDF 5.4.10
+ if ($this->tableLevel>1) { $mmsize = $this->ConvertSize($properties['FONT-SIZE'], $this->base_table_properties['FONT-SIZE']); }
+ else { $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK); }
+ if ($mmsize) {
+ $this->default_font_size = $mmsize*(_MPDFK);
+ $this->SetFontSize($this->default_font_size,false);
+ }
+ }
+ $this->base_table_properties['FONT-SIZE'] = $this->FontSize.'mm'; // mPDF 5.4.10
+
+ if (isset($properties['FONT-WEIGHT'])) {
+ if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $this->base_table_properties['FONT-WEIGHT'] = 'BOLD'; }
+ }
+ if (isset($properties['FONT-STYLE'])) {
+ if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->base_table_properties['FONT-STYLE'] = 'ITALIC'; }
+ }
+ if (isset($properties['COLOR'])) {
+ $this->base_table_properties['COLOR'] = $properties['COLOR'];
+ }
+ if (isset($properties['FONT-KERNING'])) {
+ $this->base_table_properties['FONT-KERNING'] = $properties['FONT-KERNING'];
+ }
+ if (isset($properties['LETTER-SPACING'])) {
+ $this->base_table_properties['LETTER-SPACING'] = $properties['LETTER-SPACING'];
+ }
+ if (isset($properties['WORD-SPACING'])) {
+ $this->base_table_properties['WORD-SPACING'] = $properties['WORD-SPACING'];
+ }
+
+ if (isset($properties['PADDING-LEFT'])) {
+ $table['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['PADDING-RIGHT'])) {
+ $table['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['PADDING-TOP'])) {
+ $table['padding']['T'] = $this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['PADDING-BOTTOM'])) {
+ $table['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+
+ if (isset($properties['MARGIN-TOP'])) {
+ if ($lastbottommargin) {
+ $tmp = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if ($tmp > $lastbottommargin) { $properties['MARGIN-TOP'] -= $lastbottommargin; }
+ else { $properties['MARGIN-TOP'] = 0; }
+ }
+ $table['margin']['T'] = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+
+ if (isset($properties['MARGIN-BOTTOM'])) {
+ $table['margin']['B'] = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['MARGIN-LEFT'])) {
+ $table['margin']['L'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+
+ if (isset($properties['MARGIN-RIGHT'])) {
+ $table['margin']['R'] = $this->ConvertSize($properties['MARGIN-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['MARGIN-LEFT']) && isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-LEFT'])=='auto' && strtolower($properties['MARGIN-RIGHT'])=='auto') {
+ $table['a'] = 'C';
+ }
+ else if (isset($properties['MARGIN-LEFT']) && strtolower($properties['MARGIN-LEFT'])=='auto') {
+ $table['a'] = 'R';
+ }
+ else if (isset($properties['MARGIN-RIGHT']) && strtolower($properties['MARGIN-RIGHT'])=='auto') {
+ $table['a'] = 'L';
+ }
+
+ if (isset($properties['LINE-HEIGHT']) && $this->tableLevel==1) {
+ $this->table_lineheight = $this->fixLineheight($properties['LINE-HEIGHT']);
+ if (!$this->table_lineheight) { $this->table_lineheight = $this->normalLineheight; }
+ }
+
+ if (isset($properties['BORDER-COLLAPSE']) && strtoupper($properties['BORDER-COLLAPSE'])=='SEPARATE') {
+ $table['borders_separate'] = true;
+ }
+ else {
+ $table['borders_separate'] = false;
+ }
+
+ if (!$table['borders_separate']) { $table['border_spacing_H'] = $table['border_spacing_V'] = 0; }
+ else if (isset($attr['CELLSPACING'])) {
+ $table['border_spacing_H'] = $table['border_spacing_V'] = $this->ConvertSize($attr['CELLSPACING'],$this->blk[$this->blklvl]['inner_width']);
+ }
+ if (isset($properties['BORDER-SPACING-H'])) {
+ $table['border_spacing_H'] = $this->ConvertSize($properties['BORDER-SPACING-H'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['BORDER-SPACING-V'])) {
+ $table['border_spacing_V'] = $this->ConvertSize($properties['BORDER-SPACING-V'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+
+ if (isset($properties['EMPTY-CELLS'])) {
+ $table['empty_cells'] = strtolower($properties['EMPTY-CELLS']); // 'hide' or 'show'
+ }
+ else { $table['empty_cells'] = ''; }
+
+ if (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE'])=='AVOID' && $this->tableLevel==1 && !$this->writingHTMLfooter) {
+ $this->table_keep_together = true;
+ }
+ else if ($this->tableLevel==1) {
+ $this->table_keep_together = false;
+ }
+ if (isset($properties['PAGE-BREAK-AFTER']) && $this->tableLevel==1) {
+ $table['page_break_after'] = strtoupper($properties['PAGE-BREAK-AFTER']);
+ }
+
+/*-- BACKGROUNDS --*/
+ if (isset($properties['BACKGROUND-GRADIENT']) && !$this->kwt && !$this->ColActive) { $table['gradient'] = $properties['BACKGROUND-GRADIENT']; }
+
+ if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->kwt && !$this->ColActive) {
+ $ret = $this->SetBackground($properties, $currblk['inner_width']);
+ if ($ret) { $table['background-image'] = $ret; }
+ }
+/*-- END BACKGROUNDS --*/
+
+ if (isset($properties['OVERFLOW'])) {
+ $table['overflow'] = strtolower($properties['OVERFLOW']); // 'hidden' 'wrap' or 'visible' or 'auto'
+ if (($this->ColActive || $this->tableLevel>1) && $table['overflow']=='visible') { unset($table['overflow']); }
+ }
+
+ $properties = array();
+
+
+
+ if (isset($attr['CELLPADDING'])) {
+ $table['cell_padding'] = $attr['CELLPADDING'];
+ }
+ else {
+ $table['cell_padding'] = false;
+ }
+
+ if (isset($attr['BORDER']) && $attr['BORDER']=='1') { // mPDF 5.5.08
+ $this->table_border_attr_set = 1; // mPDF 5.5.08
+ $bord = $this->border_details('#000000 1px solid');
+ if ($bord['s']) {
+ $table['border'] = _BORDER_ALL;
+ $table['border_details']['R'] = $bord;
+ $table['border_details']['L'] = $bord;
+ $table['border_details']['T'] = $bord;
+ $table['border_details']['B'] = $bord;
+ }
+ }
+ else {
+ $this->table_border_attr_set = 0;
+ }
+
+ if ($w) {
+ $maxwidth = $this->blk[$this->blklvl]['inner_width'];
+ if ($table['borders_separate']) {
+ $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['border_details']['L']['w']/2 + $table['border_details']['R']['w']/2;
+ }
+ else {
+ $tblblw = $table['margin']['L'] + $table['margin']['R'] + $table['max_cell_border_width']['L']/2 + $table['max_cell_border_width']['R']/2;
+ }
+ if (strpos($w,'%') && $this->tableLevel == 1 && !$this->ignore_table_percents ) {
+ // % needs to be of inner box without table margins etc.
+ $maxwidth -= $tblblw ;
+ $wmm = $this->ConvertSize($w,$maxwidth,$this->FontSize,false);
+ $table['w'] = $wmm + $tblblw ;
+ }
+ if (strpos($w,'%') && $this->tableLevel > 1 && !$this->ignore_table_percents && $this->keep_table_proportions) {
+ $table['wpercent'] = $w + 0; // makes 80% -> 80
+ }
+ if (!strpos($w,'%') && !$this->ignore_table_widths ) {
+ $wmm = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ $table['w'] = $wmm + $tblblw ;
+ }
+ if (!$this->keep_table_proportions) {
+ if (isset($table['w']) && $table['w'] > $this->blk[$this->blklvl]['inner_width']) { $table['w'] = $this->blk[$this->blklvl]['inner_width']; }
+ }
+ }
+
+ if (isset($attr['AUTOSIZE']) && $this->tableLevel==1) {
+ $this->shrink_this_table_to_fit = $attr['AUTOSIZE'];
+ if ($this->shrink_this_table_to_fit < 1) { $this->shrink_this_table_to_fit = 1; }
+ }
+ if (isset($attr['ROTATE']) && $this->tableLevel==1) {
+ $this->table_rotate = $attr['ROTATE'];
+ }
+
+ //++++++++++++++++++++++++++++
+ // keeping block together on one page
+ // Autosize is now forced therefore keep block together disabled
+ if ($this->keep_block_together) {
+ $this->keep_block_together = 0;
+ $this->printdivbuffer();
+ $this->blk[$this->blklvl]['keep_block_together'] = 0;
+ }
+ if ($this->table_rotate) {
+ $this->tbrot_Links = array();
+ $this->tbrot_Annots = array();
+ $this->tbrotForms = array();
+ $this->tbrot_Reference = array();
+ $this->tbrot_BMoutlines = array();
+ $this->tbrot_toc = array();
+ }
+
+ if ($this->kwt) {
+ if ($this->table_rotate) { $this->table_keep_together = true; }
+ $this->kwt = false;
+ $this->kwt_saved = true;
+ }
+
+ if ($this->tableLevel==1 && $this->useGraphs) {
+ if (isset($attr['ID']) && $attr['ID']) { $this->currentGraphId = strtoupper($attr['ID']); }
+ else { $this->currentGraphId = '0'; }
+ $this->graphs[$this->currentGraphId] = array();
+ }
+ //++++++++++++++++++++++++++++
+ $this->plainCell_properties = array();
+ unset($table);
+ break;
+
+ case 'THEAD':
+ $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
+ $this->cssmgr->tbCSSlvl++;
+ $this->tablethead = 1;
+ $this->tabletfoot = 0;
+ $properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
+ if (isset($properties['FONT-WEIGHT'])) {
+ if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $this->thead_font_weight = 'B'; }
+ else { $this->thead_font_weight = ''; }
+ }
+
+ if (isset($properties['FONT-STYLE'])) {
+ if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->thead_font_style = 'I'; }
+ else { $this->thead_font_style = ''; }
+ }
+ if (isset($properties['FONT-VARIANT'])) {
+ if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->thead_font_smCaps = 'S'; }
+ else { $this->thead_font_smCaps = ''; }
+ }
+
+ if (isset($properties['VERTICAL-ALIGN'])) {
+ $this->thead_valign_default = $properties['VERTICAL-ALIGN'];
+ }
+ if (isset($properties['TEXT-ALIGN'])) {
+ $this->thead_textalign_default = $properties['TEXT-ALIGN'];
+ }
+ $properties = array();
+ break;
+
+ case 'TFOOT':
+ $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
+ $this->cssmgr->tbCSSlvl++;
+ $this->tabletfoot = 1;
+ $this->tablethead = 0;
+ $properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
+ if (isset($properties['FONT-WEIGHT'])) {
+ if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $this->tfoot_font_weight = 'B'; }
+ else { $this->tfoot_font_weight = ''; }
+ }
+
+ if (isset($properties['FONT-STYLE'])) {
+ if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->tfoot_font_style = 'I'; }
+ else { $this->tfoot_font_style = ''; }
+ }
+ if (isset($properties['FONT-VARIANT'])) {
+ if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->tfoot_font_smCaps = 'S'; }
+ else { $this->tfoot_font_smCaps = ''; }
+ }
+
+ if (isset($properties['VERTICAL-ALIGN'])) {
+ $this->tfoot_valign_default = $properties['VERTICAL-ALIGN'];
+ }
+ if (isset($properties['TEXT-ALIGN'])) {
+ $this->tfoot_textalign_default = $properties['TEXT-ALIGN'];
+ }
+ $properties = array();
+ break;
+
+
+ case 'TBODY':
+ $this->tablethead = 0;
+ $this->tabletfoot = 0;
+ $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
+ $this->cssmgr->tbCSSlvl++;
+ $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
+ break;
+
+
+ case 'TR':
+ $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
+ $this->cssmgr->tbCSSlvl++;
+ $this->row++;
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nr']++;
+ $this->col = -1;
+ $properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
+
+ if (!$this->simpleTables && (!isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['borders_separate']) || !$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['borders_separate'])) {
+ if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-left'][$this->row] = $properties['BORDER-LEFT']; }
+ if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-right'][$this->row] = $properties['BORDER-RIGHT']; }
+ if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-top'][$this->row] = $properties['BORDER-TOP']; }
+ if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-bottom'][$this->row] = $properties['BORDER-BOTTOM']; }
+ }
+
+ if (isset($properties['BACKGROUND-COLOR'])) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['bgcolor'][$this->row] = $properties['BACKGROUND-COLOR']; }
+ else if (isset($attr['BGCOLOR'])) $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['bgcolor'][$this->row] = $attr['BGCOLOR'];
+
+/*-- BACKGROUNDS --*/
+ if (isset($properties['BACKGROUND-GRADIENT']) && !$this->kwt && !$this->ColActive) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trgradients'][$this->row] = $properties['BACKGROUND-GRADIENT']; }
+
+ if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->kwt && !$this->ColActive) {
+ $ret = $this->SetBackground($properties, $currblk['inner_width']);
+ if ($ret) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trbackground-images'][$this->row] = $ret; }
+ }
+/*-- END BACKGROUNDS --*/
+
+
+ if (isset($properties['TEXT-ROTATE'])) {
+ $this->trow_text_rotate = $properties['TEXT-ROTATE'];
+ }
+ if (isset($attr['TEXT-ROTATE'])) $this->trow_text_rotate = $attr['TEXT-ROTATE'];
+
+ if ($this->tablethead) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead'][$this->row] = true; }
+ if ($this->tabletfoot) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$this->row] = true; }
+ $properties = array();
+ break;
+
+
+ case 'TH':
+ case 'TD':
+ $this->ignorefollowingspaces = true;
+ $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
+ $this->cssmgr->tbCSSlvl++;
+ $this->InlineProperties = array();
+ $this->spanlvl = 0;
+ $this->tdbegin = true;
+ $this->col++;
+ while (isset($this->cell[$this->row][$this->col])) { $this->col++; }
+
+ //Update number column
+ if ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] < $this->col+1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] = $this->col+1; }
+
+ $table = &$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]];
+
+ $c = array('a' => false,
+ 'R' => false,
+ 'nowrap' => false,
+ 'bgcolor' => false,
+ 'padding' => array('L' => false,
+ 'R' => false,
+ 'T' => false,
+ 'B' => false
+ )
+ );
+
+ if ($this->simpleTables && $this->row==0 && $this->col==0){
+ $table['simple']['border'] = false;
+ $table['simple']['border_details']['R']['w'] = 0;
+ $table['simple']['border_details']['L']['w'] = 0;
+ $table['simple']['border_details']['T']['w'] = 0;
+ $table['simple']['border_details']['B']['w'] = 0;
+ $table['simple']['border_details']['R']['style'] = '';
+ $table['simple']['border_details']['L']['style'] = '';
+ $table['simple']['border_details']['T']['style'] = '';
+ $table['simple']['border_details']['B']['style'] = '';
+ }
+ else if (!$this->simpleTables) {
+ $c['border'] = false;
+ $c['border_details']['R']['w'] = 0;
+ $c['border_details']['L']['w'] = 0;
+ $c['border_details']['T']['w'] = 0;
+ $c['border_details']['B']['w'] = 0;
+ $c['border_details']['mbw']['BL'] = 0;
+ $c['border_details']['mbw']['BR'] = 0;
+ $c['border_details']['mbw']['RT'] = 0;
+ $c['border_details']['mbw']['RB'] = 0;
+ $c['border_details']['mbw']['TL'] = 0;
+ $c['border_details']['mbw']['TR'] = 0;
+ $c['border_details']['mbw']['LT'] = 0;
+ $c['border_details']['mbw']['LB'] = 0;
+ $c['border_details']['R']['style'] = '';
+ $c['border_details']['L']['style'] = '';
+ $c['border_details']['T']['style'] = '';
+ $c['border_details']['B']['style'] = '';
+ $c['border_details']['R']['s'] = 0;
+ $c['border_details']['L']['s'] = 0;
+ $c['border_details']['T']['s'] = 0;
+ $c['border_details']['B']['s'] = 0;
+ $c['border_details']['R']['c'] = $this->ConvertColor(0);
+ $c['border_details']['L']['c'] = $this->ConvertColor(0);
+ $c['border_details']['T']['c'] = $this->ConvertColor(0);
+ $c['border_details']['B']['c'] = $this->ConvertColor(0);
+ $c['border_details']['R']['dom'] = 0;
+ $c['border_details']['L']['dom'] = 0;
+ $c['border_details']['T']['dom'] = 0;
+ $c['border_details']['B']['dom'] = 0;
+ }
+
+
+ if ($table['va']) { $c['va'] = $table['va']; }
+ if ($table['txta']) { $c['a'] = $table['txta']; }
+ if ($this->table_border_attr_set) {
+ if ($table['border_details']) {
+ if (!$this->simpleTables){
+ $c['border_details']['R'] = $table['border_details']['R'];
+ $c['border_details']['L'] = $table['border_details']['L'];
+ $c['border_details']['T'] = $table['border_details']['T'];
+ $c['border_details']['B'] = $table['border_details']['B'];
+ $c['border'] = $table['border'];
+ $c['border_details']['L']['dom'] = 1;
+ $c['border_details']['R']['dom'] = 1;
+ $c['border_details']['T']['dom'] = 1;
+ $c['border_details']['B']['dom'] = 1;
+ }
+ else if ($this->simpleTables && $this->row==0 && $this->col==0){
+ $table['simple']['border_details']['R'] = $table['border_details']['R'];
+ $table['simple']['border_details']['L'] = $table['border_details']['L'];
+ $table['simple']['border_details']['T'] = $table['border_details']['T'];
+ $table['simple']['border_details']['B'] = $table['border_details']['B'];
+ $table['simple']['border'] = $table['border'];
+ }
+ }
+ }
+ // INHERITED THEAD CSS Properties
+ if ($this->tablethead) {
+ if ($this->thead_valign_default) $c['va'] = $align[strtolower($this->thead_valign_default)];
+ if ($this->thead_textalign_default) $c['a'] = $align[strtolower($this->thead_textalign_default)];
+ if ($this->thead_font_weight == 'B') { $this->SetStyle('B',true); }
+ if ($this->thead_font_style == 'I') { $this->SetStyle('I',true); }
+ if ($this->thead_font_smCaps == 'S') { $this->SetStyle('S',true); }
+ }
+
+ // INHERITED TFOOT CSS Properties
+ if ($this->tabletfoot) {
+ if ($this->tfoot_valign_default) $c['va'] = $align[strtolower($this->tfoot_valign_default)];
+ if ($this->tfoot_textalign_default) $c['a'] = $align[strtolower($this->tfoot_textalign_default)];
+ if ($this->tfoot_font_weight == 'B') { $this->SetStyle('B',true); }
+ if ($this->tfoot_font_style == 'I') { $this->SetStyle('I',true); }
+ if ($this->tfoot_font_style == 'S') { $this->SetStyle('S',true); }
+ }
+
+
+ if ($this->trow_text_rotate){
+ $c['R'] = $this->trow_text_rotate;
+ }
+
+ $this->cell_border_dominance_L = 0;
+ $this->cell_border_dominance_R = 0;
+ $this->cell_border_dominance_T = 0;
+ $this->cell_border_dominance_B = 0;
+
+ $properties = $this->cssmgr->MergeCSS('TABLE',$tag,$attr);
+ $properties = $this->cssmgr->array_merge_recursive_unique($this->base_table_properties, $properties);
+
+ if (isset($properties['FONT-KERNING']) && (strtoupper($properties['FONT-KERNING'])=='NORMAL' || strtoupper($properties['FONT-KERNING'])=='AUTO')) {
+ $this->kerning = true;
+ }
+ else { $this->kerning = false; }
+
+ if (isset($properties['LETTER-SPACING']) && ($properties['LETTER-SPACING'] || $properties['LETTER-SPACING']==='0') && strtoupper($properties['LETTER-SPACING']) != 'NORMAL') {
+ $this->lSpacingCSS = strtoupper($properties['LETTER-SPACING']);
+ $this->fixedlSpacing = $this->ConvertSize($this->lSpacingCSS,$this->FontSize);
+ }
+ else {
+ $this->lSpacingCSS = '';
+ $this->fixedlSpacing = false;
+ }
+ if (isset($properties['WORD-SPACING']) && strtoupper($properties['WORD-SPACING']) != 'NORMAL') {
+ $this->wSpacingCSS = strtoupper($properties['WORD-SPACING']);
+ $this->minwSpacing = $this->ConvertSize($this->wSpacingCSS,$this->FontSize);
+ }
+ else {
+ $this->minwSpacing = 0;
+ $this->wSpacingCSS = '';
+ }
+ // mPDF 5.6.08
+ if (isset($properties['HYPHENS']) && $properties['HYPHENS']) {
+ if (strtoupper($properties['HYPHENS']) == 'NONE') { $this->textparam['hyphens'] = 2; }
+ else if (strtoupper($properties['HYPHENS']) == 'AUTO') { $this->textparam['hyphens'] = 1; }
+ else if (strtoupper($properties['HYPHENS']) == 'MANUAL') { $this->textparam['hyphens'] = 0; }
+ }
+
+ if (isset($properties['BACKGROUND-COLOR'])) { $c['bgcolor'] = $properties['BACKGROUND-COLOR']; }
+ else if (isset($properties['BACKGROUND'])) { $c['bgcolor'] = $properties['BACKGROUND']; }
+ else if (isset($attr['BGCOLOR'])) $c['bgcolor'] = $attr['BGCOLOR'];
+
+
+
+/*-- BACKGROUNDS --*/
+ if (isset($properties['BACKGROUND-GRADIENT'])) { $c['gradient'] = $properties['BACKGROUND-GRADIENT']; }
+ else { $c['gradient'] = false; }
+
+ if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->keep_block_together) {
+ $ret = $this->SetBackground($properties, $this->blk[$this->blklvl]['inner_width']);
+ if ($ret) { $c['background-image'] = $ret; }
+ }
+/*-- END BACKGROUNDS --*/
+ if (isset($properties['VERTICAL-ALIGN'])) { $c['va']=$align[strtolower($properties['VERTICAL-ALIGN'])]; }
+ else if (isset($attr['VALIGN'])) $c['va'] = $align[strtolower($attr['VALIGN'])];
+
+
+ // mPDF 5.6.13
+ if (isset($properties['TEXT-ALIGN']) && $properties['TEXT-ALIGN']) {
+ if (substr($properties['TEXT-ALIGN'],0,1)=='D') { $c['a'] = $properties['TEXT-ALIGN']; }
+ else { $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
+ }
+ // mPDF 5.6.13
+ if (isset($attr['ALIGN']) && $attr['ALIGN']) {
+ if (strtolower($attr['ALIGN']) == 'char') {
+ if (isset($attr['CHAR']) && $attr['CHAR']) {
+ $char = html_entity_decode($attr['CHAR']);
+ $char = strcode2utf($char);
+ $d = array_search($char,$this->decimal_align);
+ if ($d !== false) { $c['a'] = $d.'R'; }
+ }
+ else { $c['a'] = 'DPR'; }
+ }
+ else { $c['a'] = $align[strtolower($attr['ALIGN'])]; }
+ }
+
+ if (!$c['a']) {
+ if (isset($table['direction']) && $table['direction'] == 'rtl' ) { $c['a'] = 'R'; }
+ else { $c['a'] = 'L'; }
+ }
+
+
+ if (isset($properties['TEXT-ROTATE']) && ($properties['TEXT-ROTATE'] || $properties['TEXT-ROTATE']==="0")){
+ $c['R'] = $properties['TEXT-ROTATE'];
+ }
+ if (isset($properties['BORDER'])) {
+ $bord = $this->border_details($properties['BORDER']);
+ if ($bord['s']) {
+ if (!$this->simpleTables){
+ $c['border'] = _BORDER_ALL;
+ $c['border_details']['R'] = $bord;
+ $c['border_details']['L'] = $bord;
+ $c['border_details']['T'] = $bord;
+ $c['border_details']['B'] = $bord;
+ $c['border_details']['L']['dom'] = $this->cell_border_dominance_L;
+ $c['border_details']['R']['dom'] = $this->cell_border_dominance_R;
+ $c['border_details']['T']['dom'] = $this->cell_border_dominance_T;
+ $c['border_details']['B']['dom'] = $this->cell_border_dominance_B;
+ }
+ else if ($this->simpleTables && $this->row==0 && $this->col==0){
+ $table['simple']['border'] = _BORDER_ALL;
+ $table['simple']['border_details']['R'] = $bord;
+ $table['simple']['border_details']['L'] = $bord;
+ $table['simple']['border_details']['T'] = $bord;
+ $table['simple']['border_details']['B'] = $bord;
+ }
+ }
+ }
+ if (!$this->simpleTables){
+ if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
+ $c['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
+ $this->setBorder($c['border'], _BORDER_RIGHT, $c['border_details']['R']['s']);
+ $c['border_details']['R']['dom'] = $this->cell_border_dominance_R;
+ }
+ if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
+ $c['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
+ $this->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
+ $c['border_details']['L']['dom'] = $this->cell_border_dominance_L;
+ }
+ if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
+ $c['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
+ $this->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
+ $c['border_details']['B']['dom'] = $this->cell_border_dominance_B;
+ }
+ if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
+ $c['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
+ $this->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
+ $c['border_details']['T']['dom'] = $this->cell_border_dominance_T;
+ }
+ }
+ else if ($this->simpleTables && $this->row==0 && $this->col==0){
+ if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
+ $bord = $this->border_details($properties['BORDER-LEFT']);
+ if ($bord['s']) { $table['simple']['border'] = _BORDER_ALL; }
+ else { $table['simple']['border'] = 0; }
+ $table['simple']['border_details']['R'] = $bord;
+ $table['simple']['border_details']['L'] = $bord;
+ $table['simple']['border_details']['T'] = $bord;
+ $table['simple']['border_details']['B'] = $bord;
+ }
+ }
+
+ if ($this->simpleTables && $this->row==0 && $this->col==0 && !$table['borders_separate'] && $table['simple']['border'] ){
+ $table['border_details'] = $table['simple']['border_details'];
+ $table['border'] = $table['simple']['border'];
+ }
+
+ // Border set on TR (if collapsed only)
+ if (!$table['borders_separate'] && !$this->simpleTables && isset($table['trborder-left'][$this->row])) {
+ if ($this->col==0) {
+ $left = $this->border_details($table['trborder-left'][$this->row]);
+ $c['border_details']['L'] = $left;
+ $this->setBorder($c['border'], _BORDER_LEFT, $c['border_details']['L']['s']);
+ }
+ $c['border_details']['B'] = $this->border_details($table['trborder-bottom'][$this->row]);
+ $this->setBorder($c['border'], _BORDER_BOTTOM, $c['border_details']['B']['s']);
+ $c['border_details']['T'] = $this->border_details($table['trborder-top'][$this->row]);
+ $this->setBorder($c['border'], _BORDER_TOP, $c['border_details']['T']['s']);
+ }
+
+ if ($this->packTableData && !$this->simpleTables) {
+ $c['borderbin'] = $this->_packCellBorder($c);
+ unset($c['border']);
+ unset($c['border_details']);
+ }
+
+ if (isset($properties['PADDING-LEFT'])) {
+ $c['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['PADDING-RIGHT'])) {
+ $c['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['PADDING-BOTTOM'])) {
+ $c['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+ if (isset($properties['PADDING-TOP'])) {
+ $c['padding']['T'] = $this->ConvertSize($properties['PADDING-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+
+ $w = '';
+ if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
+ else if (isset($attr['WIDTH'])) { $w = $attr['WIDTH']; }
+ if ($w) {
+ if (strpos($w,'%') && !$this->ignore_table_percents ) { $c['wpercent'] = $w + 0; } // makes 80% -> 80
+ else if (!strpos($w,'%') && !$this->ignore_table_widths ) { $c['w'] = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ }
+
+ if (isset($properties['HEIGHT']) && !strpos($properties['HEIGHT'],'%')) { $c['h'] = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+ else if (isset($attr['HEIGHT']) && !strpos($attr['HEIGHT'],'%')) $c['h'] = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+
+
+ if (isset($properties['COLOR'])) {
+ $cor = $this->ConvertColor($properties['COLOR']);
+ if ($cor) {
+ $this->colorarray = $cor;
+ $this->SetTColor($cor);
+ }
+ }
+ if (isset($properties['FONT-FAMILY'])) {
+ $this->SetFont($properties['FONT-FAMILY'],'',0,false);
+ }
+ if (isset($properties['FONT-SIZE'])) {
+ $mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/_MPDFK);
+ if ($mmsize) {
+ $this->SetFontSize($mmsize*(_MPDFK),false);
+ }
+ }
+ $c['dfs'] = $this->FontSize; // Default Font size
+ if (isset($properties['FONT-WEIGHT'])) {
+ if (strtoupper($properties['FONT-WEIGHT']) == 'BOLD') { $this->SetStyle('B',true); }
+ }
+ if (isset($properties['FONT-STYLE'])) {
+ if (strtoupper($properties['FONT-STYLE']) == 'ITALIC') { $this->SetStyle('I',true); }
+ }
+ if (isset($properties['FONT-VARIANT'])) {
+ if (strtoupper($properties['FONT-VARIANT']) == 'SMALL-CAPS') { $this->SetStyle('S',true); }
+ }
+ if (isset($properties['TEXT-DECORATION'])) {
+ if (strtoupper($properties['TEXT-DECORATION']) == 'LINE-THROUGH') { $this->strike = true; }
+ else if (strtoupper($properties['TEXT-DECORATION']) == 'UNDERLINE') { $this->SetStyle('U',true); }
+ }
+ if (isset($properties['TEXT-SHADOW'])) {
+ $ts = $this->cssmgr->setCSStextshadow($properties['TEXT-SHADOW']);
+ if ($ts) { $this->textshadow = $ts; }
+ }
+ if (isset($properties['TEXT-TRANSFORM'])) {
+ if (strtoupper($properties['TEXT-TRANSFORM']) == 'CAPITALIZE') { $this->capitalize = true; }
+ else if (strtoupper($properties['TEXT-TRANSFORM']) == 'UPPERCASE') { $this->toupper = true; }
+ else if (strtoupper($properties['TEXT-TRANSFORM']) == 'LOWERCASE') { $this->tolower = true; }
+ }
+ if (isset($properties['WHITE-SPACE'])) {
+ if (strtoupper($properties['WHITE-SPACE']) == 'NOWRAP') { $c['nowrap']= 1; }
+ }
+ $properties = array();
+
+ if (isset($attr['TEXT-ROTATE'])) {
+ $c['R'] = $attr['TEXT-ROTATE'];
+ }
+ if (isset($attr['NOWRAP']) && $attr['NOWRAP']) $c['nowrap']= 1;
+
+ $this->cell[$this->row][$this->col] = $c;
+ unset($c);
+ $this->cell[$this->row][$this->col]['s'] = 0 ;
+
+ $cs = $rs = 1;
+ if (isset($attr['COLSPAN']) && $attr['COLSPAN']>1) $cs = $this->cell[$this->row][$this->col]['colspan'] = $attr['COLSPAN'];
+ if ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] < $this->col+$cs) {
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'] = $this->col+$cs;
+ } // following code moved outside if...
+ for($l=$this->col; $l < $this->col+$cs ;$l++) {
+ if ($l-$this->col) $this->cell[$this->row][$l] = 0;
+ }
+ if (isset($attr['ROWSPAN']) && $attr['ROWSPAN']>1) $rs = $this->cell[$this->row][$this->col]['rowspan'] = $attr['ROWSPAN'];
+ for ($k=$this->row ; $k < $this->row+$rs ;$k++) {
+ for($l=$this->col; $l < $this->col+$cs ;$l++) {
+ if ($k-$this->row || $l-$this->col) $this->cell[$k][$l] = 0;
+ }
+ }
+ unset($table);
+ break;
+/*-- END TABLES --*/
+
+
+/*-- LISTS --*/
+ // *********** LISTS ********************
+ case 'OL':
+ case 'UL':
+ $this->listjustfinished = false;
+
+ if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
+ else { $lastbottommargin = 0; }
+ $this->lastblockbottommargin = 0;
+ $this->blockjustfinished=false;
+
+ $this->linebreakjustfinished=false;
+ $this->lastoptionaltag = ''; // Save current HTML specified optional endtag
+ $this->cssmgr->listCSSlvl++;
+ if((!$this->tableLevel) && ($this->listlvl == 0)) {
+ $blockstate = 0;
+ //if ($this->lastblocklevelchange == 1) { $blockstate = -1; } // Top margins/padding only
+ //else if ($this->lastblocklevelchange < 1) { $blockstate = 0; } // NO margins/padding
+ // called from block after new div e.g. ...
... Outputs block top margin/border and padding
+ if (count($this->textbuffer) == 0 && $this->lastblocklevelchange == 1 && !$this->tableLevel && !$this->kwt) {
+ $this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,false,1,true, $this->blk[$this->blklvl]['direction']);
+ $this->finishFlowingBlock(true); // true = END of flowing block
+ }
+ else if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer,$blockstate); }
+ $this->textbuffer=array();
+ $this->lastblocklevelchange = -1;
+ }
+ // ol and ul types are mixed here
+ if ($this->listlvl == 0) {
+ $this->list_indent = array();
+ $this->list_align = array();
+ $this->list_lineheight = array();
+ $this->InlineProperties['LIST'] = array();
+ $this->InlineProperties['LISTITEM'] = array();
+ }
+
+/*-- TABLES --*/
+ // A simple list for inside a table
+ if($this->tableLevel) {
+ $this->list_indent[$this->listlvl] = 0; // mm default indent for each level
+ if ($tag == 'OL') $this->listtype = '1';
+ else if ($tag == 'UL') $this->listtype = 'disc';
+ if ($this->listlvl > 0) {
+ $this->listlist[$this->listlvl]['MAXNUM'] = $this->listnum; //save previous lvl's maxnum
+ }
+ $this->listlvl++;
+ // mPDF 5.6.15
+ if (isset($attr['START'])) { $this->listnum = intval($attr['START']); }
+ else { $this->listnum = 0; }
+ $this->listlist[$this->listlvl] = array('TYPE'=>$this->listtype,'MAXNUM'=>$this->listnum);
+ break;
+ }
+/*-- END TABLES --*/
+
+
+ if (($this->PDFA || $this->PDFX) && $tag == 'UL') {
+ if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "List bullets cannot use core font Zapfdingbats in PDFA1-b or PDFX/1-a. (Substitute characters from current font used if available, otherwise substitutes hyphen '-')"; }
+ }
+
+ if ($this->cssmgr->listCSSlvl==1) {
+ $properties = $this->cssmgr->MergeCSS('TOPLIST',$tag,$attr);
+ }
+ else {
+ $properties = $this->cssmgr->MergeCSS('LIST',$tag,$attr);
+ }
+ if (!empty($properties)) $this->setCSS($properties,'LIST');
+ // List-type
+
+ $this->listtype = '';
+ if (isset($properties['LIST-STYLE-TYPE'])) {
+ $this->listtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
+ }
+ else if (isset($properties['LIST-STYLE'])) {
+ $this->listtype = $this->_getListStyle($properties['LIST-STYLE']);
+ }
+ else if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listtype = $attr['TYPE']; }
+ if (!$this->listtype) {
+ if ($tag == 'OL') $this->listtype = '1';
+ if ($tag == 'UL') {
+ if ($this->listlvl % 3 == 0) $this->listtype = 'disc';
+ elseif ($this->listlvl % 3 == 1) $this->listtype = 'circle';
+ else $this->listtype = 'square';
+ }
+ }
+ if ($this->listlvl == 0) {
+ $this->inherit_lineheight = 0;
+ $this->listlvl++; // first depth level
+ // mPDF 5.6.15
+ if (isset($attr['START'])) { $this->listnum = intval($attr['START']); }
+ else { $this->listnum = 0; }
+ $this->listDir = (isset($this->blk[$this->blklvl]['direction']) ? $this->blk[$this->blklvl]['direction'] : null);
+ $occur = $this->listoccur[$this->listlvl] = 1;
+ $this->listlist[$this->listlvl][1] = array('TYPE'=>$this->listtype,'MAXNUM'=>$this->listnum);
+ }
+ else {
+ if (!empty($this->textbuffer))
+ {
+ $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
+ $this->listnum++;
+ }
+ // Save current lineheight to inherit
+ $this->textbuffer = array();
+ $occur = $this->listoccur[$this->listlvl];
+ $this->listlist[$this->listlvl][$occur]['MAXNUM'] = $this->listnum; //save previous lvl's maxnum
+ $this->listlvl++;
+ // mPDF 5.6.15
+ if (isset($attr['START'])) { $this->listnum = intval($attr['START']); }
+ else { $this->listnum = 0; }
+
+
+ if (!isset($this->listoccur[$this->listlvl]) || $this->listoccur[$this->listlvl] == 0) $this->listoccur[$this->listlvl] = 1;
+ else $this->listoccur[$this->listlvl]++;
+ $occur = $this->listoccur[$this->listlvl];
+ $this->listlist[$this->listlvl][$occur] = array('TYPE'=>$this->listtype,'MAXNUM'=>$this->listnum);
+ }
+
+
+ // TOP LEVEL ONLY
+ if ($this->listlvl == 1) {
+ if (isset($properties['MARGIN-TOP'])) {
+ if ($lastbottommargin) {
+ $tmp = $this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ if ($tmp > $lastbottommargin) { $properties['MARGIN-TOP'] -= $lastbottommargin; }
+ else { $properties['MARGIN-TOP'] = 0; }
+ }
+ $this->DivLn($this->ConvertSize($properties['MARGIN-TOP'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false),$this->blklvl,true,1); // collapsible
+ }
+ if (isset($properties['MARGIN-BOTTOM'])) {
+ $this->list_margin_bottom = $this->ConvertSize($properties['MARGIN-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
+ }
+
+ if (isset($this->blk[$this->blklvl]['line_height'])) {
+ $this->list_lineheight[$this->listlvl][$occur] = $this->blk[$this->blklvl]['line_height'];
+ }
+
+ if (isset($properties['DIRECTION']) && $properties['DIRECTION']) { $this->listDir = strtolower($properties['DIRECTION']); }
+ else if (isset($attr['DIR']) && $attr['DIR']) { $this->listDir = strtolower($attr['DIR']); }
+
+ }
+ $this->list_indent[$this->listlvl][$occur] = 5; // mm default indent for each level
+ if (isset($properties['TEXT-INDENT'])) { $this->list_indent[$this->listlvl][$occur] = $this->ConvertSize($properties['TEXT-INDENT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
+
+ if (isset($properties['TEXT-ALIGN'])) {
+ $this->list_align[$this->listlvl][$occur] = $align[strtolower($properties['TEXT-ALIGN'])];
+ }
+
+
+ if (isset($properties['LINE-HEIGHT'])) {
+ $this->list_lineheight[$this->listlvl][$occur] = $this->fixLineheight($properties['LINE-HEIGHT']);
+ }
+ else if ($this->listlvl>1 && isset($this->list_lineheight[($this->listlvl - 1)][1])) {
+ $this->list_lineheight[$this->listlvl][$occur] = end($this->list_lineheight[($this->listlvl - 1)]);
+ }
+ if (!isset($this->list_lineheight[$this->listlvl][$occur]) || !$this->list_lineheight[$this->listlvl][$occur]) {
+ $this->list_lineheight[$this->listlvl][$occur] = $this->normalLineheight;
+ }
+
+ $this->InlineProperties['LIST'][$this->listlvl][$occur] = $this->saveInlineProperties();
+ $properties = array();
+ break;
+
+
+
+ case 'LI':
+ // Start Block
+ $this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
+ $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
+/*-- TABLES --*/
+ // A simple list for inside a table
+ if($this->tableLevel) {
+ $this->blockjustfinished=false;
+
+ // If already something in the Cell
+ if ((isset($this->cell[$this->row][$this->col]['maxs']) && $this->cell[$this->row][$this->col]['maxs'] > 0 ) || $this->cell[$this->row][$this->col]['s'] > 0 ) {
+ $this->_saveCellTextBuffer("\n");
+ if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ $this->cell[$this->row][$this->col]['s'] = 0 ;
+ }
+ if ($this->listlvl == 0) { //in case of malformed HTML code. Example:(...)- Content
Paragraph1
(...)
+ $this->listlvl++; // first depth level
+ $this->listnum = 0; // reset
+ $this->listlist[$this->listlvl] = array('TYPE'=>'disc','MAXNUM'=>$this->listnum);
+ }
+
+ $this->listnum++;
+ switch($this->listlist[$this->listlvl]['TYPE']) {
+ case 'A':
+ $blt = $this->dec2alpha($this->listnum,true).$this->list_number_suffix;
+ break;
+ case 'a':
+ $blt = $this->dec2alpha($this->listnum,false).$this->list_number_suffix;
+ break;
+ case 'I':
+ $blt = $this->dec2roman($this->listnum,true).$this->list_number_suffix;
+ break;
+ case 'i':
+ $blt = $this->dec2roman($this->listnum,false).$this->list_number_suffix;
+ break;
+ case '1':
+ $blt = $this->listnum.$this->list_number_suffix;
+ break;
+ default:
+ if ($this->listlvl % 3 == 1 && $this->_charDefined($this->CurrentFont['cw'],8226)) { $blt = "\xe2\x80\xa2"; } // •
+ else if ($this->listlvl % 3 == 2 && $this->_charDefined($this->CurrentFont['cw'],9900)) { $blt = "\xe2\x9a\xac"; } // ⚬
+ else if ($this->listlvl % 3 == 0 && $this->_charDefined($this->CurrentFont['cw'],9642)) { $blt = "\xe2\x96\xaa"; } // ▪
+ else { $blt = '-'; }
+ break;
+ }
+
+ // change to spaces
+ if ($this->usingCoreFont) {
+ $ls = str_repeat(chr(160).chr(160),($this->listlvl-1)*2) . $blt . ' ';
+ }
+ else {
+ $ls = str_repeat("\xc2\xa0\xc2\xa0",($this->listlvl-1)*2) . $blt . ' ';
+ }
+
+ $this->_saveCellTextBuffer($ls, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $this->GetStringWidth($ls);
+ break;
+ }
+/*-- END TABLES --*/
+ //Observation: is ignored
+ if ($this->listlvl == 0) { //in case of malformed HTML code. Example:(...)- Content
Paragraph1
(...)
+ //First of all, skip a line
+ $this->listlvl++; // first depth level
+ $this->listnum = 0; // reset
+ $this->listoccur[$this->listlvl] = 1;
+ $this->listlist[$this->listlvl][1] = array('TYPE'=>'disc','MAXNUM'=>$this->listnum);
+ }
+ if ($this->listnum == 0) {
+ $this->listnum++;
+ $this->textbuffer = array();
+ }
+ else {
+ if (!empty($this->textbuffer)) {
+ if (!$this->listjustfinished) {
+ $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
+ $this->listnum++;
+ }
+ else {
+ $this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype, true);
+ }
+ }
+ $this->textbuffer = array();
+ }
+ $this->listjustfinished = false;
+
+ $this->cssmgr->listCSSlvl++;
+ $properties = $this->cssmgr->MergeCSS('LIST',$tag,$attr);
+ if (!empty($properties)) $this->setCSS($properties,'LIST');
+ $this->InlineProperties['LISTITEM'][$this->listlvl][$this->listoccur[$this->listlvl]][$this->listnum] = $this->saveInlineProperties();
+
+ // List-type
+ if (isset($properties['LIST-STYLE-TYPE'])) {
+ $this->listitemtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
+ }
+ else if (isset($properties['LIST-STYLE'])) {
+ $this->listitemtype = $this->_getListStyle($properties['LIST-STYLE']);
+ }
+ else if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listitemtype = $attr['TYPE']; }
+ else $this->listitemtype = '';
+ break;
+/*-- END LISTS --*/
+
+ }//end of switch
+}
+
+/*-- LISTS --*/
+
+function _getListStyle($ls) {
+ if (stristr($ls,'decimal')) { return '1'; }
+/* CSS3 list-styles numeric (selected) + I added tamil
+arabic-indic | bengali | devanagari | gujarati | gurmukhi | kannada | malayalam | oriya | persian | telugu | thai | urdu
+*/
+ else if (preg_match('/(disc|circle|square|arabic-indic|bengali|devanagari|gujarati|gurmukhi|kannada|malayalam|oriya|persian|tamil|telugu|thai|urdu)/i',$ls,$m)) {
+ return strtolower(trim($m[1]));
+ }
+ else if (stristr($ls,'lower-roman')) { return 'i'; }
+ else if (stristr($ls,'upper-roman')) { return 'I'; }
+ else if (stristr($ls,'lower-latin')|| stristr($ls,'lower-alpha')) { return 'a'; }
+ else if (stristr($ls,'upper-latin') || stristr($ls,'upper-alpha')) { return 'A'; }
+ else if (stristr($ls,'none')) { return 'none'; }
+ else if (preg_match('/U\+([a-fA-F0-9]+)/i',$ls)) { return $ls; }
+ else { return ''; }
+}
+/*-- END LISTS --*/
+
+
+
+function CloseTag($tag)
+{
+ $this->ignorefollowingspaces = false; //Eliminate exceeding left-side spaces
+ //Closing tag
+ if($tag=='OPTION') { $this->selectoption['ACTIVE'] = false; $this->lastoptionaltag = ''; }
+
+ if($tag=='TTS' or $tag=='TTA' or $tag=='TTZ') {
+ if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+ $ltag = strtolower($tag);
+ $this->$ltag = false;
+ }
+
+
+ if($tag=='FONT' || $tag=='SPAN' || $tag=='CODE' || $tag=='KBD' || $tag=='SAMP' || $tag=='TT' || $tag=='VAR'
+ || $tag=='INS' || $tag=='STRONG' || $tag=='CITE' || $tag=='SUB' || $tag=='SUP' || $tag=='S' || $tag=='STRIKE' || $tag=='DEL'
+ || $tag=='Q' || $tag=='EM' || $tag=='B' || $tag=='I' || $tag=='U' | $tag=='SMALL' || $tag=='BIG' || $tag=='ACRONYM'
+ || $tag=='MARK' || $tag=='TIME' || $tag=='PROGRESS' || $tag=='METER'
+ ) { // mPDF 5.5.09
+
+ if ($tag == 'SPAN') {
+ if (isset($this->InlineProperties['SPAN'][$this->spanlvl]) && $this->InlineProperties['SPAN'][$this->spanlvl]) { $this->restoreInlineProperties($this->InlineProperties['SPAN'][$this->spanlvl]); }
+ unset($this->InlineProperties['SPAN'][$this->spanlvl]);
+ if (isset($this->InlineAnnots['SPAN'][$this->spanlvl]) && $this->InlineAnnots['SPAN'][$this->spanlvl]) { $annot = $this->InlineAnnots['SPAN'][$this->spanlvl]; } // *ANNOTATIONS*
+ unset($this->InlineAnnots['SPAN'][$this->spanlvl]); // *ANNOTATIONS*
+ $this->spanlvl--;
+ }
+ else {
+ if (isset($this->InlineProperties[$tag]) && $this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+ if (isset($this->InlineAnnots[$tag]) && $this->InlineAnnots[$tag]) { $annot = $this->InlineAnnots[$tag]; } // *ANNOTATIONS*
+ unset($this->InlineAnnots[$tag]); // *ANNOTATIONS*
+ }
+
+/*-- ANNOTATIONS --*/
+ if (isset($annot)) {
+ if($this->tableLevel) { // *TABLES*
+ $this->cell[$this->row][$this->col]['textbuffer'][] = array($annot); // *TABLES*
+ } // *TABLES*
+ else { // *TABLES*
+ $this->textbuffer[] = array($annot);
+ } // *TABLES*
+ }
+/*-- END ANNOTATIONS --*/
+ }
+
+ if($tag=='METER' || $tag=='PROGRESS') {
+ $this->inMeter = false; // mPDF 5.5.09
+ }
+
+
+ if($tag=='A') {
+ $this->HREF='';
+ if (isset($this->InlineProperties['A'])) { $this->restoreInlineProperties($this->InlineProperties['A']); }
+ unset($this->InlineProperties['A']);
+ }
+
+ if($tag=='LEGEND') { // mPDF 5.4.18
+ if (count($this->textbuffer) && !$this->tableLevel) {
+ $leg = $this->textbuffer[(count($this->textbuffer)-1)];
+ unset($this->textbuffer[(count($this->textbuffer)-1)]);
+ $this->textbuffer = array_values($this->textbuffer);
+ $this->blk[$this->blklvl]['border_legend'] = $leg;
+ $this->blk[$this->blklvl]['margin_top'] += ($leg[11]/2)/_MPDFK;
+ $this->blk[$this->blklvl]['padding_top'] += ($leg[11]/2)/_MPDFK;
+ }
+ if (isset($this->InlineProperties['LEGEND'])) { $this->restoreInlineProperties($this->InlineProperties['LEGEND']); }
+ unset($this->InlineProperties['LEGEND']);
+ $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
+ }
+
+
+
+/*-- FORMS --*/
+ // *********** FORM ELEMENTS ********************
+
+ if($tag=='TEXTAREA') {
+ $this->specialcontent = '';
+ if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+ }
+
+
+ if($tag=='SELECT') {
+ $this->lastoptionaltag = '';
+ $texto = '';
+ if (isset($this->selectoption['SELECTED'])) { $texto = $this->selectoption['SELECTED']; }
+
+ if ($this->useActiveForms) { $w = $this->selectoption['MAXWIDTH']; }
+ else { $w = $this->GetStringWidth($texto); }
+ if ($w == 0) { $w = 5; }
+ $objattr['type'] = 'select';
+ $objattr['text'] = $texto;
+ if (isset($this->selectoption['NAME'])) { $objattr['fieldname'] = $this->selectoption['NAME']; }
+ if (isset($this->selectoption['READONLY'])) { $objattr['readonly'] = true; }
+ if (isset($this->selectoption['REQUIRED'])) { $objattr['required'] = true; }
+ if (isset($this->selectoption['SPELLCHECK'])) { $objattr['spellcheck'] = true; }
+ if (isset($this->selectoption['EDITABLE'])) { $objattr['editable'] = true; }
+ if (isset($this->selectoption['ONCHANGE'])) { $objattr['onChange'] = $this->selectoption['ONCHANGE']; }
+ if (isset($this->selectoption['ITEMS'])) { $objattr['items'] = $this->selectoption['ITEMS']; }
+ if (isset($this->selectoption['MULTIPLE'])) { $objattr['multiple'] = $this->selectoption['MULTIPLE']; }
+ if (isset($this->selectoption['DISABLED'])) { $objattr['disabled'] = $this->selectoption['DISABLED']; }
+ if (isset($this->selectoption['TITLE'])) { $objattr['title'] = $this->selectoption['TITLE']; }
+ if (isset($this->selectoption['COLOR'])) { $objattr['color'] = $this->selectoption['COLOR']; }
+ if (isset($this->selectoption['SIZE'])) { $objattr['size'] = $this->selectoption['SIZE']; }
+ if (isset($objattr['size']) && $objattr['size']>1) { $rows=$objattr['size']; } else { $rows = 1; }
+
+ $objattr['fontfamily'] = $this->FontFamily;
+ $objattr['fontsize'] = $this->FontSizePt;
+
+ $objattr['width'] = $w + ($this->form->form_element_spacing['select']['outer']['h']*2)+($this->form->form_element_spacing['select']['inner']['h']*2) + ($this->FontSize*1.4);
+ $objattr['height'] = ($this->FontSize*$rows) + ($this->form->form_element_spacing['select']['outer']['v']*2)+($this->form->form_element_spacing['select']['inner']['v']*2);
+ $e = "\xbb\xa4\xactype=select,objattr=".serialize($objattr)."\xbb\xa4\xac";
+
+ // Clear properties - tidy up
+ $properties = array();
+
+ // Output it to buffers
+ if ($this->tableLevel) { // *TABLES*
+ $this->_saveCellTextBuffer($e, $this->HREF);
+ $this->cell[$this->row][$this->col]['s'] += $objattr['width'] ; // *TABLES*
+ } // *TABLES*
+ else { // *TABLES*
+ $this->_saveTextBuffer($e, $this->HREF);
+ } // *TABLES*
+
+ $this->selectoption = array();
+ $this->specialcontent = '';
+
+ if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
+ unset($this->InlineProperties[$tag]);
+
+ }
+/*-- END FORMS --*/
+
+
+ // *********** BLOCKS ********************
+ // mPDF 5.4.18
+ if($tag=='P' || $tag=='DIV' || $tag=='H1' || $tag=='H2' || $tag=='H3' || $tag=='H4' || $tag=='H5' || $tag=='H6' || $tag=='PRE'
+ || $tag=='FORM' || $tag=='ADDRESS' || $tag=='BLOCKQUOTE' || $tag=='CENTER' || $tag=='DT' || $tag=='DD' || $tag=='DL'
+ || $tag=='CAPTION' || $tag=='FIELDSET'
+ || $tag=='ARTICLE' || $tag=='ASIDE' || $tag=='FIGURE' || $tag=='FIGCAPTION' || $tag=='FOOTER' || $tag=='HEADER' || $tag=='HGROUP'
+ || $tag=='NAV' || $tag=='SECTION' || $tag=='DETAILS' || $tag=='SUMMARY'
+ ) { // mPDF 5.5.09 // mPDF 5.5.22
+
+ $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
+ $this->blockjustfinished=true;
+
+ $this->lastblockbottommargin = $this->blk[$this->blklvl]['margin_bottom'];
+/*-- LISTS --*/
+ if ($this->listlvl>0) { return; }
+/*-- END LISTS --*/
+
+ // mPDF 5.6.34
+ if (preg_match('/^H\d/',$tag) && !$this->tableLevel && !$this->writingToC) { // mPDF 5.6.38
+ if (isset($this->h2toc[$tag]) || isset($this->h2bookmarks[$tag])) {
+ $content = '';
+ if (count($this->textbuffer)==1) { $content = $this->textbuffer[0][0]; }
+ else {
+ for ($i=0;$itextbuffer);$i++) {
+ if (substr($this->textbuffer[$i][0],0,3) != "\xbb\xa4\xac") { //inline object
+ $content .= $this->textbuffer[$i][0];
+ }
+ }
+ }
+/*-- TOC --*/
+ if (isset($this->h2toc[$tag])) {
+ $objattr = array();
+ $objattr['type'] = 'toc';
+ $objattr['toclevel'] = $this->h2toc[$tag];
+ $objattr['CONTENT'] = htmlspecialchars($content); // mPDF 5.6.37
+ $e = "\xbb\xa4\xactype=toc,objattr=".serialize($objattr)."\xbb\xa4\xac";
+ array_unshift($this->textbuffer,array($e));
+ }
+/*-- END TOC --*/
+/*-- BOOKMARKS --*/
+ if (isset($this->h2bookmarks[$tag])) {
+ $objattr = array();
+ $objattr['type'] = 'bookmark';
+ $objattr['bklevel'] = $this->h2bookmarks[$tag];
+ $objattr['CONTENT'] = $content;
+ $e = "\xbb\xa4\xactype=toc,objattr=".serialize($objattr)."\xbb\xa4\xac";
+ array_unshift($this->textbuffer,array($e));
+ }
+/*-- END BOOKMARKS --*/
+ }
+ }
+
+/*-- TABLES --*/
+ if($this->tableLevel) {
+ if ($this->linebreakjustfinished) { $this->blockjustfinished=false; }
+ if (isset($this->InlineProperties['BLOCKINTABLE'])) {
+ if ($this->InlineProperties['BLOCKINTABLE']) { $this->restoreInlineProperties($this->InlineProperties['BLOCKINTABLE']); }
+ unset($this->InlineProperties['BLOCKINTABLE']);
+ }
+ if($tag=='PRE') { $this->ispre=false; }
+ return;
+ }
+/*-- END TABLES --*/
+ $this->lastoptionaltag = '';
+ $this->divbegin=false;
+
+ $this->linebreakjustfinished=false;
+
+ $this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
+
+/*-- CSS-FLOAT --*/
+ // If float contained in a float, need to extend bottom to allow for it
+ $currpos = $this->page*1000 + $this->y;
+ if (isset($this->blk[$this->blklvl]['float_endpos']) && $this->blk[$this->blklvl]['float_endpos'] > $currpos) {
+ $old_page = $this->page;
+ $new_page = intval($this->blk[$this->blklvl]['float_endpos'] /1000);
+ if ($old_page != $new_page) {
+ $s = $this->PrintPageBackgrounds();
+ // Writes after the marker so not overwritten later by page background etc.
+ $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+ $this->pageBackgrounds = array();
+ $this->page = $new_page;
+ $this->ResetMargins();
+ $this->Reset();
+ $this->pageoutput[$this->page] = array();
+ }
+ $this->y = (($this->blk[$this->blklvl]['float_endpos'] *1000) % 1000000)/1000; // mod changes operands to integers before processing
+ }
+/*-- END CSS-FLOAT --*/
+
+
+ //Print content
+ if ($this->lastblocklevelchange == 1) { $blockstate = 3; } // Top & bottom margins/padding
+ else if ($this->lastblocklevelchange == -1) { $blockstate = 2; } // Bottom margins/padding only
+ else { $blockstate = 0; }
+ // called from after e.g.
... Outputs block margin/border and padding
+ if (count($this->textbuffer) && $this->textbuffer[count($this->textbuffer)-1]) {
+ if (substr($this->textbuffer[count($this->textbuffer)-1][0],0,3) != "\xbb\xa4\xac") { // not special content
+ if ($this->usingCoreFont) {
+ $this->textbuffer[count($this->textbuffer)-1][0] = preg_replace('/[ ]+$/', '', $this->textbuffer[count($this->textbuffer)-1][0]);
+ }
+ else {
+ $this->textbuffer[count($this->textbuffer)-1][0] = preg_replace('/[ ]+$/u', '', $this->textbuffer[count($this->textbuffer)-1][0]); }
+ }
+ }
+
+ if (count($this->textbuffer) == 0 && $this->lastblocklevelchange != 0) {
+ //$this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,false,2,true, $this->blk[$this->blklvl]['direction']);
+ $this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,false,$blockstate,true, $this->blk[$this->blklvl]['direction']);
+ $this->finishFlowingBlock(true); // true = END of flowing block
+ $this->PaintDivBB('',$blockstate);
+ }
+ else {
+ $this->printbuffer($this->textbuffer,$blockstate);
+ }
+
+
+ $this->textbuffer=array();
+
+ if ($this->blk[$this->blklvl]['keep_block_together']) {
+ $this->printdivbuffer();
+ }
+
+ if ($this->kwt) {
+ $this->kwt_height = $this->y - $this->kwt_y0;
+ }
+
+/*-- CSS-IMAGE-FLOAT --*/
+ $this->printfloatbuffer();
+/*-- END CSS-IMAGE-FLOAT --*/
+
+ if($tag=='PRE') { $this->ispre=false; }
+
+/*-- CSS-FLOAT --*/
+ if ($this->blk[$this->blklvl]['float'] == 'R') {
+ // If width not set, here would need to adjust and output buffer
+ $s = $this->PrintPageBackgrounds();
+ // Writes after the marker so not overwritten later by page background etc.
+ $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+ $this->pageBackgrounds = array();
+ $this->Reset();
+ $this->pageoutput[$this->page] = array();
+
+ for($i=($this->blklvl-1); $i >= 0; $i--) {
+ if (isset($this->blk[$i]['float_endpos'])) { $this->blk[$i]['float_endpos'] = max($this->blk[$i]['float_endpos'], ($this->page*1000 + $this->y)); }
+ else { $this->blk[$i]['float_endpos'] = $this->page*1000 + $this->y; }
+ }
+
+ $this->floatDivs[] = array(
+ 'side'=>'R',
+ 'startpage'=>$this->blk[$this->blklvl]['startpage'] ,
+ 'y0'=>$this->blk[$this->blklvl]['float_start_y'] ,
+ 'startpos'=> ($this->blk[$this->blklvl]['startpage']*1000 + $this->blk[$this->blklvl]['float_start_y']),
+ 'endpage'=>$this->page ,
+ 'y1'=>$this->y ,
+ 'endpos'=> ($this->page*1000 + $this->y),
+ 'w'=> $this->blk[$this->blklvl]['float_width'],
+ 'blklvl'=>$this->blklvl,
+ 'blockContext' => $this->blk[$this->blklvl-1]['blockContext']
+ );
+
+ $this->y = $this->blk[$this->blklvl]['float_start_y'] ;
+ $this->page = $this->blk[$this->blklvl]['startpage'] ;
+ $this->ResetMargins();
+ $this->pageoutput[$this->page] = array();
+ }
+ if ($this->blk[$this->blklvl]['float'] == 'L') {
+ // If width not set, here would need to adjust and output buffer
+ $s = $this->PrintPageBackgrounds();
+ // Writes after the marker so not overwritten later by page background etc.
+ $this->pages[$this->page] = preg_replace('/(___BACKGROUND___PATTERNS'.date('jY').')/', '\\1'."\n".$s."\n", $this->pages[$this->page]);
+ $this->pageBackgrounds = array();
+ $this->Reset();
+ $this->pageoutput[$this->page] = array();
+
+ for($i=($this->blklvl-1); $i >= 0; $i--) {
+ if (isset($this->blk[$i]['float_endpos'])) { $this->blk[$i]['float_endpos'] = max($this->blk[$i]['float_endpos'], ($this->page*1000 + $this->y)); }
+ else { $this->blk[$i]['float_endpos'] = $this->page*1000 + $this->y; }
+ }
+
+ $this->floatDivs[] = array(
+ 'side'=>'L',
+ 'startpage'=>$this->blk[$this->blklvl]['startpage'] ,
+ 'y0'=>$this->blk[$this->blklvl]['float_start_y'] ,
+ 'startpos'=> ($this->blk[$this->blklvl]['startpage']*1000 + $this->blk[$this->blklvl]['float_start_y']),
+ 'endpage'=>$this->page ,
+ 'y1'=>$this->y ,
+ 'endpos'=> ($this->page*1000 + $this->y),
+ 'w'=> $this->blk[$this->blklvl]['float_width'],
+ 'blklvl'=>$this->blklvl,
+ 'blockContext' => $this->blk[$this->blklvl-1]['blockContext']
+ );
+
+ $this->y = $this->blk[$this->blklvl]['float_start_y'] ;
+ $this->page = $this->blk[$this->blklvl]['startpage'] ;
+ $this->ResetMargins();
+ $this->pageoutput[$this->page] = array();
+ }
+/*-- END CSS-FLOAT --*/
+
+ if (isset($this->blk[$this->blklvl]['visibility']) && $this->blk[$this->blklvl]['visibility']!='visible') {
+ $this->SetVisibility('visible');
+ }
+
+ if (isset($this->blk[$this->blklvl]['page_break_after'])) { $page_break_after = $this->blk[$this->blklvl]['page_break_after']; }
+ else { $page_break_after = ''; }
+
+ //Reset values
+ $this->Reset();
+
+ // mPDF 5.6.01 - LAYERS
+ if (isset($this->blk[$this->blklvl]['z-index']) && $this->blk[$this->blklvl]['z-index'] > 0) {
+ $this->EndLayer();
+ }
+
+ if ($this->blklvl > 0) { // ==0 SHOULDN'T HAPPEN - NOT XHTML
+ if ($this->blk[$this->blklvl]['tag'] == $tag) {
+ unset($this->blk[$this->blklvl]);
+ $this->blklvl--;
+ }
+ //else { echo $tag; exit; } // debug - forces error if incorrectly nested html tags
+ }
+
+ $this->lastblocklevelchange = -1 ;
+ // Reset Inline-type properties
+ if (isset($this->blk[$this->blklvl]['InlineProperties'])) { $this->restoreInlineProperties($this->blk[$this->blklvl]['InlineProperties']); }
+
+ $this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
+
+ if ($page_break_after) {
+ $save_blklvl = $this->blklvl;
+ $save_blk = $this->blk;
+ $save_silp = $this->saveInlineProperties();
+ $save_spanlvl = $this->spanlvl;
+ $save_ilp = $this->InlineProperties;
+ if ($this->blklvl>1) {
+ // Close any open block tags
+ for ($b= $this->blklvl;$b>0;$b--) { $this->CloseTag($this->blk[$b]['tag']); }
+ // Output any text left in buffer
+ if (count($this->textbuffer)) { $this->printbuffer($this->textbuffer); $this->textbuffer=array(); }
+ }
+/*-- COLUMNS --*/
+ $save_cols = false;
+ if ($this->ColActive) {
+ $save_cols = true;
+ $save_nbcol = $this->NbCol; // other values of gap and vAlign will not change by setting Columns off
+ $this->SetColumns(0);
+ }
+/*-- END COLUMNS --*/
+ if ($page_break_after == 'RIGHT') { $this->AddPage($this->CurOrientation,'NEXT-ODD','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+ else if ($page_break_after == 'LEFT') { $this->AddPage($this->CurOrientation,'NEXT-EVEN','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+ else { $this->AddPage($this->CurOrientation,'','','','','','', '','', '','','','','','',0,0,0,0,$pagesel); }
+ if (!$this->restoreBlockPagebreaks) {
+ $this->blklvl = 0;
+ $this->lastblocklevelchange = 0;
+ $this->blk = array();
+ $this->initialiseBlock($this->blk[0]);
+ $this->blk[0]['width'] =& $this->pgwidth;
+ $this->blk[0]['inner_width'] =& $this->pgwidth;
+ $this->blk[0]['blockContext'] = $this->blockContext;
+ $properties = $this->cssmgr->MergeCSS('BLOCK','BODY','');
+ $this->setCSS($properties,'','BODY');
+ $this->blklvl++;
+ $currblk =& $this->blk[$this->blklvl];
+ $prevblk =& $this->blk[$this->blklvl-1];
+
+ $this->initialiseBlock($currblk);
+ $currblk['tag'] = $tag;
+ $currblk['attr'] = $attr;
+
+ $this->Reset();
+ $properties = $this->cssmgr->MergeCSS('BLOCK',$tag,$attr);
+ }
+/*-- COLUMNS --*/
+ if ($save_cols) {
+ // Restore columns
+ $this->SetColumns($save_nbcol,$this->colvAlign,$this->ColGap);
+ }
+/*-- END COLUMNS --*/
+ if ($this->restoreBlockPagebreaks && !$this->tableLevel && !$this->listlvl) {
+ $this->blk = $save_blk;
+ // Re-open block tags
+ $t = $this->blk[0]['tag'];
+ $a = $this->blk[0]['attr'];
+ $this->blklvl = 0;
+ for ($b=0; $b<=$save_blklvl;$b++) {
+ $tc = $t;
+ $ac = $a;
+ $t = $this->blk[$b+1]['tag'];
+ $a = $this->blk[$b+1]['attr'];
+ unset($this->blk[$b+1]);
+ $this->OpenTag($tc,$ac);
+ }
+ $this->spanlvl = $save_spanlvl;
+ $this->InlineProperties = $save_ilp;
+ $this->restoreInlineProperties($save_silp);
+ }
+ }
+
+ }
+
+
+/*-- TABLES --*/
+
+ if($tag=='TH') $this->SetStyle('B',false);
+
+ if(($tag=='TH' or $tag=='TD') && $this->tableLevel) {
+ $this->lastoptionaltag = 'TR';
+ unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]);
+ $this->cssmgr->tbCSSlvl--;
+ if (!$this->tdbegin) { return; }
+ $this->tdbegin = false;
+ // Added for correct calculation of cell column width - otherwise misses the last line if not end etc.
+ if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
+ if (!is_array($this->cell[$this->row][$this->col])) { $this->Error("You may have an error in your HTML code e.g. </td></td>"); }
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+ elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
+ $this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
+ }
+
+ // Remove last
if at end of cell
+ if (isset($this->cell[$this->row][$this->col]['textbuffer'])) { $ntb = count($this->cell[$this->row][$this->col]['textbuffer']); }
+ else { $ntb = 0; }
+ if ($ntb>1 && $this->cell[$this->row][$this->col]['textbuffer'][$ntb-1][0] == "\n") {
+ unset($this->cell[$this->row][$this->col]['textbuffer'][$ntb-1]);
+ }
+
+ if ($this->cacheTables) {
+ $clen = $this->_cacheCell($this->cell[$this->row][$this->col], $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cache']);
+ $this->cell[$this->row][$this->col] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['ptr'];
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['ptr'] += $clen;
+ }
+
+ if ($this->tablethead) {
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead'][$this->row] = true;
+ if ($this->tableLevel==1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] = max($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] , ($this->row+1)); }
+ }
+ if ($this->tabletfoot) {
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$this->row] = true;
+ if ($this->tableLevel==1) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['footernrows'] = max($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['footernrows'] , ($this->row+1 - $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['headernrows'] )); }
+ }
+ $this->Reset();
+ }
+
+ if($tag=='TR' && $this->tableLevel) {
+ // If Border set on TR - Update right border
+ if (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-left'][$this->row])) {
+ if ($this->cacheTables) {
+ $c = $this->_uncacheCell($this->cell[$this->row][$this->col], $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cache'], null);
+ }
+ else { $c =& $this->cell[$this->row][$this->col]; }
+ if ($c) {
+ if ($this->packTableData) {
+ $cell = $this->_unpackCellBorder($c['borderbin'] );
+ }
+ else { $cell = $c; }
+ $cell['border_details']['R'] = $this->border_details($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-right'][$this->row]);
+ $this->setBorder($cell['border'], _BORDER_RIGHT, $cell['border_details']['R']['s']);
+ if ($this->packTableData) {
+ $c['borderbin'] = $this->_packCellBorder($cell);
+ unset($c['border']);
+ unset($c['border_details']);
+ }
+ else { $c = $cell; }
+ }
+ if ($this->cacheTables) {
+ $fh = fopen($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cache'], "r+b");
+ $this->_cacheUpdateBorder($c, $fh, $this->cell[$this->row][$this->col]);
+ fclose($fh);
+ }
+ }
+ $this->lastoptionaltag = '';
+ unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]);
+ $this->cssmgr->tbCSSlvl--;
+ $this->trow_text_rotate = '';
+ $this->tabletheadjustfinished = false;
+ }
+
+ if($tag=='TBODY') {
+ $this->lastoptionaltag = '';
+ unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]);
+ $this->cssmgr->tbCSSlvl--;
+ }
+
+ if($tag=='THEAD') {
+ $this->lastoptionaltag = '';
+ unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]);
+ $this->cssmgr->tbCSSlvl--;
+ $this->tablethead = 0;
+ $this->tabletheadjustfinished = true;
+ $this->ResetStyles();
+ $this->thead_font_weight = '';
+ $this->thead_font_style = '';
+ $this->thead_font_smCaps = '';
+
+ $this->thead_valign_default = '';
+ $this->thead_textalign_default = '';
+ }
+
+ if($tag=='TFOOT') {
+ $this->lastoptionaltag = '';
+ unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]);
+ $this->cssmgr->tbCSSlvl--;
+ $this->tabletfoot = 0;
+ $this->ResetStyles();
+ $this->tfoot_font_weight = '';
+ $this->tfoot_font_style = '';
+ $this->tfoot_font_smCaps = '';
+
+ $this->tfoot_valign_default = '';
+ $this->tfoot_textalign_default = '';
+ }
+
+ if($tag=='TABLE') { // TABLE-END (
+ if ($this->progressBar) { $this->UpdateProgressBar(1,'','TABLE'); } // *PROGRESS-BAR*
+ if ($this->progressBar) { $this->UpdateProgressBar(7,0,''); } // *PROGRESS-BAR*
+ $this->lastoptionaltag = '';
+ unset($this->cssmgr->tablecascadeCSS[$this->cssmgr->tbCSSlvl]);
+ $this->cssmgr->tbCSSlvl--;
+ $this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = $this->cell;
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['wc'] = array_pad(array(),$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nc'],array('miw'=>0,'maw'=>0));
+ $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['hr'] = array_pad(array(),$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nr'],0);
+
+ // Move table footer