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->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->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-ALIGN'])) { $css .= 'text-align: '.strtolower($p['TEXT-ALIGN']).'; '; }
if (isset($p['TEXT-SHADOW'])) { $css .= 'text-shadow: '.strtolower($p['TEXT-SHADOW']).'; '; } // mPDF 5.3.A4
if (isset($p['FONT-VARIANT'])) { $css .= 'font-variant: '.strtolower($p['FONT-VARIANT']).'; '; }
if (isset($p['COLOR'])) { $css .= 'color: '.strtolower($p['COLOR']).'; '; }
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'];
// mPDF 5.3.66
$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']; } // mPDF 5.3.A4
/*-- 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']; }
/*-- 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); } // mPDF 5.3.04
//================================================================
// 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] );
}
function _fix_borderStr($bd) {
$prop = preg_split('/\s+/',trim($bd));
$w = 'medium';
$c = '#000000';
$s = 'none';
if ( count($prop) == 1 ) {
// solid
if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; }
// #000000
else if (is_array($this->ConvertColor($prop[0]))) { $c = $prop[0]; }
// 1px
else { $w = $prop[0]; }
}
else if (count($prop) == 2 ) {
// 1px solid
if (in_array($prop[1],$this->borderstyles) || $prop[1] == 'none' || $prop[1] == 'hidden' ) { $w = $prop[0]; $s = $prop[1]; }
// solid #000000
else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) { $s = $prop[0]; $c = $prop[1]; }
// 1px #000000
else { $w = $prop[0]; $c = $prop[1]; }
}
else if ( count($prop) == 3 ) {
// Change #000000 1px solid to 1px solid #000000 (proper)
if (substr($prop[0],0,1) == '#') { $c = $prop[0]; $w = $prop[1]; $s = $prop[2]; }
// Change solid #000000 1px to 1px solid #000000 (proper)
else if (substr($prop[0],1,1) == '#') { $s = $prop[0]; $c = $prop[1]; $w = $prop[2]; }
// Change solid 1px #000000 to 1px solid #000000 (proper)
else if (in_array($prop[0],$this->borderstyles) || $prop[0] == 'none' || $prop[0] == 'hidden' ) {
$s = $prop[0]; $w = $prop[1]; $c = $prop[2];
}
else { $w = $prop[0]; $s = $prop[1]; $c = $prop[2]; }
}
else { return ''; }
$s = strtolower($s);
return $w.' '.$s.' '.$c;
}
// NEW FUNCTION FOR CSS MARGIN or PADDING called from SetCSS
function fixCSS($prop) {
if (!is_array($prop) || (count($prop)==0)) return array();
$newprop = array();
foreach($prop AS $k => $v) {
if ($k != 'BACKGROUND-IMAGE' && $k != 'BACKGROUND' && $k != 'ODD-HEADER-NAME' && $k != 'EVEN-HEADER-NAME' && $k != 'ODD-FOOTER-NAME' && $k != 'EVEN-FOOTER-NAME' && $k != 'HEADER' && $k != 'FOOTER') {
$v = strtolower($v);
}
if ($k == 'FONT') {
$s = trim($v);
preg_match_all('/\"(.*?)\"/',$s,$ff);
if (count($ff[1])) {
foreach($ff[1] AS $ffp) {
$w = preg_split('/\s+/',$ffp);
$s = preg_replace('/\"'.$ffp.'\"/',$w[0],$s);
}
}
preg_match_all('/\'(.*?)\'/',$s,$ff);
if (count($ff[1])) {
foreach($ff[1] AS $ffp) {
$w = preg_split('/\s+/',$ffp);
$s = preg_replace('/\''.$ffp.'\'/',$w[0],$s);
}
}
$s = preg_replace('/\s*,\s*/',',',$s);
$bits = preg_split('/\s+/',$s);
if (count($bits)>1) {
$k = 'FONT-FAMILY'; $v = $bits[(count($bits)-1)];
$fs = $bits[(count($bits)-2)];
if (preg_match('/(.*?)\/(.*)/',$fs, $fsp)) {
$newprop['FONT-SIZE'] = $fsp[1];
$newprop['LINE-HEIGHT'] = $fsp[2];
}
else { $newprop['FONT-SIZE'] = $fs; }
if (preg_match('/(italic|oblique)/i',$s)) { $newprop['FONT-STYLE'] = 'italic'; }
else { $newprop['FONT-STYLE'] = 'normal'; }
if (preg_match('/bold/i',$s)) { $newprop['FONT-WEIGHT'] = 'bold'; }
else { $newprop['FONT-WEIGHT'] = 'normal'; }
if (preg_match('/small-caps/i',$s)) { $newprop['TEXT-TRANSFORM'] = 'uppercase'; }
}
}
if ($k == 'FONT-FAMILY') {
$aux_fontlist = explode(",",$v);
$found = 0;
foreach($aux_fontlist AS $f) {
$fonttype = trim($f);
$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
$fonttype = preg_replace('/ /','',$fonttype);
$v = strtolower(trim($fonttype));
if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
if ((!$this->onlyCoreFonts && in_array($v,$this->available_unifonts)) ||
in_array($v,array('ccourier','ctimes','chelvetica')) || /* mPDF 5.3.21 & 22 */
($this->onlyCoreFonts && in_array($v,array('courier','times','helvetica','arial'))) ||
in_array($v, array('sjis','uhc','big5','gb'))) {
$newprop[$k] = $v;
$found = 1;
break;
}
}
if (!$found) {
foreach($aux_fontlist AS $f) {
$fonttype = trim($f);
$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
$fonttype = preg_replace('/ /','',$fonttype);
$v = strtolower(trim($fonttype));
if (isset($this->fonttrans[$v]) && $this->fonttrans[$v]) { $v = $this->fonttrans[$v]; }
if (in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) {
$newprop[$k] = $v;
break;
}
}
}
}
else if ($k == 'MARGIN') {
$tmp = $this->expand24($v);
$newprop['MARGIN-TOP'] = $tmp['T'];
$newprop['MARGIN-RIGHT'] = $tmp['R'];
$newprop['MARGIN-BOTTOM'] = $tmp['B'];
$newprop['MARGIN-LEFT'] = $tmp['L'];
}
/*-- BORDER-RADIUS --*/
else if ($k == 'BORDER-RADIUS' || $k == 'BORDER-TOP-LEFT-RADIUS' || $k == 'BORDER-TOP-RIGHT-RADIUS' || $k == 'BORDER-BOTTOM-LEFT-RADIUS' || $k == 'BORDER-BOTTOM-RIGHT-RADIUS') {
$tmp = $this->border_radius_expand($v,$k);
if (isset($tmp['TL-H'])) $newprop['BORDER-TOP-LEFT-RADIUS-H'] = $tmp['TL-H'];
if (isset($tmp['TL-V'])) $newprop['BORDER-TOP-LEFT-RADIUS-V'] = $tmp['TL-V'];
if (isset($tmp['TR-H'])) $newprop['BORDER-TOP-RIGHT-RADIUS-H'] = $tmp['TR-H'];
if (isset($tmp['TR-V'])) $newprop['BORDER-TOP-RIGHT-RADIUS-V'] = $tmp['TR-V'];
if (isset($tmp['BL-H'])) $newprop['BORDER-BOTTOM-LEFT-RADIUS-H'] = $tmp['BL-H'];
if (isset($tmp['BL-V'])) $newprop['BORDER-BOTTOM-LEFT-RADIUS-V'] = $tmp['BL-V'];
if (isset($tmp['BR-H'])) $newprop['BORDER-BOTTOM-RIGHT-RADIUS-H'] = $tmp['BR-H'];
if (isset($tmp['BR-V'])) $newprop['BORDER-BOTTOM-RIGHT-RADIUS-V'] = $tmp['BR-V'];
}
/*-- END BORDER-RADIUS --*/
else if ($k == 'PADDING') {
$tmp = $this->expand24($v);
$newprop['PADDING-TOP'] = $tmp['T'];
$newprop['PADDING-RIGHT'] = $tmp['R'];
$newprop['PADDING-BOTTOM'] = $tmp['B'];
$newprop['PADDING-LEFT'] = $tmp['L'];
}
else if ($k == 'BORDER') {
if ($v == '1') { $v = '1px solid #000000'; }
else { $v = $this->_fix_borderStr($v); }
$newprop['BORDER-TOP'] = $v;
$newprop['BORDER-RIGHT'] = $v;
$newprop['BORDER-BOTTOM'] = $v;
$newprop['BORDER-LEFT'] = $v;
}
else if ($k == 'BORDER-TOP') {
$newprop['BORDER-TOP'] = $this->_fix_borderStr($v);
}
else if ($k == 'BORDER-RIGHT') {
$newprop['BORDER-RIGHT'] = $this->_fix_borderStr($v);
}
else if ($k == 'BORDER-BOTTOM') {
$newprop['BORDER-BOTTOM'] = $this->_fix_borderStr($v);
}
else if ($k == 'BORDER-LEFT') {
$newprop['BORDER-LEFT'] = $this->_fix_borderStr($v);
}
else if ($k == 'BORDER-STYLE') {
$e = $this->expand24($v);
$newprop['BORDER-TOP-STYLE'] = $e['T'];
$newprop['BORDER-RIGHT-STYLE'] = $e['R'];
$newprop['BORDER-BOTTOM-STYLE'] = $e['B'];
$newprop['BORDER-LEFT-STYLE'] = $e['L'];
}
else if ($k == 'BORDER-WIDTH') {
$e = $this->expand24($v);
$newprop['BORDER-TOP-WIDTH'] = $e['T'];
$newprop['BORDER-RIGHT-WIDTH'] = $e['R'];
$newprop['BORDER-BOTTOM-WIDTH'] = $e['B'];
$newprop['BORDER-LEFT-WIDTH'] = $e['L'];
}
else if ($k == 'BORDER-COLOR') {
$e = $this->expand24($v);
$newprop['BORDER-TOP-COLOR'] = $e['T'];
$newprop['BORDER-RIGHT-COLOR'] = $e['R'];
$newprop['BORDER-BOTTOM-COLOR'] = $e['B'];
$newprop['BORDER-LEFT-COLOR'] = $e['L'];
}
else if ($k == 'BORDER-SPACING') {
$prop = preg_split('/\s+/',trim($v));
if (count($prop) == 1 ) {
$newprop['BORDER-SPACING-H'] = $prop[0];
$newprop['BORDER-SPACING-V'] = $prop[0];
}
else if (count($prop) == 2 ) {
$newprop['BORDER-SPACING-H'] = $prop[0];
$newprop['BORDER-SPACING-V'] = $prop[1];
}
}
else if ($k == 'SIZE') {
$prop = preg_split('/\s+/',trim($v));
if (preg_match('/(auto|portrait|landscape)/',$prop[0])) {
$newprop['SIZE'] = strtoupper($prop[0]);
}
else if (count($prop) == 1 ) {
$newprop['SIZE']['W'] = $this->ConvertSize($prop[0]);
$newprop['SIZE']['H'] = $this->ConvertSize($prop[0]);
}
else if (count($prop) == 2 ) {
$newprop['SIZE']['W'] = $this->ConvertSize($prop[0]);
$newprop['SIZE']['H'] = $this->ConvertSize($prop[1]);
}
}
else if ($k == 'SHEET-SIZE') {
$prop = preg_split('/\s+/',trim($v));
if (count($prop) == 2 ) {
$newprop['SHEET-SIZE'] = array($this->ConvertSize($prop[0]), $this->ConvertSize($prop[1]));
}
else {
if(preg_match('/([0-9a-zA-Z]*)-L/i',$v,$m)) { // e.g. A4-L = A$ landscape
$ft = $this->_getPageFormat($m[1]);
$format = array($ft[1],$ft[0]);
}
else { $format = $this->_getPageFormat($v); }
if ($format) { $newprop['SHEET-SIZE'] = array($format[0]/_MPDFK, $format[1]/_MPDFK); }
}
}
else if ($k == 'BACKGROUND') {
$bg = $this->parseCSSbackground($v);
if ($bg['c']) { $newprop['BACKGROUND-COLOR'] = $bg['c']; }
else { $newprop['BACKGROUND-COLOR'] = 'transparent'; }
/*-- BACKGROUNDS --*/
if ($bg['i']) {
$newprop['BACKGROUND-IMAGE'] = $bg['i'];
if ($bg['r']) { $newprop['BACKGROUND-REPEAT'] = $bg['r']; }
if ($bg['p']) { $newprop['BACKGROUND-POSITION'] = $bg['p']; }
}
else { $newprop['BACKGROUND-IMAGE'] = ''; }
/*-- END BACKGROUNDS --*/
}
/*-- BACKGROUNDS --*/
else if ($k == 'BACKGROUND-IMAGE') {
if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',$v,$m)) {
$newprop['BACKGROUND-IMAGE'] = $m[0];
continue;
}
if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) {
$newprop['BACKGROUND-IMAGE'] = $m[1];
}
else if (strtolower($v)=='none') { $newprop['BACKGROUND-IMAGE'] = ''; }
}
else if ($k == 'BACKGROUND-REPEAT') {
if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',$v,$m)) {
$newprop['BACKGROUND-REPEAT'] = strtolower($m[1]);
}
}
else if ($k == 'BACKGROUND-POSITION') {
$s = $v;
$bits = preg_split('/\s+/',trim($s));
// These should be Position x1 or x2
if (count($bits)==1) {
if (preg_match('/bottom/',$bits[0])) { $bg['p'] = '50% 100%'; }
else if (preg_match('/top/',$bits[0])) { $bg['p'] = '50% 0%'; }
else { $bg['p'] = $bits[0] . ' 50%'; }
}
else if (count($bits)==2) {
// Can be either right center or center right
if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
$bg['p'] = $bits[1] . ' '.$bits[0];
}
else {
$bg['p'] = $bits[0] . ' '.$bits[1];
}
}
if ($bg['p']) {
$bg['p'] = preg_replace('/(left|top)/','0%',$bg['p']);
$bg['p'] = preg_replace('/(right|bottom)/','100%',$bg['p']);
$bg['p'] = preg_replace('/(center)/','50%',$bg['p']);
if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',$bg['p'])) {
$bg['p'] = false;
}
}
if ($bg['p']) { $newprop['BACKGROUND-POSITION'] = $bg['p']; }
}
/*-- END BACKGROUNDS --*/
else if ($k == 'IMAGE-ORIENTATION') {
if (preg_match('/([\-]*[0-9\.]+)(deg|grad|rad)/i',$v,$m)) {
$angle = $m[1] + 0;
if (strtolower($m[2])=='deg') { $angle = $angle; }
else if (strtolower($m[2])=='grad') { $angle *= (360/400); }
else if (strtolower($m[2])=='rad') { $angle = rad2deg($angle); }
while($angle < 0) { $angle += 360; }
$angle = ($angle % 360);
$angle /= 90;
$angle = round($angle) * 90;
$newprop['IMAGE-ORIENTATION'] = $angle;
}
}
else {
$newprop[$k] = $v;
}
}
return $newprop;
}
// mPDF 5.3.A1
function setCSSboxshadow($v) {
$sh = array();
$c = preg_match_all('/(rgba|rgb|cmyka|cmyk|hsla|hsl)\(.*?\)/',$v,$x);
for($i=0; $i<$c; $i++) {
$col = preg_replace('/,/','*',$x[0][$i]);
$v = preg_replace('/'.preg_quote($x[0][$i],'/').'/',$col,$v);
}
$ss = explode(',',$v);
foreach ($ss AS $s) {
$new = array('inset'=>false, 'blur'=>0, 'spread'=>0);
if (preg_match('/inset/i',$s)) { $new['inset'] = true; $s = preg_replace('/\s*inset\s*/','',$s); }
$p = explode(' ',trim($s));
if (isset($p[0])) { $new['x'] = $this->ConvertSize(trim($p[0]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
if (isset($p[1])) { $new['y'] = $this->ConvertSize(trim($p[1]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
if (isset($p[2])) {
if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
$new['blur'] = $this->ConvertSize(trim($p[2]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
}
else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[2])); }
if (isset($p[3])) {
if (preg_match('/^\s*[\.\-0-9]/',$p[3])) {
$new['spread'] = $this->ConvertSize(trim($p[3]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
}
else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[3])); }
if (isset($p[4])) {
$new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[4]));
}
}
}
if (!$new['col']) { $new['col'] = $this->ConvertColor('#888888'); }
if (isset($new['y'])) { array_unshift($sh, $new); }
}
return $sh;
}
// mPDF 5.3.A2
function setCSStextshadow($v) {
$sh = array();
$c = preg_match_all('/(rgba|rgb|cmyka|cmyk|hsla|hsl)\(.*?\)/',$v,$x);
for($i=0; $i<$c; $i++) {
$col = preg_replace('/,/','*',$x[0][$i]);
$v = preg_replace('/'.preg_quote($x[0][$i],'/').'/',$col,$v);
}
$ss = explode(',',$v);
foreach ($ss AS $s) {
$new = array('blur'=>0);
$p = explode(' ',trim($s));
if (isset($p[0])) { $new['x'] = $this->ConvertSize(trim($p[0]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
if (isset($p[1])) { $new['y'] = $this->ConvertSize(trim($p[1]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false); }
if (isset($p[2])) {
if (preg_match('/^\s*[\.\-0-9]/',$p[2])) {
$new['blur'] = $this->ConvertSize(trim($p[2]),$this->blk[$this->blklvl-1]['inner_width'],$this->FontSize,false);
}
else { $new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[2])); }
if (isset($p[3])) {
$new['col'] = $this->ConvertColor(preg_replace('/\*/',',',$p[3]));
}
}
if (!$new['col']) { $new['col'] = $this->ConvertColor('#888888'); }
if (isset($new['y'])) { array_unshift($sh, $new); }
}
return $sh;
}
function parseCSSbackground($s) {
$bg = array('c'=>false, 'i'=>false, 'r'=>false, 'p'=>false, );
/*-- BACKGROUNDS --*/
if (preg_match('/(-moz-)*(repeating-)*(linear|radial)-gradient\(.*\)/i',$s,$m)) {
$bg['i'] = $m[0];
}
else
/*-- END BACKGROUNDS --*/
if (preg_match('/url\(/i',$s)) {
// If color, set and strip it off
if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|cmyka|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})\s+(url\(.*)/i',$s,$m)) { // mPDF 5.3.68
$bg['c'] = strtolower($m[1]);
$s = $m[3]; // mPDF 5.3.74
}
/*-- BACKGROUNDS --*/
if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',$s,$m)) {
$bg['i'] = $m[1];
$s = strtolower($m[2]);
if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/',$s,$m)) {
$bg['r'] = $m[1];
}
// Remove repeat, attachment (discarded) and also any inherit
$s = preg_replace('/(repeat-x|repeat-y|no-repeat|repeat|scroll|fixed|inherit)/','',$s);
$bits = preg_split('/\s+/',trim($s));
// These should be Position x1 or x2
if (count($bits)==1) {
if (preg_match('/bottom/',$bits[0])) { $bg['p'] = '50% 100%'; }
else if (preg_match('/top/',$bits[0])) { $bg['p'] = '50% 0%'; }
else { $bg['p'] = $bits[0] . ' 50%'; }
}
else if (count($bits)==2) {
// Can be either right center or center right
if (preg_match('/(top|bottom)/',$bits[0]) || preg_match('/(left|right)/',$bits[1])) {
$bg['p'] = $bits[1] . ' '.$bits[0];
}
else {
$bg['p'] = $bits[0] . ' '.$bits[1];
}
}
if ($bg['p']) {
$bg['p'] = preg_replace('/(left|top)/','0%',$bg['p']);
$bg['p'] = preg_replace('/(right|bottom)/','100%',$bg['p']);
$bg['p'] = preg_replace('/(center)/','50%',$bg['p']);
if (!preg_match('/[\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)* [\-]{0,1}\d+(in|cm|mm|pt|pc|em|ex|px|%)*/',$bg['p'])) {
$bg['p'] = false;
}
}
}
/*-- END BACKGROUNDS --*/
}
else if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|(rgba|rgb|cmyka|cmyk|hsla|hsl|spot)\(.*?\)|[a-zA-Z]{3,})/i',$s,$m)) { $bg['c'] = strtolower($m[1]); } // mPDF 5.3.68
return ($bg);
}
function expand24($mp) {
$prop = preg_split('/\s+/',trim($mp));
if (count($prop) == 1 ) {
return array('T' => $prop[0], 'R' => $prop[0], 'B' => $prop[0], 'L'=> $prop[0]);
}
if (count($prop) == 2 ) {
return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[0], 'L'=> $prop[1]);
}
if (count($prop) == 3 ) {
return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[1]);
}
if (count($prop) == 4 ) {
return array('T' => $prop[0], 'R' => $prop[1], 'B' => $prop[2], 'L'=> $prop[3]);
}
return array();
}
/*-- BORDER-RADIUS --*/
function border_radius_expand($val,$k) {
$b = array();
if ($k == 'BORDER-RADIUS') {
$hv = explode('/',trim($val));
$prop = preg_split('/\s+/',trim($hv[0]));
if (count($prop)==1) {
$b['TL-H'] = $b['TR-H'] = $b['BR-H'] = $b['BL-H'] = $prop[0];
}
else if (count($prop)==2) {
$b['TL-H'] = $b['BR-H'] = $prop[0];
$b['TR-H'] = $b['BL-H'] = $prop[1];
}
else if (count($prop)==3) {
$b['TL-H'] = $prop[0];
$b['TR-H'] = $b['BL-H'] = $prop[1];
$b['BR-H'] = $prop[2];
}
else if (count($prop)==4) {
$b['TL-H'] = $prop[0];
$b['TR-H'] = $prop[1];
$b['BR-H'] = $prop[2];
$b['BL-H'] = $prop[3];
}
if (count($hv)==2) {
$prop = preg_split('/\s+/',trim($hv[1]));
if (count($prop)==1) {
$b['TL-V'] = $b['TR-V'] = $b['BR-V'] = $b['BL-V'] = $prop[0];
}
else if (count($prop)==2) {
$b['TL-V'] = $b['BR-V'] = $prop[0];
$b['TR-V'] = $b['BL-V'] = $prop[1];
}
else if (count($prop)==3) {
$b['TL-V'] = $prop[0];
$b['TR-V'] = $b['BL-V'] = $prop[1];
$b['BR-V'] = $prop[2];
}
else if (count($prop)==4) {
$b['TL-V'] = $prop[0];
$b['TR-V'] = $prop[1];
$b['BR-V'] = $prop[2];
$b['BL-V'] = $prop[3];
}
}
else {
$b['TL-V'] = $b['TL-H'];
$b['TR-V'] = $b['TR-H'];
$b['BL-V'] = $b['BL-H'];
$b['BR-V'] = $b['BR-H'];
}
return $b;
}
// Parse 2
$h = 0;
$v = 0;
$prop = preg_split('/\s+/',trim($val));
if (count($prop)==1) { $h = $v = $val; }
else { $h = $prop[0]; $v = $prop[1]; }
if ($h==0 || $v==0) { $h = $v = 0; }
if ($k == 'BORDER-TOP-LEFT-RADIUS') {
$b['TL-H'] = $h;
$b['TL-V'] = $v;
}
else if ($k == 'BORDER-TOP-RIGHT-RADIUS') {
$b['TR-H'] = $h;
$b['TR-V'] = $v;
}
else if ($k == 'BORDER-BOTTOM-LEFT-RADIUS') {
$b['BL-H'] = $h;
$b['BL-V'] = $v;
}
else if ($k == 'BORDER-BOTTOM-RIGHT-RADIUS') {
$b['BR-H'] = $h;
$b['BR-V'] = $v;
}
return $b;
}
/*-- END BORDER-RADIUS --*/
/*-- 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 --*/
/*-- TABLES --*/
function setBorderDominance($prop, $val) {
if (isset($prop['BORDER-LEFT']) && $prop['BORDER-LEFT']) { $this->cell_border_dominance_L = $val; }
if (isset($prop['BORDER-RIGHT']) && $prop['BORDER-RIGHT']) { $this->cell_border_dominance_R = $val; }
if (isset($prop['BORDER-TOP']) && $prop['BORDER-TOP']) { $this->cell_border_dominance_T = $val; }
if (isset($prop['BORDER-BOTTOM']) && $prop['BORDER-BOTTOM']) { $this->cell_border_dominance_B = $val; }
}
/*-- END TABLES --*/
/*-- HTML-CSS --*/
function _mergeCSS($p, &$t) { // mPDF 5.3.82 $p changed to &$p
// Save Cascading CSS e.g. "div.topic p" at this block level
if (isset($p) && $p) {
if ($t) {
$t = $this->array_merge_recursive_unique($t, $p); // mPDF 5.3.96
}
else { $t = $p; }
}
}
// for CSS handling
function array_merge_recursive_unique($array1, $array2) {
$arrays = func_get_args();
$narrays = count($arrays);
$ret = $arrays[0];
for ($i = 1; $i < $narrays; $i ++) {
foreach ($arrays[$i] as $key => $value) {
if (((string) $key) === ((string) intval($key))) { // integer or string as integer key - append
$ret[] = $value;
}
else { // string key - merge
if (is_array($value) && isset($ret[$key])) {
$ret[$key] = $this->array_merge_recursive_unique($ret[$key], $value);
}
else {
$ret[$key] = $value;
}
}
}
}
return $ret;
}
function _mergeFullCSS($p, &$t, $tag, $classes, $id) { // mPDF 5.3.82 $p changed to &$p
$this->_mergeCSS($p[$tag], $t);
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
$this->_mergeCSS($p['CLASS>>'.$class], $t);
}
// STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd) td:nth-child(2n+1)
// mPDF 5.3.82
if ($tag=='TR' && isset($p) && $p) {
foreach($p AS $k=>$val) {
if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
$select = false;
if ($tag=='TR') {
$row = $this->row; // mPDF 5.3.84
$thnr = (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead']) ? count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead']) : 0);
$tfnr = (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) ? count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) : 0);
if ($this->tabletfoot) { $row -= $thnr; }
else if (!$this->tablethead) { $row -= ($thnr + $tfnr); }
if ($m[1]=='ODD' && ($row % 2) == 0) { $select = true; }
else if ($m[1]=='EVEN' && ($row % 2) == 1) { $select = true; }
else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) {
if ((($row + 1) % $a[1]) == $a[2]) { $select = true; }
}
}
else if ($tag=='TD' || $tag=='TH') {
if ($m[1]=='ODD' && ($this->col % 2) == 0) { $select = true; }
else if ($m[1]=='EVEN' && ($this->col % 2) == 1) { $select = true; }
else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) {
if ((($this->col + 1) % $a[1]) == $a[2]) { $select = true; }
}
}
if ($select) {
$this->_mergeCSS($p[$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $t);
}
}
}
}
// STYLESHEET CLASS e.g. #smallone{} #redletter{}
if (isset($id) && $id) {
$this->_mergeCSS($p['ID>>'.$id], $t);
}
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
$this->_mergeCSS($p[$tag.'>>CLASS>>'.$class], $t);
}
// STYLESHEET CLASS e.g. #smallone{} #redletter{}
if (isset($id)) {
$this->_mergeCSS($p[$tag.'>>ID>>'.$id], $t);
}
}
function _set_mergedCSS(&$m, &$p, $d=true, $bd=false) {
if (isset($m)) {
if ((isset($m['depth']) && $m['depth']>1) || $d==false) { // include check for 'depth'
if ($bd) { $this->setBorderDominance($m, $bd); } // *TABLES*
if (is_array($m)) {
$p = array_merge($p,$m);
$this->_mergeBorders($p,$m);
}
}
}
}
function _mergeBorders(&$b, &$a) { // Merges $a['BORDER-TOP-STYLE'] to $b['BORDER-TOP'] etc.
foreach(array('TOP','RIGHT','BOTTOM','LEFT') AS $side) {
foreach(array('STYLE','WIDTH','COLOR') AS $el) {
if (isset($a['BORDER-'.$side.'-'.$el])) { // e.g. $b['BORDER-TOP-STYLE']
$s = trim($a['BORDER-'.$side.'-'.$el]);
if (isset($b['BORDER-'.$side])) { // e.g. $b['BORDER-TOP']
$p = trim($b['BORDER-'.$side]);
}
else { $p = ''; }
if ($el=='STYLE') {
if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 '.$s.' \\3', $p); }
else { $b['BORDER-'.$side] = '0px '.$s.' #000000'; }
}
else if ($el=='WIDTH') {
if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', $s.' \\2 \\3', $p); }
else { $b['BORDER-'.$side] = $s.' none #000000'; }
}
else if ($el=='COLOR') {
if ($p) { $b['BORDER-'.$side] = preg_replace('/(\S+)\s+(\S+)\s+(\S+)/', '\\1 \\2 '.$s, $p); }
else { $b['BORDER-'.$side] = '0px none '.$s; }
}
}
}
}
}
function MergeCSS($inherit,$tag,$attr) {
$p = array();
$zp = array();
$classes = array();
if (isset($attr['CLASS'])) {
$classes = preg_split('/\s+/',$attr['CLASS']);
}
if (!isset($attr['ID'])) { $attr['ID']=''; }
//===============================================
/*-- TABLES --*/
// Set Inherited properties
if ($inherit == 'TOPTABLE') { // $tag = TABLE
//===============================================
// Save Cascading CSS e.g. "div.topic p" at this block level
if (isset($this->blk[$this->blklvl]['cascadeCSS'])) {
$this->tablecascadeCSS[0] = $this->blk[$this->blklvl]['cascadeCSS'];
}
else {
$this->tablecascadeCSS[0] = $this->cascadeCSS;
}
}
//===============================================
// Set Inherited properties
if ($inherit == 'TOPTABLE' || $inherit == 'TABLE') {
//Cascade everything from last level that is not an actual property, or defined by current tag/attributes
if (isset($this->tablecascadeCSS[$this->tbCSSlvl-1]) && is_array($this->tablecascadeCSS[$this->tbCSSlvl-1])) {
foreach($this->tablecascadeCSS[$this->tbCSSlvl-1] AS $k=>$v) {
$this->tablecascadeCSS[$this->tbCSSlvl][$k] = $v;
}
}
$this->_mergeFullCSS($this->cascadeCSS, $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
//===============================================
// Cascading forward CSS e.g. "table.topic td" for this table in $this->tablecascadeCSS
//===============================================
// STYLESHEET TAG e.g. table
$this->_mergeFullCSS($this->tablecascadeCSS[$this->tbCSSlvl-1], $this->tablecascadeCSS[$this->tbCSSlvl], $tag, $classes, $attr['ID']);
//===============================================
}
/*-- END TABLES --*/
//===============================================
/*-- LISTS --*/
// Set Inherited properties
if ($inherit == 'TOPLIST') { // $tag = UL,OL
//===============================================
// Save Cascading CSS e.g. "div.topic p" at this block level
if (isset($this->blk[$this->blklvl]['cascadeCSS'])) {
$this->listcascadeCSS[0] = $this->blk[$this->blklvl]['cascadeCSS'];
}
else {
$this->listcascadeCSS[0] = $this->cascadeCSS;
}
}
//===============================================
// Set Inherited properties
if ($inherit == 'TOPLIST' || $inherit == 'LIST') {
//Cascade everything from last level that is not an actual property, or defined by current tag/attributes
if (isset($this->listcascadeCSS[$this->listCSSlvl-1]) && is_array($this->listcascadeCSS[$this->listCSSlvl-1])) {
foreach($this->listcascadeCSS[$this->listCSSlvl-1] AS $k=>$v) {
$this->listcascadeCSS[$this->listCSSlvl][$k] = $v;
}
}
$this->_mergeFullCSS($this->cascadeCSS, $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
//===============================================
// Cascading forward CSS e.g. "table.topic td" for this list in $this->listcascadeCSS
//===============================================
// STYLESHEET TAG e.g. table
$this->_mergeFullCSS($this->listcascadeCSS[$this->listCSSlvl-1], $this->listcascadeCSS[$this->listCSSlvl], $tag, $classes, $attr['ID']);
//===============================================
}
/*-- END LISTS --*/
//===============================================
// Set Inherited properties
if ($inherit == 'BLOCK') {
if (isset($this->blk[$this->blklvl-1]['cascadeCSS']) && is_array($this->blk[$this->blklvl-1]['cascadeCSS'])) {
foreach($this->blk[$this->blklvl-1]['cascadeCSS'] AS $k=>$v) {
$this->blk[$this->blklvl]['cascadeCSS'][$k] = $v;
}
}
//===============================================
// Save Cascading CSS e.g. "div.topic p" at this block level
$this->_mergeFullCSS($this->cascadeCSS, $this->blk[$this->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID']);
//===============================================
// Cascading forward CSS
//===============================================
$this->_mergeFullCSS($this->blk[$this->blklvl-1]['cascadeCSS'], $this->blk[$this->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID']);
//===============================================
// Block properties
if (isset($this->blk[$this->blklvl-1]['margin_collapse']) && $this->blk[$this->blklvl-1]['margin_collapse']) { $p['MARGIN-COLLAPSE'] = 'COLLAPSE'; } // custom tag, but follows CSS principle that border-collapse is inherited
if (isset($this->blk[$this->blklvl-1]['line_height']) && $this->blk[$this->blklvl-1]['line_height']) { $p['LINE-HEIGHT'] = $this->blk[$this->blklvl-1]['line_height']; }
if (isset($this->blk[$this->blklvl-1]['direction']) && $this->blk[$this->blklvl-1]['direction']) { $p['DIRECTION'] = $this->blk[$this->blklvl-1]['direction']; }
if (isset($this->blk[$this->blklvl-1]['align']) && $this->blk[$this->blklvl-1]['align']) {
if ($this->blk[$this->blklvl-1]['align'] == 'L') { $p['TEXT-ALIGN'] = 'left'; }
else if ($this->blk[$this->blklvl-1]['align'] == 'J') { $p['TEXT-ALIGN'] = 'justify'; }
else if ($this->blk[$this->blklvl-1]['align'] == 'R') { $p['TEXT-ALIGN'] = 'right'; }
else if ($this->blk[$this->blklvl-1]['align'] == 'C') { $p['TEXT-ALIGN'] = 'center'; }
}
if ($this->ColActive || $this->keep_block_together) {
if (isset($this->blk[$this->blklvl-1]['bgcolor']) && $this->blk[$this->blklvl-1]['bgcolor']) { // Doesn't officially inherit, but default value is transparent (?=inherited)
$cor = $this->blk[$this->blklvl-1]['bgcolorarray' ];
$p['BACKGROUND-COLOR'] = $this->_colAtoString($cor);
}
}
if (isset($this->blk[$this->blklvl-1]['text_indent']) && ($this->blk[$this->blklvl-1]['text_indent'] || $this->blk[$this->blklvl-1]['text_indent']===0)) { $p['TEXT-INDENT'] = $this->blk[$this->blklvl-1]['text_indent']; }
if (isset($this->blk[$this->blklvl-1]['InlineProperties'])) {
$biilp = $this->blk[$this->blklvl-1]['InlineProperties'];
}
else { $biilp = null; }
if (isset($biilp[ 'family' ]) && $biilp[ 'family' ]) { $p['FONT-FAMILY'] = $biilp[ 'family' ]; }
if (isset($biilp[ 'I' ]) && $biilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
if (isset($biilp[ 'sizePt' ]) && $biilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $biilp[ 'sizePt' ] . 'pt'; }
if (isset($biilp[ 'B' ]) && $biilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
if (isset($biilp[ 'colorarray' ]) && $biilp[ 'colorarray' ]) {
$cor = $biilp[ 'colorarray' ];
$p['COLOR'] = $this->_colAtoString($cor);
}
if (isset($biilp[ 'fontkerning' ])) {
if ($biilp[ 'fontkerning' ]) { $p['FONT-KERNING'] = 'normal'; }
else { $p['FONT-KERNING'] = 'none'; }
}
if (isset($biilp[ 'lSpacingCSS' ]) && $biilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $biilp[ 'lSpacingCSS' ]; }
if (isset($biilp[ 'wSpacingCSS' ]) && $biilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $biilp[ 'wSpacingCSS' ]; }
if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
else if (isset($biilp[ 'capitalize' ]) && $biilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; }
// CSS says text-decoration is not inherited, but IE7 does??
if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
if (isset($biilp[ 'smCaps' ]) && $biilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; }
}
//===============================================
//===============================================
/*-- LISTS --*/
// Set Inherited properties
if ($inherit == 'TOPLIST') {
if ($this->listCSSlvl == 1) {
$bilp = $this->blk[$this->blklvl]['InlineProperties'];
if (isset($bilp[ 'family' ]) && $bilp[ 'family' ]) { $p['FONT-FAMILY'] = $bilp[ 'family' ]; }
if (isset($bilp[ 'I' ]) && $bilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
if (isset($bilp[ 'sizePt' ]) && $bilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $bilp[ 'sizePt' ] . 'pt'; }
if (isset($bilp[ 'B' ]) && $bilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
if (isset($bilp[ 'colorarray' ]) && $bilp[ 'colorarray' ]) {
$cor = $bilp[ 'colorarray' ];
$p['COLOR'] = $this->_colAtoString($cor);
}
if (isset($bilp[ 'toupper' ]) && $bilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
else if (isset($bilp[ 'tolower' ]) && $bilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
else if (isset($bilp[ 'capitalize' ]) && $bilp[ 'capitalize' ]) { $p['TEXT-TRANSFORM'] = 'capitalize'; }
if (isset($bilp[ 'fontkerning' ])) {
if ($bilp[ 'fontkerning' ]) { $p['FONT-KERNING'] = 'normal'; }
else { $p['FONT-KERNING'] = 'none'; }
}
if (isset($bilp[ 'lSpacingCSS' ]) && $bilp[ 'lSpacingCSS' ]) { $p['LETTER-SPACING'] = $bilp[ 'lSpacingCSS' ]; }
if (isset($bilp[ 'wSpacingCSS' ]) && $bilp[ 'wSpacingCSS' ]) { $p['WORD-SPACING'] = $bilp[ 'wSpacingCSS' ]; }
// CSS says text-decoration is not inherited, but IE7 does??
if (isset($bilp[ 'underline' ]) && $bilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
if (isset($bilp[ 'smCaps' ]) && $bilp[ 'smCaps' ]) { $p['FONT-VARIANT'] = 'small-caps'; }
if ($tag=='LI') { // mPDF 5.3.99
// Note to self - this should never work, as TOPLIST is not called when LI (see code removed in v5.3)
$this->Error("If you see this message, please report this as a bug to the mPDF Forum.");
}
}
}
/*-- END LISTS --*/
//===============================================
//===============================================
// DEFAULT for this TAG set in DefaultCSS
if (isset($this->defaultCSS[$tag])) {
$zp = $this->fixCSS($this->defaultCSS[$tag]);
if (is_array($zp)) { // Default overwrites Inherited
$p = array_merge($p,$zp); // !! Note other way round !!
$this->_mergeBorders($p,$zp);
}
}
//===============================================
/*-- TABLES --*/
// cellPadding overwrites TD/TH default but not specific CSS set on cell
if (($tag=='TD' || $tag=='TH') && isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']) && ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'] || $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']===0)) {
$p['PADDING-LEFT'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
$p['PADDING-RIGHT'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
$p['PADDING-TOP'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
$p['PADDING-BOTTOM'] = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'];
}
/*-- END TABLES --*/
//===============================================
// STYLESHEET TAG e.g. h1 p div table
if (isset($this->CSS[$tag]) && $this->CSS[$tag]) {
$zp = $this->CSS[$tag];
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
//===============================================
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
$zp = array();
if (isset($this->CSS['CLASS>>'.$class]) && $this->CSS['CLASS>>'.$class]) { $zp = $this->CSS['CLASS>>'.$class]; }
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
//===============================================
/*-- TABLES --*/
// mPDF 5.3.82
// STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd) td:nth-child(2n+1)
if ($tag=='TR' || $tag=='TD' || $tag=='TH') {
foreach($this->CSS AS $k=>$val) {
if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
$select = false;
if ($tag=='TR') {
$row = $this->row; // mPDF 5.3.84
$thnr = (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead']) ? count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead']) : 0);
$tfnr = (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) ? count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) : 0);
if ($this->tabletfoot) { $row -= $thnr; }
else if (!$this->tablethead) { $row -= ($thnr + $tfnr); }
if ($m[1]=='ODD' && ($row % 2) == 0) { $select = true; }
else if ($m[1]=='EVEN' && ($row % 2) == 1) { $select = true; }
else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) {
if ((($row + 1) % $a[1]) == $a[2]) { $select = true; }
}
}
else if ($tag=='TD' || $tag=='TH') {
if ($m[1]=='ODD' && ($this->col % 2) == 0) { $select = true; }
else if ($m[1]=='EVEN' && ($this->col % 2) == 1) { $select = true; }
else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) {
if ((($this->col+1) % $a[1]) == $a[2]) { $select = true; }
}
}
if ($select) {
$zp = $this->CSS[$tag.'>>SELECTORNTHCHILD>>'.$m[1]];
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); }
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
}
}
}
/*-- END TABLES --*/
//===============================================
// STYLESHEET ID e.g. #smallone{} #redletter{}
if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']]) && $this->CSS['ID>>'.$attr['ID']]) {
$zp = $this->CSS['ID>>'.$attr['ID']];
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
//===============================================
// STYLESHEET CLASS e.g. p.smallone{} div.redletter{}
foreach($classes AS $class) {
$zp = array();
if (isset($this->CSS[$tag.'>>CLASS>>'.$class]) && $this->CSS[$tag.'>>CLASS>>'.$class]) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
//===============================================
// STYLESHEET CLASS e.g. p#smallone{} div#redletter{}
if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']]) && $this->CSS[$tag.'>>ID>>'.$attr['ID']]) {
$zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']];
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
//===============================================
// Cascaded e.g. div.class p only works for block level
if ($inherit == 'BLOCK') {
$this->_set_mergedCSS($this->blk[$this->blklvl-1]['cascadeCSS'][$tag], $p);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->blk[$this->blklvl-1]['cascadeCSS']['CLASS>>'.$class], $p);
}
$this->_set_mergedCSS($this->blk[$this->blklvl-1]['cascadeCSS']['ID>>'.$attr['ID']], $p);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->blk[$this->blklvl-1]['cascadeCSS'][$tag.'>>CLASS>>'.$class], $p);
}
$this->_set_mergedCSS($this->blk[$this->blklvl-1]['cascadeCSS'][$tag.'>>ID>>'.$attr['ID']], $p);
}
else if ($inherit == 'INLINE') {
$this->_set_mergedCSS($this->blk[$this->blklvl]['cascadeCSS'][$tag], $p);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->blk[$this->blklvl]['cascadeCSS']['CLASS>>'.$class], $p);
}
$this->_set_mergedCSS($this->blk[$this->blklvl]['cascadeCSS']['ID>>'.$attr['ID']], $p);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->blk[$this->blklvl]['cascadeCSS'][$tag.'>>CLASS>>'.$class], $p);
}
$this->_set_mergedCSS($this->blk[$this->blklvl]['cascadeCSS'][$tag.'>>ID>>'.$attr['ID']], $p);
}
/*-- TABLES --*/
else if ($inherit == 'TOPTABLE' || $inherit == 'TABLE') { // NB looks at $this->tablecascadeCSS-1 for cascading CSS
// false, 9 = don't check for 'depth' and do set border dominance
$this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag], $p, false, 9);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1]['CLASS>>'.$class], $p, false, 9);
}
// STYLESHEET nth-child SELECTOR e.g. tr:nth-child(odd) td:nth-child(2n+1)
// mPDF 5.3.82
if ($tag=='TR' || $tag=='TD' || $tag=='TH') {
foreach($this->tablecascadeCSS[$this->tbCSSlvl-1] AS $k=>$val) {
if (preg_match('/'.$tag.'>>SELECTORNTHCHILD>>(.*)/',$k, $m)) {
$select = false;
if ($tag=='TR') {
$row = $this->row; // mPDF 5.3.84
$thnr = (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead']) ? count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead']) : 0);
$tfnr = (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) ? count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) : 0);
if ($this->tabletfoot) { $row -= $thnr; }
else if (!$this->tablethead) { $row -= ($thnr + $tfnr); }
if ($m[1]=='ODD' && ($row % 2) == 0) { $select = true; }
else if ($m[1]=='EVEN' && ($row % 2) == 1) { $select = true; }
else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) {
if ((($row + 1) % $a[1]) == $a[2]) { $select = true; }
}
}
else if ($tag=='TD' || $tag=='TH') {
if ($m[1]=='ODD' && ($this->col % 2) == 0) { $select = true; }
else if ($m[1]=='EVEN' && ($this->col % 2) == 1) { $select = true; }
else if (preg_match('/(\d+)N\+(\d+)/',$m[1],$a)) {
if ((($this->col + 1) % $a[1]) == $a[2]) { $select = true; }
}
}
if ($select) {
$this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>SELECTORNTHCHILD>>'.$m[1]], $p, false, 9);
}
}
}
}
$this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1]['ID>>'.$attr['ID']], $p, false, 9);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>CLASS>>'.$class], $p, false, 9);
}
$this->_set_mergedCSS($this->tablecascadeCSS[$this->tbCSSlvl-1][$tag.'>>ID>>'.$attr['ID']], $p, false, 9);
}
/*-- END TABLES --*/
//===============================================
/*-- LISTS --*/
else if ($inherit == 'TOPLIST' || $inherit == 'LIST') { // NB looks at $this->listcascadeCSS-1 for cascading CSS
// false = don't check for 'depth'
$this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag], $p, false);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['CLASS>>'.$class], $p, false);
}
$this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1]['ID>>'.$attr['ID']], $p, false);
foreach($classes AS $class) {
$this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag.'>>CLASS>>'.$class], $p, false);
}
$this->_set_mergedCSS($this->listcascadeCSS[$this->listCSSlvl-1][$tag.'>>ID>>'.$attr['ID']], $p, false);
}
/*-- END LISTS --*/
//===============================================
//===============================================
// INLINE STYLE e.g. style="CSS:property"
if (isset($attr['STYLE'])) {
$zp = $this->readInlineCSS($attr['STYLE']);
if ($tag=='TD' || $tag=='TH') { $this->setBorderDominance($zp, 9); } // *TABLES* // *TABLES-ADVANCED-BORDERS*
if (is_array($zp)) {
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp);
}
}
//===============================================
//===============================================
// INLINE ATTRIBUTES e.g. .. ALIGN="CENTER">
if (isset($attr['LANG']) and $attr['LANG']!='') {
$p['LANG'] = $attr['LANG'];
}
if (isset($attr['COLOR']) and $attr['COLOR']!='') {
$p['COLOR'] = $attr['COLOR'];
}
if ($tag != 'INPUT') {
if (isset($attr['WIDTH']) and $attr['WIDTH']!='') {
$p['WIDTH'] = $attr['WIDTH'];
}
if (isset($attr['HEIGHT']) and $attr['HEIGHT']!='') {
$p['HEIGHT'] = $attr['HEIGHT'];
}
}
if ($tag == 'FONT') {
if (isset($attr['FACE'])) {
$p['FONT-FAMILY'] = $attr['FACE'];
}
if (isset($attr['SIZE']) and $attr['SIZE']!='') {
$s = '';
if ($attr['SIZE'] === '+1') { $s = '120%'; }
else if ($attr['SIZE'] === '-1') { $s = '86%'; }
else if ($attr['SIZE'] === '1') { $s = 'XX-SMALL'; }
else if ($attr['SIZE'] == '2') { $s = 'X-SMALL'; }
else if ($attr['SIZE'] == '3') { $s = 'SMALL'; }
else if ($attr['SIZE'] == '4') { $s = 'MEDIUM'; }
else if ($attr['SIZE'] == '5') { $s = 'LARGE'; }
else if ($attr['SIZE'] == '6') { $s = 'X-LARGE'; }
else if ($attr['SIZE'] == '7') { $s = 'XX-LARGE'; }
if ($s) $p['FONT-SIZE'] = $s;
}
}
if (isset($attr['VALIGN']) and $attr['VALIGN']!='') {
$p['VERTICAL-ALIGN'] = $attr['VALIGN'];
}
if (isset($attr['VSPACE']) and $attr['VSPACE']!='') {
$p['MARGIN-TOP'] = $attr['VSPACE'];
$p['MARGIN-BOTTOM'] = $attr['VSPACE'];
}
if (isset($attr['HSPACE']) and $attr['HSPACE']!='') {
$p['MARGIN-LEFT'] = $attr['HSPACE'];
$p['MARGIN-RIGHT'] = $attr['HSPACE'];
}
//===============================================
return $p;
}
/*-- 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->CSS['@PAGE'])) { $zp = $this->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->CSS['@PAGE>>PSEUDO>>RIGHT']) && $side=='R') {
$zp = $this->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->CSS['@PAGE>>PSEUDO>>LEFT']) && $side=='L') {
$zp = $this->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->CSS['@PAGE>>PSEUDO>>FIRST']) && $first) { $zp = $this->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->CSS['@PAGE>>NAMED>>'.$name])) { $zp = $this->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->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>RIGHT']) && $side=='R') { $zp = $this->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->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>LEFT']) && $side=='L') { $zp = $this->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->CSS['@PAGE>>NAMED>>'.$name.'>>PSEUDO>>FIRST']) && $first) { $zp = $this->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']; } // mPDF 5.3.12
/*-- 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 --*/
function PreviewBlockCSS($tag,$attr) {
// Looks ahead from current block level to a new level
$p = array();
$zp = array();
$oldcascadeCSS = $this->blk[$this->blklvl]['cascadeCSS'];
$classes = array();
if (isset($attr['CLASS'])) { $classes = preg_split('/\s+/',$attr['CLASS']); }
//===============================================
// DEFAULT for this TAG set in DefaultCSS
if (isset($this->defaultCSS[$tag])) {
$zp = $this->fixCSS($this->defaultCSS[$tag]);
if (is_array($zp)) { $p = array_merge($zp,$p); } // Inherited overwrites default
}
// STYLESHEET TAG e.g. h1 p div table
if (isset($this->CSS[$tag])) {
$zp = $this->CSS[$tag];
if (is_array($zp)) { $p = array_merge($p,$zp); }
}
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
$zp = array();
if (isset($this->CSS['CLASS>>'.$class])) { $zp = $this->CSS['CLASS>>'.$class]; }
if (is_array($zp)) { $p = array_merge($p,$zp); }
}
// STYLESHEET ID e.g. #smallone{} #redletter{}
if (isset($attr['ID']) && isset($this->CSS['ID>>'.$attr['ID']])) {
$zp = $this->CSS['ID>>'.$attr['ID']];
if (is_array($zp)) { $p = array_merge($p,$zp); }
}
// STYLESHEET CLASS e.g. p.smallone{} div.redletter{}
foreach($classes AS $class) {
$zp = array();
if (isset($this->CSS[$tag.'>>CLASS>>'.$class])) { $zp = $this->CSS[$tag.'>>CLASS>>'.$class]; }
if (is_array($zp)) { $p = array_merge($p,$zp); }
}
// STYLESHEET CLASS e.g. p#smallone{} div#redletter{}
if (isset($attr['ID']) && isset($this->CSS[$tag.'>>ID>>'.$attr['ID']])) {
$zp = $this->CSS[$tag.'>>ID>>'.$attr['ID']];
if (is_array($zp)) { $p = array_merge($p,$zp); }
}
//===============================================
// STYLESHEET TAG e.g. div h1 div p
$this->_set_mergedCSS($oldcascadeCSS[$tag], $p);
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
$this->_set_mergedCSS($oldcascadeCSS['CLASS>>'.$class], $p);
}
// STYLESHEET CLASS e.g. #smallone{} #redletter{}
if (isset($attr['ID'])) {
$this->_set_mergedCSS($oldcascadeCSS['ID>>'.$attr['ID']], $p);
}
// STYLESHEET CLASS e.g. div.smallone{} p.redletter{}
foreach($classes AS $class) {
$this->_set_mergedCSS($oldcascadeCSS[$tag.'>>CLASS>>'.$class], $p);
}
// STYLESHEET CLASS e.g. div#smallone{} p#redletter{}
if (isset($attr['ID'])) {
$this->_set_mergedCSS($oldcascadeCSS[$tag.'>>ID>>'.$attr['ID']], $p);
}
//===============================================
// INLINE STYLE e.g. style="CSS:property"
if (isset($attr['STYLE'])) {
$zp = $this->readInlineCSS($attr['STYLE']);
if (is_array($zp)) { $p = array_merge($p,$zp); }
}
//===============================================
return $p;
}
/*-- 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;
$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); // mPDF 5.3.99
}
else {
/*-- END TABLES --*/
$this->_saveTextBuffer($e); // mPDF 5.3.99
} // *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->readInlineCSS($attr['HEADER-STYLE']); }
else { $properties = $this->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') { // mPDF 5.3.86
$p['L']['font-style'] = 'B';
$p['C']['font-style'] = 'B';
$p['R']['font-style'] = 'B';
}
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='italic') { // mPDF 5.3.86
$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->readInlineCSS($attr['HEADER-STYLE-LEFT']); }
else { $properties = $this->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'; } // mPDF 5.3.86
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='italic') { $p['L']['font-style'] .='I'; } // mPDF 5.3.86
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->readInlineCSS($attr['HEADER-STYLE-CENTER']); }
else { $properties = $this->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'; } // mPDF 5.3.86
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='italic') { $p['C']['font-style'] .= 'I'; } // mPDF 5.3.86
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->readInlineCSS($attr['HEADER-STYLE-RIGHT']); }
else { $properties = $this->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'; } // mPDF 5.3.86
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='italic') { $p['R']['font-style'] .= 'I'; } // mPDF 5.3.86
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 '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 {
$this->InlineProperties[$tag] = $this->saveInlineProperties();
if (isset($annot)) { $this->InlineAnnots[$tag] = $annot; } // *ANNOTATIONS*
}
$properties = $this->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']); // mPDF 5.3.99 // *TABLES*
} // *TABLES*
else { // *TABLES*
$this->_saveTextBuffer($e, '', $attr['NAME']); // mPDF 5.3.99 //an internal link (adds a space for recognition)
} // *TABLES*
}
if (isset($attr['HREF'])) {
$this->InlineProperties['A'] = $this->saveInlineProperties();
$properties = $this->MergeCSS('',$tag,$attr);
if (!empty($properties)) $this->setCSS($properties,'INLINE');
$this->HREF=htmlspecialchars_decode(urldecode($attr['HREF'])); // mPDF 5.3.95
}
break;
case 'BR':
// Added mPDF 3.0 Float DIV - CLEAR
if (isset($attr['STYLE'])) {
$properties = $this->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"); // mPDF 5.3.99
}
$this->_saveCellTextBuffer("\n"); // mPDF 5.3.99
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"); // mPDF 5.3.99
} // *TABLES*
$this->ignorefollowingspaces = true;
$this->blockjustfinished=false;
$this->listjustfinished=false;
$this->linebreakjustfinished=true;
break;
// *********** BLOCKS ********************
//NB $outerblocktags = array('DIV','FORM','CENTER','DL');
//NB $innerblocktags = array('P','BLOCKQUOTE','ADDRESS','PRE',''H1','H2','H3','H4','H5','H6','DT','DD');
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': // mPDF 5.3.56
case 'P':
case 'H1':
case 'H2':
case 'H3':
case 'H4':
case 'H5':
case 'H6':
case 'DL':
case 'DT':
case 'DD':
$p = $this->PreviewBlockCSS($tag,$attr);
if(isset($p['DISPLAY']) && strtolower($p['DISPLAY'])=='none') {
$this->blklvl++;
$this->blk[$this->blklvl]['hide'] = true;
return;
}
// mPDF 5.3.56
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']); } // mPDF 5.3.A8
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"); // mPDF 5.3.99
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->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();
// mPDF 5.3.03
$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->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
// mPDF 5.3.03
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->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->MergeCSS('BLOCK',$tag,$attr);
}
/*-- COLUMNS --*/
if ($save_cols) {
// Restore columns
$this->SetColumns($save_nbcol,$this->colvAlign,$this->ColGap);
}
/*-- END COLUMNS --*/
// mPDF 5.3.03
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();
}
// mPDF 5.3.76
if ($lastbottommargin && isset($properties['MARGIN-TOP']) && $properties['MARGIN-TOP'] && empty($properties['FLOAT'])) { $currblk['lastbottommargin'] = $lastbottommargin; }
$this->setCSS($properties,'BLOCK',$tag); //name(id/class/style) found in the CSS array!
$currblk['InlineProperties'] = $this->saveInlineProperties();
// mPDF 5.3.42 VISIBILITY
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))) { // mPDF 5.3.04
// 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))) { // mPDF 5.3.04
$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))) { // mPDF 5.3.04
$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))) { // mPDF 5.3.04
// 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))) { // mPDF 5.3.04
$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))) { // mPDF 5.3.04
$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))) { // mPDF 5.3.04
// 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))) { // mPDF 5.3.04
$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))) { // mPDF 5.3.04
$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); // mPDF 5.3.04
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->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->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']); }
if (isset($properties['TEXT-ALIGN'])) { $objattr['align'] = $align[strtolower($properties['TEXT-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']); }
if (isset($properties['HEIGHT'])) { $objattr['linewidth'] = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
if(isset($attr['WIDTH']) && $attr['WIDTH'] != '') $objattr['width'] = $this->ConvertSize($attr['WIDTH'],$this->blk[$this->blklvl]['inner_width']);
if(isset($attr['ALIGN']) && $attr['ALIGN'] != '') $objattr['align'] = $align[strtolower($attr['ALIGN'])];
if(isset($attr['COLOR']) && $attr['COLOR'] != '') $objattr['color'] = $this->ConvertColor($attr['COLOR']);
/*-- 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); // mPDF 5.3.99
}
else {
/*-- END TABLES --*/
$this->_saveTextBuffer($e, $this->HREF); // mPDF 5.3.99
} // *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->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); // mPDF 5.3.99
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
}
else {
/*-- END TABLES --*/
$this->_saveTextBuffer($e, $this->HREF); // mPDF 5.3.99
} // *TABLES*
}
break;
/*-- END BARCODES --*/
// *********** FORM ELEMENTS ********************
/*-- FORMS --*/
case 'SELECT':
$this->lastoptionaltag = ''; // Save current HTML specified optional endtag
$this->InlineProperties[$tag] = $this->saveInlineProperties();
$properties = $this->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;
}
// mPDF 5.3.46
if(isset($attr['VALUE'])) {
$attr['VALUE'] = strcode2utf($attr['VALUE']);
$attr['VALUE'] = $this->lesser_entity_decode($attr['VALUE']); // mPDF 5.3.58
if ($this->onlyCoreFonts)
$attr['VALUE'] = mb_convert_encoding($attr['VALUE'], $this->mb_enc,'UTF-8');
// mPDF 5.3.58
}
$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;
// mPDF 5.3.25
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']; } // mPDF 5.3.37
}
$this->InlineProperties[$tag] = $this->saveInlineProperties();
$properties = $this->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($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['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); // mPDF 5.3.04
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']; }
// mPDF 5.3.46
else $objattr['title'] = '';
$objattr['title'] = strcode2utf($objattr['title']);
$objattr['title'] = $this->lesser_entity_decode($objattr['title']); // mPDF 5.3.58
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']; }
}
// mPDF 5.3.46
if(isset($attr['VALUE'])) {
$attr['VALUE'] = strcode2utf($attr['VALUE']);
$attr['VALUE'] = $this->lesser_entity_decode($attr['VALUE']); // mPDF 5.3.58
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->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); // mPDF 5.3.04
$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; }
// mPDF 5.3.46
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) {
// mPDF 5.3.25
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']; } // mPDF 5.3.37
}
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); // mPDF 5.3.99
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
}
else {
/*-- END TABLES --*/
$this->_saveTextBuffer($e, $this->HREF); // mPDF 5.3.99
} // *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->MergeCSS('',$tag,$attr);
if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
return;
}
// mPDF 5.3.42 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;
}
}
// 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);
if(isset($properties['HEIGHT'])) $h = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
if(isset($attr['WIDTH'])) $w = $this->ConvertSize($attr['WIDTH'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
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) { // mPDF 5.3.78
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']);
// 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); // mPDF 5.3.99
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
}
else {
/*-- END TABLES --*/
$this->_saveTextBuffer($e, $this->HREF); // mPDF 5.3.99
} // *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 ********************
// mPDF 5.3.A5
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->MergeCSS('',$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;
}
}
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;
$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'; }
}
// 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) { // mPDF 5.3.78
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
$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->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]];
// mPDF 5.3.79
// 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;
$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; // mPDF 5.3.62
$table['footernrows'] = 0; // mPDF 5.3.62
$this->base_table_properties = array();
}
// ADDED CSS FUNCIONS FOR TABLE
if ($this->tbCSSlvl==1) {
$properties = $this->MergeCSS('TOPTABLE',$tag,$attr);
}
else {
$properties = $this->MergeCSS('TABLE',$tag,$attr);
}
$w = '';
if (isset($properties['WIDTH'])) { $w = $properties['WIDTH']; }
if(isset($properties['DIRECTION']) && $properties['DIRECTION']) { $table['direction'] = strtolower($properties['DIRECTION']); }
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']; }
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($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'] = $properties['FONT-FAMILY'];
}
if (isset($properties['FONT-SIZE'])) {
$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'] = $properties['FONT-SIZE'];
}
}
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 (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;
}
// mPDF 5.3.55
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']); } // mPDF 5.3.36
}
$properties = array();
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($attr['CELLPADDING'])) {
$table['cell_padding'] = $attr['CELLPADDING'];
}
else {
$table['cell_padding'] = false;
}
if (isset($attr['BORDER'])) {
$this->table_border_attr_set = 1;
if ($attr['BORDER']=='1') {
$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 (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($attr['BGCOLOR'])) { $table['bgcolor'][-1] = $attr['BGCOLOR']; }
if (isset($attr['WIDTH']) && $attr['WIDTH']) { $w = $attr['WIDTH']; }
if ($w) { // set here or earlier in $properties
$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); // mPDF 5.3.76
break;
case 'THEAD':
$this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
$this->tbCSSlvl++;
$this->tablethead = 1;
$this->tabletfoot = 0;
$properties = $this->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->tbCSSlvl++;
$this->tabletfoot = 1;
$this->tablethead = 0;
$properties = $this->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->tbCSSlvl++;
$this->MergeCSS('TABLE',$tag,$attr);
break;
case 'TR':
$this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
$this->tbCSSlvl++;
$this->row++;
$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['nr']++;
$this->col = -1;
$properties = $this->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']; }
/*-- 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 (isset($attr['BGCOLOR'])) $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['bgcolor'][$this->row] = $attr['BGCOLOR'];
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;
// mPDF 5.3.75
case 'TH':
case 'TD':
$this->ignorefollowingspaces = true;
$this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
$this->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]];
// mPDF 5.3.77
$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); } // mPDF 5.3.76
}
// 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->MergeCSS('TABLE',$tag,$attr);
$properties = $this->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 = '';
}
if (isset($properties['BACKGROUND-COLOR'])) { $c['bgcolor'] = $properties['BACKGROUND-COLOR']; }
else if (isset($properties['BACKGROUND'])) { $c['bgcolor'] = $properties['BACKGROUND']; }
/*-- 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'])]; }
if (isset($properties['TEXT-ALIGN'])) { $c['a'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
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;
}
}
// mPDF 5.3.15
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'];
}
// mPDF 5.3.78
// 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']; }
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); } // mPDF 5.3.57
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); }
}
// mPDF 5.3.34
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); }
}
// mPDF 5.3.A2
if (isset($properties['TEXT-SHADOW'])) {
$ts = $this->setCSStextshadow($properties['TEXT-SHADOW']);
if ($ts) { $this->textshadow = $ts; }
}
// mPDF 5.3.80
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['HEIGHT']) && !strpos($attr['HEIGHT'],'%')) $c['h'] = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); // mPDF 5.3.57
if (isset($attr['ALIGN'])) $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($attr['VALIGN'])) $c['va'] = $align[strtolower($attr['VALIGN'])];
if (isset($attr['BGCOLOR'])) $c['bgcolor'] = $attr['BGCOLOR'];
if (isset($attr['TEXT-ROTATE'])) {
$c['R'] = $attr['TEXT-ROTATE'];
}
if (isset($attr['NOWRAP']) && $attr['NOWRAP']) $c['nowrap']= 1;
// mPDF 5.3.77
$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;
} // mPDF 5.3.79 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); // mPDF 5.3.76
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->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++;
$this->listnum = 0; // reset
$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->listCSSlvl==1) {
$properties = $this->MergeCSS('TOPLIST',$tag,$attr);
}
else {
$properties = $this->MergeCSS('LIST',$tag,$attr);
}
if (!empty($properties)) $this->setCSS($properties,'LIST'); // mPDF 5.3.65
// List-type
$this->listtype = '';
if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listtype = $attr['TYPE']; }
else 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']);
}
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
$this->listnum = 0; // reset
$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++;
$this->listnum = 0; // reset
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']); }
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"); // mPDF 5.3.99
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); // mPDF 5.3.99
$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) { // mPDF 5.3.11
$this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
$this->listnum++;
}
else { // mPDF 5.3.10
$this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype, true);
}
}
$this->textbuffer = array();
}
$this->listjustfinished = false; // mPDF 5.3.11
$this->listCSSlvl++;
$properties = $this->MergeCSS('LIST',$tag,$attr);
if (!empty($properties)) $this->setCSS($properties,'LIST'); // mPDF 5.3.98
$this->InlineProperties['LISTITEM'][$this->listlvl][$this->listoccur[$this->listlvl]][$this->listnum] = $this->saveInlineProperties();
// List-type
if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listitemtype = $attr['TYPE']; }
else 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 $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') {
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=='A') {
$this->HREF='';
if (isset($this->InlineProperties['A'])) { $this->restoreInlineProperties($this->InlineProperties['A']); }
unset($this->InlineProperties['A']);
}
/*-- 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); // mPDF 5.3.99
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ; // *TABLES*
} // *TABLES*
else { // *TABLES*
$this->_saveTextBuffer($e, $this->HREF); // mPDF 5.3.99
} // *TABLES*
$this->selectoption = array();
$this->specialcontent = '';
if ($this->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
unset($this->InlineProperties[$tag]);
}
/*-- END FORMS --*/
// *********** BLOCKS ********************
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' ) {
// mPDF 5.3.56
$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 --*/
/*-- 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']); // mPDF 5.3.29
$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 --*/
// mPDF 5.3.42 VISIBILITY
if (isset($this->blk[$this->blklvl]['visibility']) && $this->blk[$this->blklvl]['visibility']!='visible') {
$this->SetVisibility('visible');
}
// mPDF 5.3.03
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();
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'];
// mPDF 5.3.03
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->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->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->tablecascadeCSS[$this->tbCSSlvl]);
$this->tbCSSlvl--;
if (!$this->tdbegin) { return; } // mPDF 5.3.79
$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]);
}
// mPDF 5.3.79
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;
}
// mPDF 5.3.62
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) {
// mPDF 5.3.78
// If Border set on TR - Update right border
if (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['trborder-left'][$this->row])) {
// mPDF 5.3.79
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; }
}
// mPDF 5.3.79
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->tablecascadeCSS[$this->tbCSSlvl]);
$this->tbCSSlvl--;
$this->trow_text_rotate = '';
$this->tabletheadjustfinished = false;
}
if($tag=='TBODY') {
$this->lastoptionaltag = '';
unset($this->tablecascadeCSS[$this->tbCSSlvl]);
$this->tbCSSlvl--;
}
if($tag=='THEAD') {
$this->lastoptionaltag = '';
unset($this->tablecascadeCSS[$this->tbCSSlvl]);
$this->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->tablecascadeCSS[$this->tbCSSlvl]);
$this->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->tablecascadeCSS[$this->tbCSSlvl]);
$this->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