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['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['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'];
if (isset($p['BACKGROUND-COLOR'])) { $pb['BACKGROUND-COLOR'] = $p['BACKGROUND-COLOR']; }
if (isset($p['BACKGROUND-IMAGE'])) { $pb['BACKGROUND-IMAGE'] = $p['BACKGROUND-IMAGE']; } // *BACKGROUND-IMAGES*
// mPDF 4.3.015
if (isset($p['BACKGROUND-IMAGE-RESIZE'])) { $pb['BACKGROUND-IMAGE-RESIZE'] = $p['BACKGROUND-IMAGE-RESIZE']; } // *BACKGROUND-IMAGES*
// mPDF 4.3.017
if (isset($p['BACKGROUND-IMAGE-OPACITY'])) { $pb['BACKGROUND-IMAGE-OPACITY'] = $p['BACKGROUND-IMAGE-OPACITY']; } // *BACKGROUND-IMAGES*
if (isset($p['BACKGROUND-REPEAT'])) { $pb['BACKGROUND-REPEAT'] = $p['BACKGROUND-REPEAT']; } // *BACKGROUND-IMAGES*
if (isset($p['BACKGROUND-POSITION'])) { $pb['BACKGROUND-POSITION'] = $p['BACKGROUND-POSITION']; } // *BACKGROUND-IMAGES*
if (isset($p['BACKGROUND-GRADIENT'])) { $pb['BACKGROUND-GRADIENT'] = $p['BACKGROUND-GRADIENT']; } // *GRADIENTS*
$this->setCSS($pb,'BLOCK',$tag);
//================================================================
$bbox_dir = $p['DIR'];
$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'; }
//================================================================
// mPDF 4.2
if ($checkinnerhtml=='' && $inner_h==='auto') { $inner_h = 0.0001; }
if ($checkinnerhtml=='' && $inner_w==='auto') { $inner_w = $this->GetStringWidth('WW'); }
//================================================================
// Algorithm from CSS2.1 See http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height
if ($bbox_top==='auto' && $inner_h==='auto' && $bbox_bottom==='auto') {
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'
}
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;
}
}
//================================================================
//================================================================
/*-- BACKGROUND-IMAGES --*/
if (isset($pb['BACKGROUND-IMAGE']) && $pb['BACKGROUND-IMAGE']) { // mPDF 4.3.011
$file = $pb['BACKGROUND-IMAGE'];
$sizesarray = $this->Image($file,0,0,0,0,'','',false, false, false, false, false); // mPDF 4.3.012D
if (isset($sizesarray['IMAGE_ID'])) {
$image_id = $sizesarray['IMAGE_ID'];
$orig_w = $sizesarray['WIDTH']*$this->k; // in user units i.e. mm
$orig_h = $sizesarray['HEIGHT']*$this->k; // (using $this->img_dpi)
$x_repeat = true;
$y_repeat = true;
if (isset($pb['BACKGROUND-REPEAT'])) {
if ($pb['BACKGROUND-REPEAT']=='no-repeat' || $pb['BACKGROUND-REPEAT']=='repeat-x') { $y_repeat = false; }
if ($pb['BACKGROUND-REPEAT']=='no-repeat' || $pb['BACKGROUND-REPEAT']=='repeat-y') { $x_repeat = false; }
}
$x_pos = 0;
$y_pos = 0;
if (isset($pb['BACKGROUND-POSITION'])) {
$ppos = preg_split('/\s+/',$pb['BACKGROUND-POSITION']);
$x_pos = $ppos[0];
$y_pos = $ppos[1];
if (!stristr($x_pos ,'%') ) { $x_pos = $this->ConvertSize($x_pos ,$this->blk[1]['inner_width'],$this->FontSize); }
if (!stristr($y_pos ,'%') ) { $y_pos = $this->ConvertSize($y_pos ,$this->blk[1]['inner_width'],$this->FontSize); }
}
// mPDF 4.3.015
if (isset($pb['BACKGROUND-IMAGE-RESIZE'])) { $resize = $pb['BACKGROUND-IMAGE-RESIZE']; }
else { $resize = 0; }
// mPDF 4.3.017
if (isset($pb['BACKGROUND-IMAGE-OPACITY'])) { $opacity = $pb['BACKGROUND-IMAGE-OPACITY']; }
else { $opacity = 1; }
$this->blk[1]['background-image'] = array('image_id'=>$image_id, 'orig_w'=>$orig_w, 'orig_h'=>$orig_h, 'x_pos'=>$x_pos, 'y_pos'=>$y_pos, 'x_repeat'=>$x_repeat, 'y_repeat'=>$y_repeat, 'resize'=>$resize, 'opacity'=>$opacity); // mPDF 4.3.015 4.3.017
}
}
/*-- END BACKGROUND-IMAGES --*/
//================================================================
$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->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->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_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->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); // *PROGRESS-BAR*
$bpcctr = 1; // *PROGRESS-BAR*
while(($ratio / $target ) > 1) {
/*-- PROGRESS-BAR --*/
if ($this->progressBar) { $this->UpdateProgressBar(4,intval(100/($ratio/$target)),('Auto-sizing fixed-position block: '.$bpcctr++)); }
/*-- END PROGRESS-BAR --*/
$this->x = $x;
$this->y = $y;
// mPDF 4.2
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->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 (!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->PaintDivBB('',0,1); // Prints borders and sets backgrounds in $this->pageBackgrounds
}
$s = $this->PrintPageBackgrounds();
$this->pages[$this->page] = preg_replace('/___BEFORE_BORDERS___/', "\n".$s."\n", $this->pages[$this->page]);
$this->pageBackgrounds = array();
// 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*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$ch*$this->k,$op));
if (!empty($block_s)) {
$tmp = "q\n".sprintf('%.3f %.3f %.3f %.3f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$ch*$this->k,$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");
}
// Page Links
foreach($this->HTMLheaderPageLinks AS $lk) {
if ($shrink_f != 1) { // i.e. autofit has resized the box
$lx1 = (($lk[0]/$this->k)-$x);
$lx2 = $x + ($lx1 * $shrink_f);
$lk[0] = $lx2*$this->k;
$ly1 = (($this->h-($lk[1]/$this->k))-$y);
$ly2 = $y + ($ly1 * $shrink_f);
$lk[1] = ($this->h-$ly2)*$this->k;
$lk[2] *= $shrink_f; // width
$lk[3] *= $shrink_f; // height
}
$this->PageLinks[$this->page][]=$lk;
}
// Restore
$this->headerbuffer = '';
$this->HTMLheaderPageLinks = array();
$this->pageBackgrounds = $save_bgs;
$this->writingHTMLheader = false;
// mPDF 4.0
$this->writingHTMLfooter = false;
// mPDF 4.1
$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 --*/
// mPDF 4.0
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;
}
// mPDF 4.0
function border_details($bd) {
$prop = preg_split('/\s+/',trim($bd));
// mPDF 4.0
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' => array('R'=>0,'G'=>0,'B'=>0), 'style'=>'solid');
}
else { return array('w' => 0, 's' => 0); } // mPDF 3.0
}
// mPDF 4.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] );
}
// mPDF 4.0
function _fix_borderStr($bd) {
$prop = preg_split('/\s+/',trim($bd));
$w = 'medium'; // mPDF 4.3.010
$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) {
// mPDF 4.2.013 Change all CSS properties to lowercase, except those that are case sensitive
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);
}
// mPDF 4.0 - FONT shorthand
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);
$fonttype = trim($aux_fontlist[0]);
// mPDF 4.0
$fonttype = preg_replace('/["\']*(.*?)["\']*/','\\1',$fonttype);
$aux_fontlist = explode(" ",$fonttype);
$fonttype = $aux_fontlist[0];
$v = strtolower(trim($fonttype));
if (($this->is_MB && in_array($v,$this->available_unifonts)) ||
(!$this->is_MB && in_array($v,$this->available_fonts)) || in_array($v, array('sjis','uhc','big5','gb')) ||
in_array($v,$this->sans_fonts) || in_array($v,$this->serif_fonts) || in_array($v,$this->mono_fonts) ) {
$newprop[$k] = $v;
}
}
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'];
}
// mPDF 4.0
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);
}
// mPDF 4.0
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]);
}
}
// mPDF 4.2.024
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]/$this->k, $format[1]/$this->k); }
}
}
// mPDF 3.0 - Tiling Patterns
else if ($k == 'BACKGROUND') {
$bg = $this->parseCSSbackground($v);
if ($bg['c']) { $newprop['BACKGROUND-COLOR'] = $bg['c']; }
// mPDF 4.3.002
else { $newprop['BACKGROUND-COLOR'] = 'transparent'; } // mPDF 4.3.002
/*-- BACKGROUND-IMAGES --*/
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'] = ''; } // mPDF 4.3.002 / 4.3.011
/*-- END BACKGROUND-IMAGES --*/
}
/*-- BACKGROUND-IMAGES --*/
else if ($k == 'BACKGROUND-IMAGE') {
if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)/i',$v,$m)) { // 4.2.013
$newprop['BACKGROUND-IMAGE'] = $m[1];
}
// mPDF 4.3.011
else if (strtolower($v)=='none') { $newprop['BACKGROUND-IMAGE'] = ''; }
}
// mPDF 3.0 - Tiling Patterns
else if ($k == 'BACKGROUND-REPEAT') {
if (preg_match('/(repeat-x|repeat-y|no-repeat|repeat)/i',$v,$m)) {
$newprop['BACKGROUND-REPEAT'] = strtolower($m[1]);
}
}
// mPDF 3.0 - Tiling Patterns
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 BACKGROUND-IMAGES --*/
else {
$newprop[$k] = $v;
}
}
// mPDF 4.0
// $this->_mergeBorders($newprop,$newprop);
return $newprop;
}
// mPDF 3.0 - Tiling Patterns
function parseCSSbackground($s) {
// $s = strtolower($s); // mPDF 4.2.013
$bg = array('c'=>false, 'i'=>false, 'r'=>false, 'p'=>false, );
if (preg_match('/url\(/i',$s)) { // mPDF 4.2.013
// If color, set and strip it off
if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|rgb\(.*?\)|[a-zA-Z]{3,})\s+(url\(.*)/i',$s,$m)) { // mPDF 4.2.013
$bg['c'] = strtolower($m[1]); // mPDF 4.2.013
$s = $m[2];
}
/*-- BACKGROUND-IMAGES --*/
if (preg_match('/url\([\'\"]{0,1}(.*?)[\'\"]{0,1}\)\s*(.*)/i',$s,$m)) { // mPDF 4.2.013
$bg['i'] = $m[1];
$s = strtolower($m[2]); // mPDF 4.2.013
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 BACKGROUND-IMAGES --*/
}
else if (preg_match('/^\s*(#[0-9a-fA-F]{3,6}|rgb\(.*?\)|[a-zA-Z]{3,})/i',$s,$m)) { $bg['c'] = strtolower($m[1]); } // mPDF 4.2.013
return ($bg);
}
/*-- GRADIENTS --*/
// mPDF 3.0 Gradients
function parseBackgroundGradient($bg) {
// background-gradient: linear #00FFFF #FFFF00 0 0.5 1 0.5; or
// background-gradient: radial #00FFFF #FFFF00 0.5 0.5 1 1 1.2;
$v = trim($bg);
$bgr = preg_split('/\s+/',$v);
$g = array();
if (count($bgr)> 6) {
if (strtoupper(substr($bgr[0],0,1)) == 'L' && count($bgr)==7) { // linear
$g['type'] = 2;
//$coords = array(0,0,1,1 ); // 0 0 1 0 or 0 1 1 1 is L 2 R; 1,1,0,1 is R2L; 1,1,1,0 is T2B; 1,0,1,1 is B2T
// Linear: $coords - array of the form (x1, y1, x2, y2) which defines the gradient vector (see linear_gradient_coords.jpg).
// The default value is from left to right (x1=0, y1=0, x2=1, y2=0).
$g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6]);
}
else if (count($bgr)==8) { // radial
$g['type'] = 3;
// Radial: $coords - array of the form (fx, fy, cx, cy, r) where (fx, fy) is the starting point of the gradient with color1,
// (cx, cy) is the center of the circle with color2, and r is the radius of the circle (see radial_gradient_coords.jpg).
// (fx, fy) should be inside the circle, otherwise some areas will not be defined
$g['coords'] = array($bgr[3], $bgr[4], $bgr[5], $bgr[6], $bgr[7]);
}
$cor = $this->ConvertColor($bgr[1]);
if ($cor) { $g['col'] = array($cor['R'],$cor['G'],$cor['B']); }
else { $g['col'] = array(255); }
$cor = $this->ConvertColor($bgr[2]);
if ($cor) { $g['col2'] = array($cor['R'],$cor['G'],$cor['B']); }
else { $g['col2'] = array(255); }
$g['extend'] = array('true','true');
return $g;
}
return false;
}
/*-- END GRADIENTS --*/
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]);
}
// mPDF 4.0
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 --*/
// mPDF 4.2
// 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 --*/
// mPDF 3.0
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 --*/
// mPDF 4.0
function _mergeCSS(&$p, &$t) {
// Save Cascading CSS e.g. "div.topic p" at this block level
if (isset($p) && $p) {
$carry = $p;
if ($t) {
$t = $this->array_merge_recursive_unique($t, $carry);
}
else { $t = $carry; }
}
}
// 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;
}
// mPDF 4.0
function _mergeFullCSS(&$p, &$t, $tag, $classes, $id) {
$this->_mergeCSS($p[$tag], $t);
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
$this->_mergeCSS($p['CLASS>>'.$class], $t);
}
// STYLESHEET CLASS e.g. #smallone{} #redletter{}
if (isset($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);
}
}
// mPDF 4.0
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); // mPDF 4.0
}
}
}
}
// mPDF 4.0
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; }
}
unset($a['BORDER-'.$side.'-'.$el]);
}
}
}
}
function MergeCSS($inherit,$tag,$attr) {
$p = array();
$zp = array();
$classes = array();
if (isset($attr['CLASS'])) {
$classes = preg_split('/\s+/',$attr['CLASS']);
}
//===============================================
/*-- 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) {
// if ($k != $tag && !preg_match('/^CLASS>>('.implode('|',$classes).')$/i',$k) && !preg_match('/^'.$tag.'>>CLASS>>('.implode('|',$classes).')$/i',$k) && $k != 'ID>>'.$attr['ID'] && $k != $tag.'>>ID>>'.$attr['ID'] && (preg_match('/(ID|CLASS)>>/',$k) || preg_match('/^('.$this->allowedCSStags.')(>>.*){0,1}$/',$k))) {
$this->tablecascadeCSS[$this->tbCSSlvl][$k] = $v;
// }
}
}
// mPDF 4.0
$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
// mPDF 4.0
$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;
}
}
// mPDF 4.0
$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
// mPDF 4.0
$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) {
// if ($k != $tag && !preg_match('/^CLASS>>('.implode('|',$classes).')$/i',$k) && !preg_match('/^'.$tag.'>>CLASS>>('.implode('|',$classes).')$/i',$k) && $k != 'ID>>'.$attr['ID'] && $k != $tag.'>>ID>>'.$attr['ID'] && (preg_match('/(ID|CLASS)>>/',$k) || preg_match('/^('.$this->allowedCSStags.')(>>.*){0,1}$/',$k))) {
$this->blk[$this->blklvl]['cascadeCSS'][$k] = $v;
// }
}
}
//===============================================
// Save Cascading CSS e.g. "div.topic p" at this block level
// mPDF 4.0
if (!isset($attr['ID'])) {
$attr['ID'] = null;
}
$this->_mergeFullCSS($this->cascadeCSS, $this->blk[$this->blklvl]['cascadeCSS'], $tag, $classes, $attr['ID']);
//===============================================
// Cascading forward CSS
//===============================================
// mPDF 4.0
$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]['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'; }
}
// mPDF 3.0
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'] = 'RGB('.$cor['R'].','.$cor['G'].','.$cor['B'].')';
}
}
// mPDF 4.0
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']; }
// mPDF 4.0
$biilp = $this->blk[$this->blklvl-1]['InlineProperties'];
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'] = 'RGB('.$cor['R'].','.$cor['G'].','.$cor['B'].')';
}
if (isset($biilp[ 'toupper' ]) && $biilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
else if (isset($biilp[ 'tolower' ]) && $biilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
// CSS says text-decoration is not inherited, but IE7 does??
if (isset($biilp[ 'underline' ]) && $biilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
}
//===============================================
//===============================================
/*-- LISTS --*/
// Set Inherited properties
// mPDF 4.2
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'] = 'RGB('.$cor['R'].','.$cor['G'].','.$cor['B'].')';
}
if (isset($bilp[ 'toupper' ]) && $bilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
else if (isset($bilp[ 'tolower' ]) && $bilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
// CSS says text-decoration is not inherited, but IE7 does??
if (isset($bilp[ 'underline' ]) && $bilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
if ($tag=='LI') {
$lilp = $this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]];
if (isset($lilp[ 'family' ]) && $lilp[ 'family' ]) { $p['FONT-FAMILY'] = $lilp[ 'family' ]; }
if (isset($lilp[ 'I' ]) && $lilp[ 'I' ]) { $p['FONT-STYLE'] = 'italic'; }
if (isset($lilp[ 'sizePt' ]) && $lilp[ 'sizePt' ]) { $p['FONT-SIZE'] = $lilp[ 'sizePt' ] . 'pt'; }
if (isset($lilp[ 'B' ]) && $lilp[ 'B' ]) { $p['FONT-WEIGHT'] = 'bold'; }
if (isset($lilp[ 'colorarray' ]) && $lilp[ 'colorarray' ]) {
$cor = $lilp[ 'colorarray' ];
$p['COLOR'] = 'RGB('.$cor['R'].','.$cor['G'].','.$cor['B'].')';
}
if (isset($lilp[ 'toupper' ]) && $lilp[ 'toupper' ]) { $p['TEXT-TRANSFORM'] = 'uppercase'; }
else if (isset($lilp[ 'tolower' ]) && $lilp[ 'tolower' ]) { $p['TEXT-TRANSFORM'] = 'lowercase'; }
// CSS says text-decoration is not inherited, but IE7 does??
if (isset($lilp[ 'underline' ]) && $lilp[ 'underline' ]) { $p['TEXT-DECORATION'] = 'underline'; }
}
}
}
/*-- END LISTS --*/
//===============================================
//===============================================
// DEFAULT for this TAG set in DefaultCSS
if (isset($this->defaultCSS[$tag])) {
$zp = $this->fixCSS($this->defaultCSS[$tag]);
/*-- RTL --*/
// mPDF 4.0 $rtlCSS can be any value
if ($this->directionality == 'rtl') {
if (isset($zp['TEXT-ALIGN'])) { $this->reverse_align($zp['TEXT-ALIGN']); } // mPDF 4.0
$pl = $zp['PADDING-LEFT'];
$pr = $zp['PADDING-RIGHT'];
if ($pl || $pr) { $zp['PADDING-RIGHT'] = $pl; $zp['PADDING-LEFT'] = $pr; }
$ml = $zp['MARGIN-LEFT'];
$mr = $zp['MARGIN-RIGHT'];
if ($ml || $mr) { $zp['MARGIN-RIGHT'] = $ml; $zp['MARGIN-LEFT'] = $mr; }
$bl = $zp['BORDER-LEFT'];
$br = $zp['BORDER-RIGHT'];
if ($bl || $br) { $zp['BORDER-RIGHT'] = $bl; $zp['BORDER-LEFT'] = $br; }
}
/*-- END RTL --*/
if (is_array($zp)) { // Default overwrites Inherited
$p = array_merge($p,$zp); // !! Note other way round !!
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
/*-- TABLES --*/
// mPDF 4.0 cellPadding overwrites TD/TH default but not specific CSS set on cell
if (($tag=='TD' || $tag=='TH') && ($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding'] || $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cell_padding']===0)) { // mPDF 4.4.014
$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)) {
// mPDF 4.0
if (($this->directionality == 'rtl') && ($this->rtlCSS > 0) && isset($zp['TEXT-ALIGN'])) { $this->reverse_align($zp['TEXT-ALIGN']); } // *RTL*
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
// 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)) {
// mPDF 4.0
if (($this->directionality == 'rtl') && ($this->rtlCSS > 0) && isset($zp['TEXT-ALIGN'])) { $this->reverse_align($zp['TEXT-ALIGN']); } // *RTL*
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
// 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)) {
// mPDF 4.0
if (($this->directionality == 'rtl') && ($this->rtlCSS > 0) && isset($zp['TEXT-ALIGN'])) { $this->reverse_align($zp['TEXT-ALIGN']); } // *RTL*
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
// 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)) {
// mPDF 4.0
if (($this->directionality == 'rtl') && ($this->rtlCSS > 0) && isset($zp['TEXT-ALIGN'])) { $this->reverse_align($zp['TEXT-ALIGN']); } // *RTL*
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
// 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)) {
// mPDF 4.0
if (($this->directionality == 'rtl') && ($this->rtlCSS > 0) && isset($zp['TEXT-ALIGN'])) { $this->reverse_align($zp['TEXT-ALIGN']); } // *RTL*
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
// Cascaded e.g. div.class p only works for block level
if ($inherit == 'BLOCK') {
// mPDF 4.0
$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);
}
// mPDF 4.0
else if ($inherit == 'INLINE') {
// mPDF 4.0
$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
// mPDF 4.0
$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);
}
$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'
// mPDF 4.0
$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)) {
// mPDF 4.0
if (($this->directionality == 'rtl') && ($this->rtlCSS > 1) && isset($zp['TEXT-ALIGN'])) { // *RTL*
$this->reverse_align($zp['TEXT-ALIGN']); // *RTL*
} // *RTL*
$p = array_merge($p,$zp);
$this->_mergeBorders($p,$zp); // mPDF 4.0
}
}
//===============================================
//===============================================
// 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 --*/
// mPDF 4.2
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(); }
// mPDF 4.2.022 Disallow size or sheet-size on :LEFT or :RIGHT or :FIRST
if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } // mPDF 4.2.024
// 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') { // mPDF 4.2 This had RIGHT in error
$zp = $this->CSS['@PAGE>>PSEUDO>>LEFT'];
}
else { $zp = array(); }
// mPDF 4.2.022 Disallow size or sheet-size on :LEFT or :RIGHT or :FIRST
if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } // mPDF 4.2.024
// 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(); }
// mPDF 4.2.022 Disallow size or sheet-size on :LEFT or :RIGHT or :FIRST
if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } // mPDF 4.2.024
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(); }
// mPDF 4.2.022 Disallow size or sheet-size on :LEFT or :RIGHT or :FIRST
if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } // mPDF 4.2.024
// 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(); }
// mPDF 4.2.022 Disallow size or sheet-size on :LEFT or :RIGHT or :FIRST
if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } // mPDF 4.2.024
// 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(); }
// mPDF 4.2.022 Disallow size or sheet-size on :LEFT or :RIGHT or :FIRST
if (isset($zp['SIZE'])) { unset($zp['SIZE']); }
if (isset($zp['SHEET-SIZE'])) { unset($zp['SHEET-SIZE']); } // mPDF 4.2.024
if (is_array($zp) && !empty($zp)) { $p = array_merge($p,$zp); }
}
// mPDF 4.2
$orientation = $mgl = $mgr = $mgt = $mgb = $mgh = $mgf = '';
$header = $footer = '';
$resetpagenum = $pagenumstyle = $suppress = '';
$marks = '';
$bg = array();
// mPDF 4.2.024
$newformat = '';
// mPDF 4.2.024
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) { // mPDF 4.2.024
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')) { // mPDF 4.2.024
$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;
// mPDF 4.2.024 If new sheet size not specified, set orientation based on page-box
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')) { // mPDF 4.2.024
$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 (strtoupper($p['MARKS']) == 'CROP') { $marks = 'CROP'; }
else if (strtoupper($p['MARKS']) == 'CROSS') { $marks = 'CROSS'; }
// mPDF 3.0
if (isset($p['BACKGROUND-COLOR']) && $p['BACKGROUND-COLOR']) { $bg['BACKGROUND-COLOR'] = $p['BACKGROUND-COLOR']; }
if (isset($p['BACKGROUND-GRADIENT']) && $p['BACKGROUND-GRADIENT']) { $bg['BACKGROUND-GRADIENT'] = $p['BACKGROUND-GRADIENT']; } // *GRADIENTS*
if (isset($p['BACKGROUND-IMAGE']) && $p['BACKGROUND-IMAGE']) { $bg['BACKGROUND-IMAGE'] = $p['BACKGROUND-IMAGE']; } // *BACKGROUND-IMAGES*
if (isset($p['BACKGROUND-REPEAT']) && $p['BACKGROUND-REPEAT']) { $bg['BACKGROUND-REPEAT'] = $p['BACKGROUND-REPEAT']; } // *BACKGROUND-IMAGES*
if (isset($p['BACKGROUND-POSITION']) && $p['BACKGROUND-POSITION']) { $bg['BACKGROUND-POSITION'] = $p['BACKGROUND-POSITION']; } // *BACKGROUND-IMAGES*
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;
// mPDF 4.2
// mPDF 4.2.024
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
// mPDF 4.0
$this->_set_mergedCSS($oldcascadeCSS[$tag], $p);
// STYLESHEET CLASS e.g. .smallone{} .redletter{}
foreach($classes AS $class) {
// mPDF 4.0
$this->_set_mergedCSS($oldcascadeCSS['CLASS>>'.$class], $p);
}
// STYLESHEET CLASS e.g. #smallone{} #redletter{}
if (isset($attr['ID'])) {
// mPDF 4.0
$this->_set_mergedCSS($oldcascadeCSS['ID>>'.$attr['ID']], $p);
}
// STYLESHEET CLASS e.g. div.smallone{} p.redletter{}
foreach($classes AS $class) {
// mPDF 4.0
$this->_set_mergedCSS($oldcascadeCSS[$tag.'>>CLASS>>'.$class], $p);
}
// STYLESHEET CLASS e.g. div#smallone{} p#redletter{}
if (isset($attr['ID'])) {
// mPDF 4.0
$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)) {
// mPDF 4.0 $this->Reset();
$this->pageoutput[$this->page] = array();
$end = max($l_max, $r_max, $currpos);
}
else if ($clear == 'RIGHT' && $r_exists) {
// mPDF 4.0 $this->Reset();
$this->pageoutput[$this->page] = array();
$end = max($r_max, $currpos);
}
else if ($clear == 'LEFT' && $l_exists ) {
// mPDF 4.0 $this->Reset();
$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();
// mPDF 4.0 $this->Reset();
$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 ); }
}
// mPDF 4.2 Baseline = S
$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){
// mPDF 4.2.031
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['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->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
}
else {
/*-- END TABLES --*/
$this->textbuffer[] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *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']) * $this->k;
$p['C']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * $this->k;
$p['R']['font-size'] = $this->ConvertSize($properties['FONT-SIZE']) * $this->k;
}
if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT']=='BOLD') {
$p['L']['font-style'] = 'B';
$p['C']['font-style'] = 'B';
$p['R']['font-style'] = 'B';
}
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='ITALIC') {
$p['L']['font-style'] .= 'I';
$p['C']['font-style'] .= 'I';
$p['R']['font-style'] .= 'I';
}
if (isset($properties['COLOR'])) {
$p['L']['color'] = $properties['COLOR'];
$p['C']['color'] = $properties['COLOR'];
$p['R']['color'] = $properties['COLOR'];
}
}
if (isset($attr['HEADER-STYLE-LEFT']) || isset($attr['FOOTER-STYLE-LEFT'])) {
if ($tag=='PAGEHEADER') { $properties = $this->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']) * $this->k; }
if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT']=='BOLD') { $p['L']['font-style'] ='B'; }
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='ITALIC') { $p['L']['font-style'] .='I'; }
if (isset($properties['COLOR'])) { $p['L']['color'] = $properties['COLOR']; }
}
if (isset($attr['HEADER-STYLE-CENTER']) || isset($attr['FOOTER-STYLE-CENTER'])) {
if ($tag=='PAGEHEADER') { $properties = $this->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']) * $this->k; }
if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT']=='BOLD') { $p['C']['font-style'] = 'B'; }
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='ITALIC') { $p['C']['font-style'] .= 'I'; }
if (isset($properties['COLOR'])) { $p['C']['color'] = $properties['COLOR']; }
}
if (isset($attr['HEADER-STYLE-RIGHT']) || isset($attr['FOOTER-STYLE-RIGHT'])) {
if ($tag=='PAGEHEADER') { $properties = $this->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']) * $this->k; }
if (isset($properties['FONT-WEIGHT']) && $properties['FONT-WEIGHT']=='BOLD') { $p['R']['font-style'] = 'B'; }
if (isset($properties['FONT-STYLE']) && $properties['FONT-STYLE']=='ITALIC') { $p['R']['font-style'] .= 'I'; }
if (isset($properties['COLOR'])) { $p['R']['color'] = $properties['COLOR']; }
}
if (isset($attr['LINE']) && $attr['LINE']) { // 0|1|on|off
if ($attr['LINE']=='1' || strtoupper($attr['LINE'])=='ON') { $lineset=1; }
else { $lineset=0; }
$p['line'] = $lineset;
}
break;
/*-- HTMLHEADERS-FOOTERS --*/
case 'SETHTMLPAGEHEADER':
case 'SETHTMLPAGEFOOTER':
$this->ignorefollowingspaces = true;
if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; }
else { $pname = '_default'; }
if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
if (strtoupper($attr['PAGE'])=='O' || strtoupper($attr['PAGE'])=='ODD') { $side='odd'; }
else if (strtoupper($attr['PAGE'])=='E' || strtoupper($attr['PAGE'])=='EVEN') { $side='even'; }
else if (strtoupper($attr['PAGE'])=='ALL') { $side='both'; }
else { $side='odd'; }
}
else { $side='odd'; }
if (isset($attr['VALUE']) && $attr['VALUE']) { // -1|1|on|off
if ($attr['VALUE']=='1' || strtoupper($attr['VALUE'])=='ON') { $set=1; }
else if ($attr['VALUE']=='-1' || strtoupper($attr['VALUE'])=='OFF') { $set=0; }
else { $set=1; }
}
else { $set=1; }
if (isset($attr['SHOW-THIS-PAGE']) && $attr['SHOW-THIS-PAGE'] && $tag=='SETHTMLPAGEHEADER') { $write = 1; }
else { $write = 0; }
if ($side=='odd' || $side=='both') {
if ($set && $tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader($this->pageHTMLheaders[$pname],'O',$write); }
else if ($set && $tag=='SETHTMLPAGEFOOTER') { $this->SetHTMLFooter($this->pageHTMLfooters[$pname],'O'); }
else if ($tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader('','O'); }
else { $this->SetHTMLFooter('','O'); }
}
if ($side=='even' || $side=='both') {
if ($set && $tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader($this->pageHTMLheaders[$pname],'E',$write); }
else if ($set && $tag=='SETHTMLPAGEFOOTER') { $this->SetHTMLFooter($this->pageHTMLfooters[$pname],'E'); }
else if ($tag=='SETHTMLPAGEHEADER') { $this->SetHTMLHeader('','E'); }
else { $this->SetHTMLFooter('','E'); }
}
break;
/*-- END HTMLHEADERS-FOOTERS --*/
case 'SETPAGEHEADER':
case 'SETPAGEFOOTER':
$this->ignorefollowingspaces = true;
if (isset($attr['NAME']) && $attr['NAME']) { $pname = $attr['NAME']; }
else { $pname = '_default'; }
if (isset($attr['PAGE']) && $attr['PAGE']) { // O|odd|even|E|ALL|[blank]
if (strtoupper($attr['PAGE'])=='O' || strtoupper($attr['PAGE'])=='ODD') { $side='odd'; }
else if (strtoupper($attr['PAGE'])=='E' || strtoupper($attr['PAGE'])=='EVEN') { $side='even'; }
else if (strtoupper($attr['PAGE'])=='ALL') { $side='both'; }
else { $side='odd'; }
}
else { $side='odd'; }
if (isset($attr['VALUE']) && $attr['VALUE']) { // -1|1|on|off
if ($attr['VALUE']=='1' || strtoupper($attr['VALUE'])=='ON') { $set=1; }
else if ($attr['VALUE']=='-1' || strtoupper($attr['VALUE'])=='OFF') { $set=0; }
else { $set=1; }
}
else { $set=1; }
if ($side=='odd' || $side=='both') {
if ($set && $tag=='SETPAGEHEADER') { $this->headerDetails['odd'] = $this->pageheaders[$pname]; }
else if ($set && $tag=='SETPAGEFOOTER') { $this->footerDetails['odd'] = $this->pagefooters[$pname]; }
else if ($tag=='SETPAGEHEADER') { $this->headerDetails['odd'] = array(); }
else { $this->footerDetails['odd'] = array(); }
// mPDF 4.0
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(); }
// mPDF 4.0
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 (isset($attr['FONT-SIZE']) && $attr['FONT-SIZE']) { $tocfontsize = $attr['FONT-SIZE']; } else { $tocfontsize = ''; }
if (isset($attr['FONT']) && $attr['FONT']) { $tocfont = $attr['FONT']; } else { $tocfont = ''; }
if (isset($attr['INDENT']) && $attr['INDENT']) { $tocindent = $attr['INDENT']; } else { $tocindent = ''; }
if (isset($attr['RESETPAGENUM']) && $attr['RESETPAGENUM']) { $resetpagenum = $attr['RESETPAGENUM']; } else { $resetpagenum = ''; }
if (isset($attr['PAGENUMSTYLE']) && $attr['PAGENUMSTYLE']) { $pagenumstyle = $attr['PAGENUMSTYLE']; } else { $pagenumstyle= ''; }
if (isset($attr['SUPPRESS']) && $attr['SUPPRESS']) { $suppress = $attr['SUPPRESS']; } else { $suppress = ''; }
if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $toc_orientation = $attr['TOC-ORIENTATION']; } else { $toc_orientation = ''; }
if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $paging = false; }
else { $paging = true; }
if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $links = true; }
else { $links = false; }
if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; }
$this->TOC($tocfont,$tocfontsize,$tocindent,$resetpagenum, $pagenumstyle, $suppress, $toc_orientation, $paging, $links, $toc_id);
break;
case 'TOCPAGEBREAK': // custom-tag - set Marker for insertion later of ToC AND adds PAGEBREAK
if (isset($attr['NAME']) && $attr['NAME']) { $toc_id = strtolower($attr['NAME']); } else { $toc_id = 0; }
if ($toc_id) {
if (isset($attr['FONT-SIZE'])) { $this->m_TOC[$toc_id]['TOCfontsize'] = $attr['FONT-SIZE']; } else { $this->m_TOC[$toc_id]['TOCfontsize'] = $this->default_font_size; }
if (isset($attr['FONT'])) { $this->m_TOC[$toc_id]['TOCfont'] = $attr['FONT']; } else { $this->m_TOC[$toc_id]['TOCfont'] = $this->default_font; }
if (isset($attr['INDENT']) && $attr['INDENT']) { $this->m_TOC[$toc_id]['TOCindent'] = $attr['INDENT']; } else { $this->m_TOC[$toc_id]['TOCindent'] = ''; }
if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->m_TOC[$toc_id]['TOCorientation'] = $attr['TOC-ORIENTATION']; } else { $this->m_TOC[$toc_id]['TOCorientation'] = ''; }
if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->m_TOC[$toc_id]['TOCusePaging'] = false; }
else { $this->m_TOC[$toc_id]['TOCusePaging'] = true; }
if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->m_TOC[$toc_id]['TOCuseLinking'] = true; }
else { $this->m_TOC[$toc_id]['TOCuseLinking'] = false; }
$this->m_TOC[$toc_id]['TOC_margin_left'] = $this->m_TOC[$toc_id]['TOC_margin_right'] = $this->m_TOC[$toc_id]['TOC_margin_top'] = $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $this->m_TOC[$toc_id]['TOC_margin_header'] = $this->m_TOC[$toc_id]['TOC_margin_footer'] = '';
if (isset($attr['TOC-MARGIN-RIGHT'])) { $this->m_TOC[$toc_id]['TOC_margin_right'] = $this->ConvertSize($attr['TOC-MARGIN-RIGHT'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-LEFT'])) { $this->m_TOC[$toc_id]['TOC_margin_left'] = $this->ConvertSize($attr['TOC-MARGIN-LEFT'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-TOP'])) { $this->m_TOC[$toc_id]['TOC_margin_top'] = $this->ConvertSize($attr['TOC-MARGIN-TOP'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-BOTTOM'])) { $this->m_TOC[$toc_id]['TOC_margin_bottom'] = $this->ConvertSize($attr['TOC-MARGIN-BOTTOM'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-HEADER'])) { $this->m_TOC[$toc_id]['TOC_margin_header'] = $this->ConvertSize($attr['TOC-MARGIN-HEADER'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-FOOTER'])) { $this->m_TOC[$toc_id]['TOC_margin_footer'] = $this->ConvertSize($attr['TOC-MARGIN-FOOTER'],$this->w,$this->FontSize,false); }
$this->m_TOC[$toc_id]['TOC_odd_header_name'] = $this->m_TOC[$toc_id]['TOC_even_header_name'] = $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $this->m_TOC[$toc_id]['TOC_even_footer_name'] = '';
if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) { $this->m_TOC[$toc_id]['TOC_odd_header_name'] = $attr['TOC-ODD-HEADER-NAME']; }
if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) { $this->m_TOC[$toc_id]['TOC_even_header_name'] = $attr['TOC-EVEN-HEADER-NAME']; }
if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) { $this->m_TOC[$toc_id]['TOC_odd_footer_name'] = $attr['TOC-ODD-FOOTER-NAME']; }
if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) { $this->m_TOC[$toc_id]['TOC_even_footer_name'] = $attr['TOC-EVEN-FOOTER-NAME']; }
$this->m_TOC[$toc_id]['TOC_odd_header_value'] = $this->m_TOC[$toc_id]['TOC_even_header_value'] = $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 0;
if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_odd_header_value'] = 1; }
else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_odd_header_value'] = -1; }
if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_even_header_value'] = 1; }
else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_even_header_value'] = -1; }
if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = 1; }
else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_odd_footer_value'] = -1; }
if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='ON')) { $this->m_TOC[$toc_id]['TOC_even_footer_value'] = 1; }
else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='OFF')) { $this->m_TOC[$toc_id]['TOC_even_footer_value'] = -1; }
// mPDF 4.2
if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->m_TOC[$toc_id]['TOC_page_selector'] = $attr['TOC-PAGE-SELECTOR']; }
else { $this->m_TOC[$toc_id]['TOC_page_selector'] = ''; }
// mPDF 4.2.04
if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) { $this->m_TOC[$toc_id]['TOCsheetsize'] = $attr['TOC-SHEET-SIZE']; } else { $this->m_TOC[$toc_id]['TOCsheetsize'] = ''; }
if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->m_TOC[$toc_id]['TOCpreHTML'] = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->m_TOC[$toc_id]['TOCpostHTML'] = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
// mPDF 3.0
if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->m_TOC[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); } // *BOOKMARKS*
}
else {
if (isset($attr['FONT-SIZE'])) { $this->TOCfontsize = $attr['FONT-SIZE']; } else { $this->TOCfontsize = $this->default_font_size; }
if (isset($attr['FONT'])) { $this->TOCfont = $attr['FONT']; } else { $this->TOCfont = $this->default_font; }
if (isset($attr['INDENT']) && $attr['INDENT']) { $this->TOCindent = $attr['INDENT']; } else { $this->TOCindent = ''; }
if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) { $this->TOCorientation = $attr['TOC-ORIENTATION']; } else { $this->TOCorientation = ''; }
if (isset($attr['PAGING']) && (strtoupper($attr['PAGING'])=='OFF' || $attr['PAGING']==='0')) { $this->TOCusePaging = false; }
else { $this->TOCusePaging = true; }
if (isset($attr['LINKS']) && (strtoupper($attr['LINKS'])=='ON' || $attr['LINKS']==1)) { $this->TOCuseLinking = true; }
else { $this->TOCuseLinking = false; }
$this->TOC_margin_left = $this->TOC_margin_right = $this->TOC_margin_top = $this->TOC_margin_bottom = $this->TOC_margin_header = $this->TOC_margin_footer = '';
if (isset($attr['TOC-MARGIN-RIGHT'])) { $this->TOC_margin_right = $this->ConvertSize($attr['TOC-MARGIN-RIGHT'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-LEFT'])) { $this->TOC_margin_left = $this->ConvertSize($attr['TOC-MARGIN-LEFT'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-TOP'])) { $this->TOC_margin_top = $this->ConvertSize($attr['TOC-MARGIN-TOP'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-BOTTOM'])) { $this->TOC_margin_bottom = $this->ConvertSize($attr['TOC-MARGIN-BOTTOM'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-HEADER'])) { $this->TOC_margin_header = $this->ConvertSize($attr['TOC-MARGIN-HEADER'],$this->w,$this->FontSize,false); }
if (isset($attr['TOC-MARGIN-FOOTER'])) { $this->TOC_margin_footer = $this->ConvertSize($attr['TOC-MARGIN-FOOTER'],$this->w,$this->FontSize,false); }
$this->TOC_odd_header_name = $this->TOC_even_header_name = $this->TOC_odd_footer_name = $this->TOC_even_footer_name = '';
if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) { $this->TOC_odd_header_name = $attr['TOC-ODD-HEADER-NAME']; }
if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) { $this->TOC_even_header_name = $attr['TOC-EVEN-HEADER-NAME']; }
if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) { $this->TOC_odd_footer_name = $attr['TOC-ODD-FOOTER-NAME']; }
if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) { $this->TOC_even_footer_name = $attr['TOC-EVEN-FOOTER-NAME']; }
$this->TOC_odd_header_value = $this->TOC_even_header_value = $this->TOC_odd_footer_value = $this->TOC_even_footer_value = 0;
if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='ON')) { $this->TOC_odd_header_value = 1; }
else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-HEADER-VALUE'])=='OFF')) { $this->TOC_odd_header_value = -1; }
if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='ON')) { $this->TOC_even_header_value = 1; }
else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-HEADER-VALUE'])=='OFF')) { $this->TOC_even_header_value = -1; }
if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='ON')) { $this->TOC_odd_footer_value = 1; }
else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-ODD-FOOTER-VALUE'])=='OFF')) { $this->TOC_odd_footer_value = -1; }
if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='ON')) { $this->TOC_even_footer_value = 1; }
else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE']=='-1' || strtoupper($attr['TOC-EVEN-FOOTER-VALUE'])=='OFF')) { $this->TOC_even_footer_value = -1; }
// mPDF 4.2
if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) { $this->TOC_page_selector = $attr['TOC-PAGE-SELECTOR']; }
else { $this->TOC_page_selector = ''; }
// mPDF 4.2.04
if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) { $this->TOCsheetsize = $attr['TOC-SHEET-SIZE']; } else { $this->TOCsheetsize = ''; }
if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) { $this->TOCpreHTML = htmlspecialchars_decode($attr['TOC-PREHTML'],ENT_QUOTES); }
if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) { $this->TOCpostHTML = htmlspecialchars_decode($attr['TOC-POSTHTML'],ENT_QUOTES); }
if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) { $this->TOCbookmarkText = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'],ENT_QUOTES); } // *BOOKMARKS*
}
// mPDF 3.0
if ($this->y == $this->tMargin && (!$this->mirrorMargins ||($this->mirrorMargins && $this->page % 2==1))) {
if ($toc_id) { $this->m_TOC[$toc_id]['TOCmark'] = $this->page; }
else { $this->TOCmark = $this->page; }
// Don't add a page
if ($this->page==1 && count($this->PageNumSubstitutions)==0) {
$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 (!$suppress) { $suppress = 'off'; }
if (!$resetpagenum) { $resetpagenum= 1; }
$this->PageNumSubstitutions[] = array('from'=>1, 'reset'=> $resetpagenum, 'type'=>$pagenumstyle, 'suppress'=> $suppress);
}
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 --*/
// mPDF 4.2.024
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; }
// mPDF 4.2
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 = ''; }
// mPDF 4.2
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->m_TOC[$toc_id]['TOCmark'] = $this->page; }
else { $this->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']) {
// mPDF 3.0
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;
// mPDF 3.0
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 --*/
// mPDF 3.0
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;
// mPDF 3.0
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'])) {
// mPDF 3.0
$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':
// mPDF 4.0
if (isset($attr['CONTENT']) && !$this->writingHTMLheader && !$this->writingHTMLfooter) { // Stops annotations in FixedPos
$objattr = array();
// mPDF 3.0
$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'] = ''; // mPDF 4.2.027
}
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 { $objattr['AUTHOR'] = ''; }
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'] = array($cor['R'],$cor['G'],$cor['B']); }
else { $objattr['COLOR'] = array(255,255,0); }
}
else { $objattr['COLOR'] = array(255,255,0); }
// mPDF 4.2.027
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'=>'zapfdingbats','FONT-WEIGHT'=>'normal','FONT-STYLE'=>'normal'),'INLINE');
break;
case 'TTS':
$this->tts = true;
$this->InlineProperties[$tag] = $this->saveInlineProperties();
$this->setCSS(array('FONT-FAMILY'=>'symbol','FONT-WEIGHT'=>'normal','FONT-STYLE'=>'normal'),'INLINE');
break;
case 'TTA':
$this->tta = true;
$this->InlineProperties[$tag] = $this->saveInlineProperties();
// mPDF 4.0
if (in_array($this->FontFamily,$this->mono_fonts)) {
$this->setCSS(array('FONT-FAMILY'=>'courier-embedded'),'INLINE');
}
else if (in_array($this->FontFamily,$this->serif_fonts)) {
$this->setCSS(array('FONT-FAMILY'=>'times-embedded'),'INLINE');
}
else {
$this->setCSS(array('FONT-FAMILY'=>'helvetica-embedded'),'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();
// mPDF 3.0
$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'] = array(255,255,0);
$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); // mPDF 4.0
if (!empty($properties)) $this->setCSS($properties,'INLINE');
break;
case 'A':
if (isset($attr['NAME']) and $attr['NAME'] != '') {
// mPDF 3.0
$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->cell[$this->row][$this->col]['textbuffer'][] = array($e,'','',array(),'',false,false,$attr['NAME']); // *TABLES*
} // *TABLES*
else { // *TABLES*
$this->textbuffer[] = array($e,'','',array(),'',false,false,$attr['NAME']); //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=$attr['HREF'];
}
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) {
// mPDF 3.0
if ($this->blockjustfinished || $this->listjustfinished) {
$this->cell[$this->row][$this->col]['textbuffer'][] = array("\n",$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['text'][] = "\n";
}
$this->cell[$this->row][$this->col]['textbuffer'][] = array("\n",$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['text'][] = "\n";
if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
$this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
}
elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
$this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
}
$this->cell[$this->row][$this->col]['s'] = 0 ;// reset
}
else {
/*-- END TABLES --*/
$this->textbuffer[] = array("\n",$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *TABLES*
$this->ignorefollowingspaces = true;
$this->blockjustfinished=false;
$this->listjustfinished=false;
// mPDF 3.0
$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 '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;
}
/*-- CSS-POSITION --*/
// mPDF 4.0
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;
// mPDF 4.2
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 --*/
// mPDF 4.0
if ($this->listlvl>0) { return; }
/*-- END LISTS --*/
$this->InlineProperties = array();
$this->spanlvl = 0;
$this->listjustfinished=false;
$this->divbegin=true;
// mPDF 3.0
$this->linebreakjustfinished=false;
/*-- TABLES --*/
if ($this->tableLevel) {
// mPDF 3.0
// If already something on the line
if ($this->cell[$this->row][$this->col]['s'] > 0 && !$this->nestedtablejustfinished ) {
$this->cell[$this->row][$this->col]['textbuffer'][] = array("\n",$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['text'][] = "\n";
if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
$this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
}
elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
$this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
}
$this->cell[$this->row][$this->col]['s'] = 0 ;// reset
}
// Cannot set block properties inside table - use Bold to indicate h1-h6
if ($tag == 'CENTER' && $this->tdbegin) { $this->cell[$this->row][$this->col]['a'] = $align['center']; }
$this->InlineProperties['BLOCKINTABLE'] = $this->saveInlineProperties();
$properties = $this->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();
$this->blklvl++;
// mPDF 4.0
$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 --*/
// mPDF 4.2
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
$this->blklvl = 0;
$this->lastblocklevelchange = 0;
$this->blk = array();
// mPDF 4.0
$this->initialiseBlock($this->blk[0]);
$this->blk[0]['width'] =& $this->pgwidth;
$this->blk[0]['inner_width'] =& $this->pgwidth;
// mPDF 3.0
$this->blk[0]['blockContext'] = $this->blockContext;
$properties = $this->MergeCSS('BLOCK','BODY','');
$this->setCSS($properties,'','BODY');
$this->blklvl++;
// mPDF 4.0
$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 (isset($properties['PAGE-BREAK-INSIDE']) && strtoupper($properties['PAGE-BREAK-INSIDE']) == 'AVOID' && !$this->ColActive && !$this->keep_block_together) {
$currblk['keep_block_together'] = 1;
$currblk['y00'] = $this->y;
$this->keep_block_together = 1;
$this->divbuffer = array();
$this->ktLinks = array();
$this->ktAnnots = array();
$this->ktBlock = array();
$this->ktReference = array();
$this->ktBMoutlines = array();
$this->_kttoc = array();
}
// mPDF 4.2 Collaspe vertical block margins
if ($lastbottommargin && $properties['MARGIN-TOP']) { $currblk['lastbottommargin'] = $lastbottommargin; }
$this->setCSS($properties,'BLOCK',$tag); //name(id/class/style) found in the CSS array!
$currblk['InlineProperties'] = $this->saveInlineProperties();
if(isset($attr['ALIGN']) && $attr['ALIGN']) { $currblk['block-align'] = $align[strtolower($attr['ALIGN'])]; }
// mPDF 4.0 height
if (isset($properties['HEIGHT'])) { $currblk['css_set_height'] = $this->ConvertSize($properties['HEIGHT'],($this->h - $this->tMargin - $this->bMargin),$this->FontSize,false); }
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;
$currblk['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)) < $this->GetStringWidth('WW')) {
// 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)) > $this->GetStringWidth('WW')) {
$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)) > $this->GetStringWidth('WW')) {
$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;
$currblk['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)) < $this->GetStringWidth('WW')) {
// 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)) > $this->GetStringWidth('WW')) {
$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)) > $this->GetStringWidth('WW')) {
$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)) < $this->GetStringWidth('WW')) {
// 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)) > $this->GetStringWidth('WW')) {
$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)) > $this->GetStringWidth('WW')) {
$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
// mPDF 4.0
$cbti = $this->ConvertSize($currblk['text_indent'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
if ($cbti < 0) {
$hangind = -($cbti);
if ($this->directionality == '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 ($this->directionality == '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 = $this->GetStringWidth('WW');
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'];
/*-- BACKGROUND-IMAGES --*/
// mPDF 4.3.011
if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->kwt && !$this->ColActive && !$this->keep_block_together) {
$file = $properties['BACKGROUND-IMAGE'];
$sizesarray = $this->Image($file,0,0,0,0,'','',false, false, false, false, false); // mPDF 4.3.012D
if (isset($sizesarray['IMAGE_ID'])) {
$image_id = $sizesarray['IMAGE_ID'];
$orig_w = $sizesarray['WIDTH']*$this->k; // in user units i.e. mm
$orig_h = $sizesarray['HEIGHT']*$this->k; // (using $this->img_dpi)
$x_repeat = true;
$y_repeat = true;
if (isset($properties['BACKGROUND-REPEAT'])) {
if ($properties['BACKGROUND-REPEAT']=='no-repeat' || $properties['BACKGROUND-REPEAT']=='repeat-x') { $y_repeat = false; }
if ($properties['BACKGROUND-REPEAT']=='no-repeat' || $properties['BACKGROUND-REPEAT']=='repeat-y') { $x_repeat = false; }
}
$x_pos = 0;
$y_pos = 0;
if (isset($properties['BACKGROUND-POSITION'])) {
$ppos = preg_split('/\s+/',$properties['BACKGROUND-POSITION']);
$x_pos = $ppos[0];
$y_pos = $ppos[1];
if (!stristr($x_pos ,'%') ) { $x_pos = $this->ConvertSize($x_pos ,$currblk['inner_width'],$this->FontSize); }
if (!stristr($y_pos ,'%') ) { $y_pos = $this->ConvertSize($y_pos ,$currblk['inner_width'],$this->FontSize); }
}
// mPDF 4.3.015
if (isset($properties['BACKGROUND-IMAGE-RESIZE'])) { $resize = $properties['BACKGROUND-IMAGE-RESIZE']; }
else { $resize = 0; }
// mPDF 4.3.017
if (isset($properties['BACKGROUND-IMAGE-OPACITY'])) { $opacity = $properties['BACKGROUND-IMAGE-OPACITY']; }
else { $opacity = 1; }
$currblk['background-image'] = array('image_id'=>$image_id, 'orig_w'=>$orig_w, 'orig_h'=>$orig_h, 'x_pos'=>$x_pos, 'y_pos'=>$y_pos, 'x_repeat'=>$x_repeat, 'y_repeat'=>$y_repeat, 'resize'=>$resize, 'opacity'=>$opacity); // mPDF 4.3.015 4.3.017
}
}
/*-- END BACKGROUND-IMAGES --*/
/*-- 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;
// mPDF 3.0
$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();
// mPDF 3.0
$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'])]; }
// mPDF 3.0
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->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
}
else {
/*-- END TABLES --*/
$this->textbuffer[] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *TABLES*
break;
/*-- BARCODES --*/
// mPDF 4.0
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')) {
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 ;
}
}
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->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
}
else {
/*-- END TABLES --*/
$this->textbuffer[] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *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'])) {
if (!$this->isCJK) {
$this->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
}
}
if (isset($properties['FONT-SIZE'])) {
$mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/$this->k);
$this->SetFontSize($mmsize*$this->k,false);
}
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['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']; }
$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;
}
// mPDD 1.4 Active Forms
$this->selectoption['currentVAL'] = $attr['VALUE'];
break;
case 'TEXTAREA':
$objattr = array();
// mPDF 3.0
$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['TITLE'])) { $objattr['title'] = $attr['TITLE']; }
$this->InlineProperties[$tag] = $this->saveInlineProperties();
$properties = $this->MergeCSS('',$tag,$attr);
if (isset($properties['FONT-FAMILY'])) {
if (!$this->isCJK) {
$this->SetFont($properties['FONT-FAMILY'],'',0,false);
}
}
if (isset($properties['FONT-SIZE'])) {
$mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/$this->k);
$this->SetFontSize($mmsize*$this->k,false);
}
if (isset($properties['COLOR'])) { $objattr['color'] = $this->ConvertColor($properties['COLOR']); }
$objattr['fontfamily'] = $this->FontFamily;
$objattr['fontsize'] = $this->FontSizePt;
$this->SetLineHeight('',$this->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->GetStringWidth('w');
if ($w) { $colsize = round(($w-($this->form_element_spacing['textarea']['outer']['h']*2)-($this->form_element_spacing['textarea']['inner']['h']*2))/$charsize); }
if ($h) { $rowsize = round(($h-($this->form_element_spacing['textarea']['outer']['v']*2)-($this->form_element_spacing['textarea']['inner']['v']*2))/$formLineHeight); }
$objattr['type'] = 'textarea';
$objattr['width'] = ($colsize * $charsize) + ($this->form_element_spacing['textarea']['outer']['h']*2)+($this->form_element_spacing['textarea']['inner']['h']*2);
$objattr['height'] = ($rowsize * $formLineHeight) + ($this->form_element_spacing['textarea']['outer']['v']*2)+($this->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();
// mPDF 3.0
$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['TITLE'])) { $objattr['title'] = $attr['TITLE']; }
else if(isset($attr['ALT'])) { $objattr['title'] = $attr['ALT']; }
$this->InlineProperties[$tag] = $this->saveInlineProperties();
$properties = $this->MergeCSS('',$tag,$attr);
$objattr['vertical-align'] = '';
if (isset($properties['FONT-FAMILY'])) {
if (!$this->isCJK) {
$this->SetFont($properties['FONT-FAMILY'],$this->FontStyle,0,false);
}
}
if (isset($properties['FONT-SIZE'])) {
$mmsize = $this->ConvertSize($properties['FONT-SIZE'],($this->default_font_size/$this->k));
$this->SetFontSize($mmsize*$this->k,false);
}
if (isset($properties['COLOR'])) { $objattr['color'] = $this->ConvertColor($properties['COLOR']); }
$objattr['fontfamily'] = $this->FontFamily;
$objattr['fontsize'] = $this->FontSizePt;
$type = '';
$texto='';
$height = $this->FontSize;
$width = 0;
$spacesize = $this->GetStringWidth(' ');
$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->InlineProperties[$tag]) { $this->restoreInlineProperties($this->InlineProperties[$tag]); }
unset($this->InlineProperties[$tag]);
break 2;
case 'CHECKBOX': //Draw Checkbox
$type = 'CHECKBOX';
if (isset($attr['VALUE'])) $objattr['value'] = $attr['VALUE'];
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']; // mPDF 4.2.029
// 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']); }
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
// mPDF 4.2
$info=$this->_getImage($srcpath, true, false, $orig_srcpath); // mPDF 4.2.029
if(!$info) {
$info = $this->_getImage($this->noImageFile);
if ($info) {
$srcpath = $this->noImageFile;
$w = ($info['w'] * (25.4/$this->dpi)); // mPDF 4.4.003
$h = ($info['h'] * (25.4/$this->dpi)); // mPDF 4.4.003
}
}
if(!$info) break;
$objattr['file'] = $srcpath;
//Default width and height calculation if needed
if($w==0 and $h==0) {
//Put image at default dpi
$w=($info['w']/$this->k) * (72/$this->img_dpi);
$h=($info['h']/$this->k) * (72/$this->img_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) ; // mPDF 4.1
if ($this->fullImageHeight) { $maxHeight = $this->fullImageHeight; } // mPDF 4.1
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['image_height'] = $h;
$objattr['image_width'] = $w;
$objattr['ID'] = $info['i'];
$texto = 'X';
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['VALUE'])) {
$objattr['value'] = $attr['VALUE'];
}
else {
$objattr['value'] = ucfirst(strtolower($type));
}
$texto = " " . $objattr['value'] . " ";
$width = $this->GetStringWidth($texto) + ($this->form_element_spacing['button']['outer']['h']*2)+($this->form_element_spacing['button']['inner']['h']*2);
$height = $this->FontSize + ($this->form_element_spacing['button']['outer']['v']*2)+($this->form_element_spacing['button']['inner']['v']*2);
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 = strlen($attr['VALUE']);
$texto = str_repeat('*',$num_stars);
}
else { $texto = $attr['VALUE']; }
}
$xw = ($this->form_element_spacing['input']['outer']['h']*2)+($this->form_element_spacing['input']['inner']['h']*2);
$xh = ($this->form_element_spacing['input']['outer']['v']*2)+($this->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;
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->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
}
else {
/*-- END TABLES --*/
$this->textbuffer[] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *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;
// mPDF 4.0
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) {
// mPDF 4.3.016
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;
// mPDF 4.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']; // mPDF 4.2.029
$properties = $this->MergeCSS('',$tag,$attr);
if(isset($properties ['DISPLAY']) && strtolower($properties ['DISPLAY'])=='none') {
return;
}
// 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); }
// mPDF 4.0
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;
// mPDF 4.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) { $objattr['link'] = $this->HREF; } // ? this isn't used
// mPDF 4.0
$extraheight = $objattr['padding_top'] + $objattr['padding_bottom'] + $objattr['margin_top'] + $objattr['margin_bottom'] + $objattr['border_top']['w'] + $objattr['border_bottom']['w'];
$extrawidth = $objattr['padding_left'] + $objattr['padding_right'] + $objattr['margin_left'] + $objattr['margin_right'] + $objattr['border_left']['w'] + $objattr['border_right']['w'];
// Image file
$info=$this->_getImage($srcpath, true, true, $orig_srcpath); // mPDF 4.2.029
if(!$info) {
$info = $this->_getImage($this->noImageFile);
if ($info) {
$srcpath = $this->noImageFile;
$w = ($info['w'] * (25.4/$this->dpi)); // mPDF 4.4.003
$h = ($info['h'] * (25.4/$this->dpi)); // mPDF 4.4.003
}
}
if(!$info) break;
// mPDF 4.3.016
if(isset($attr['ROTATE'])) {
if ($attr['ROTATE']==90 || $attr['ROTATE']==-90) {
$tmpw = $info['w'];
$info['w'] = $info['h'];
$info['h'] = $tmpw;
}
$objattr['ROTATE'] = $attr['ROTATE'];
}
$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*$this->k);
$h = abs($info['h']) / (20*$this->k);
}
else
/*-- END IMAGES-WMF --*/
// mPDF 4.3.013
if ($info['type']=='svg') {
// SVG units are pixels
$w = abs($info['w'])/$this->k;
$h = abs($info['h'])/$this->k;
}
else {
//Put image at default image dpi
$w=($info['w']/$this->k) * (72/$this->img_dpi);
$h=($info['h']/$this->k) * (72/$this->img_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 + 10) ; // mPDF 4.1
if ($this->fullImageHeight) { $maxHeight = $this->fullImageHeight; } // mPDF 4.1
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 --*/
// mPDF 4.3.013
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->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ;
}
else {
/*-- END TABLES --*/
$this->textbuffer[] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *TABLES*
/*-- ANNOTATIONS --*/
if ($this->title2annots && isset($attr['TITLE'])) {
$objattr = array();
// mPDF 3.0
$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'] = array(255,255,0);
$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 --*/
/*-- 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); // true = newblock
$this->finishFlowingBlock(true); // true = END of flowing block
}
else if (!$this->tableLevel && count($this->textbuffer)) { $this->printbuffer($this->textbuffer,$blockstate); }
//else if (!$this->tableLevel) { $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]]['tablecascadeCSS'] = $this->tablecascadeCSS;
$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++;
// mPDF 3.0
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 3.0
$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;
// mPDF 4.2
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->table_lineheight = $this->normalLineheight; } // mPDF 4.2
// mPDF 3.0
if ($this->tableLevel==1) { $this->tableheadernrows = 0; $this->tablefooternrows = 0; $this->usetableheader = false; } // mPDF 4.0
if ($this->tableLevel ==1) $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['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 ($this->directionality == '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 ($this->directionality == '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']){ // mPDF 4.3.007
$this->table_border_css_set = 1;
}
else {
$this->table_border_css_set = 0;
}
if (isset($properties['FONT-FAMILY'])) {
if (!$this->isCJK) {
$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/$this->k);
if ($mmsize) {
$this->default_font_size = $mmsize*($this->k);
$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['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'])) {
// mPDF 4.2 Collaspe vertical block margins
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'])) { // mPDF 4.2 Error corrected
$table['margin']['L'] = $this->ConvertSize($properties['MARGIN-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
}
if (isset($properties['MARGIN-RIGHT'])) { // mPDF 4.2 Error corrected
$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';
}
// mPDF 4.2
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->table_keep_together = true;
}
else if ($this->tableLevel==1) {
$this->table_keep_together = false;
}
// mPDF 4.2
if (isset($properties['OVERFLOW'])) {
$table['overflow'] = strtolower($properties['OVERFLOW']); // 'hidden' 'wrap' or 'visible' or 'auto'
}
$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['REPEAT_HEADER']) and $attr['REPEAT_HEADER'] == true) { $this->UseTableHeader(true); }
if (isset($attr['ALIGN'])) { $table['a'] = $align[strtolower($attr['ALIGN'])]; }
if (!$table['a']) { $table['a'] = $this->defaultTableAlign; } // mPDF 4.0
if (isset($attr['BGCOLOR'])) { $table['bgcolor'][-1] = $attr['BGCOLOR']; }
// mPDF 4.0 This does not work
// if (isset($attr['HEIGHT'])) { $table['h'] = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width']); }
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();
// mPDF 3.0
$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();
break;
case 'THEAD':
$this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
$this->tbCSSlvl++;
$this->tablethead = 1;
$this->UseTableHeader(true);
$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['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++;
// mPDF 4.0
$this->tabletfoot = 1;
// mPDF 3.0
$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['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':
// mPDF 3.0
$this->tablethead = 0;
$this->tabletfoot = 0; // mPDF 4.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 (isset($properties['BACKGROUND-COLOR'])) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['bgcolor'][$this->row] = $properties['BACKGROUND-COLOR']; }
else if (isset($properties['BACKGROUND'])) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['bgcolor'][$this->row] = $properties['BACKGROUND']; }
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; }
// mPDF 4.0
if ($this->tabletfoot) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$this->row] = true; }
$properties = array();
break;
case 'TH':
case 'TD':
$this->ignorefollowingspaces = true;
$this->lastoptionaltag = $tag; // Save current HTML specified optional endtag
$this->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; }
$this->cell[$this->row][$this->col] = array();
$this->cell[$this->row][$this->col]['text'] = array();
$this->cell[$this->row][$this->col]['s'] = 0 ;
$table = &$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]];
$cell = &$this->cell[$this->row][$this->col];
$cell['a'] = false;
$cell['R'] = false;
$cell['nowrap'] = false;
$cell['bgcolor'] = false; // mPDF 4.3.006
$cell['padding']['L'] = false;
$cell['padding']['R'] = false;
$cell['padding']['T'] = false;
$cell['padding']['B'] = false;
if ($this->simpleTables && $this->row==0 && $this->col==0){ // mPDF 4.2.017
$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) {
$cell['border'] = false;
$cell['border_details']['R']['w'] = 0;
$cell['border_details']['L']['w'] = 0;
$cell['border_details']['T']['w'] = 0;
$cell['border_details']['B']['w'] = 0;
$cell['border_details']['mbw']['BL'] = 0;
$cell['border_details']['mbw']['BR'] = 0;
$cell['border_details']['mbw']['RT'] = 0;
$cell['border_details']['mbw']['RB'] = 0;
$cell['border_details']['mbw']['TL'] = 0;
$cell['border_details']['mbw']['TR'] = 0;
$cell['border_details']['mbw']['LT'] = 0;
$cell['border_details']['mbw']['LB'] = 0;
$cell['border_details']['R']['style'] = '';
$cell['border_details']['L']['style'] = '';
$cell['border_details']['T']['style'] = '';
$cell['border_details']['B']['style'] = '';
$cell['border_details']['R']['s'] = 0;
$cell['border_details']['L']['s'] = 0;
$cell['border_details']['T']['s'] = 0;
$cell['border_details']['B']['s'] = 0;
$cell['border_details']['R']['c'] = array('R'=>0, 'G'=>0, 'B'=>0);
$cell['border_details']['L']['c'] = array('R'=>0, 'G'=>0, 'B'=>0);
$cell['border_details']['T']['c'] = array('R'=>0, 'G'=>0, 'B'=>0);
$cell['border_details']['B']['c'] = array('R'=>0, 'G'=>0, 'B'=>0);
$cell['border_details']['R']['dom'] = 0;
$cell['border_details']['L']['dom'] = 0;
$cell['border_details']['T']['dom'] = 0;
$cell['border_details']['B']['dom'] = 0;
}
// INHERITED TABLE PROPERTIES (or ROW for BGCOLOR)
// If cell bgcolor not set specifically, set to TR row bgcolor (if set)
// mPDF 4.3.006
if ((!$cell['bgcolor']) && isset($table['bgcolor'][$this->row])) {
$cell['bgcolor'] = $table['bgcolor'][$this->row];
}
else if (isset($table['bgcolor'][-1])) {
$cell['bgcolor'] = $table['bgcolor'][-1];
}
if ($table['va']) { $cell['va'] = $table['va']; }
if ($table['txta']) { $cell['a'] = $table['txta']; }
if ($this->table_border_attr_set) {
if ($table['border_details']) {
if (!$this->simpleTables){ // mPDF 4.2.017
$cell['border_details']['R'] = $table['border_details']['R'];
$cell['border_details']['L'] = $table['border_details']['L'];
$cell['border_details']['T'] = $table['border_details']['T'];
$cell['border_details']['B'] = $table['border_details']['B'];
$cell['border'] = $table['border'];
$cell['border_details']['L']['dom'] = 1;
$cell['border_details']['R']['dom'] = 1;
$cell['border_details']['T']['dom'] = 1;
$cell['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) $cell['va'] = $align[strtolower($this->thead_valign_default)];
if ($this->thead_textalign_default) $cell['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); }
}
// INHERITED TFOOT CSS Properties
if ($this->tabletfoot) {
if ($this->tfoot_valign_default) $cell['va'] = $align[strtolower($this->tfoot_valign_default)];
if ($this->tfoot_textalign_default) $cell['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->trow_text_rotate){ // mPDF 4.3.006
$cell['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);
// mPDF 4.3.006
if (isset($properties['BACKGROUND-COLOR'])) { $cell['bgcolor'] = $properties['BACKGROUND-COLOR']; }
else if (isset($properties['BACKGROUND'])) { $cell['bgcolor'] = $properties['BACKGROUND']; }
/*-- GRADIENTS --*/
// mPDF 4.3.006
if (isset($properties['BACKGROUND-GRADIENT'])) { $cell['gradient'] = $properties['BACKGROUND-GRADIENT']; }
else { $cell['gradient'] = false; }
/*-- END GRADIENTS --*/
/*-- BACKGROUND-IMAGES --*/
// mPDF 4.3.006 / 4.3.011
if (isset($properties['BACKGROUND-IMAGE']) && $properties['BACKGROUND-IMAGE'] && !$this->ColActive && !$this->keep_block_together) {
$file = $properties['BACKGROUND-IMAGE'];
$sizesarray = $this->Image($file,0,0,0,0,'','',false, false, false, false, false); // mPDF 4.3.012D
if (isset($sizesarray['IMAGE_ID'])) {
$image_id = $sizesarray['IMAGE_ID'];
$orig_w = $sizesarray['WIDTH']*$this->k; // in user units i.e. mm
$orig_h = $sizesarray['HEIGHT']*$this->k; // (using $this->img_dpi)
$x_repeat = true;
$y_repeat = true;
if (isset($properties['BACKGROUND-REPEAT'])) {
if ($properties['BACKGROUND-REPEAT']=='no-repeat' || $properties['BACKGROUND-REPEAT']=='repeat-x') { $y_repeat = false; }
if ($properties['BACKGROUND-REPEAT']=='no-repeat' || $properties['BACKGROUND-REPEAT']=='repeat-y') { $x_repeat = false; }
}
$x_pos = 0;
$y_pos = 0;
if (isset($properties['BACKGROUND-POSITION'])) {
$ppos = preg_split('/\s+/',$properties['BACKGROUND-POSITION']);
$x_pos = $ppos[0];
$y_pos = $ppos[1];
if (!stristr($x_pos ,'%') ) { $x_pos = $this->ConvertSize($x_pos ,$this->blk[$this->blklvl]['inner_width'],$this->FontSize); }
if (!stristr($y_pos ,'%') ) { $y_pos = $this->ConvertSize($y_pos ,$this->blk[$this->blklvl]['inner_width'],$this->FontSize); }
}
// mPDF 4.3.015
if (isset($properties['BACKGROUND-IMAGE-RESIZE'])) { $resize = $properties['BACKGROUND-IMAGE-RESIZE']; }
else { $resize = 0; }
// mPDF 4.3.017
if (isset($properties['BACKGROUND-IMAGE-OPACITY'])) { $opacity = $properties['BACKGROUND-IMAGE-OPACITY']; }
else { $opacity = 0; }
$cell['background-image'] = array('image_id'=>$image_id, 'orig_w'=>$orig_w, 'orig_h'=>$orig_h, 'x_pos'=>$x_pos, 'y_pos'=>$y_pos, 'x_repeat'=>$x_repeat, 'y_repeat'=>$y_repeat, 'resize'=>$resize, 'opacity'=>$opacity); // mPDF 4.3.015 mPDF 4.3.017
}
}
/*-- END BACKGROUND-IMAGES --*/
if (isset($properties['VERTICAL-ALIGN'])) { $cell['va']=$align[strtolower($properties['VERTICAL-ALIGN'])]; }
if (isset($properties['TEXT-ALIGN'])) { $cell['a'] = $align[strtolower($properties['TEXT-ALIGN'])]; }
if (isset($properties['TEXT-ROTATE']) && $properties['TEXT-ROTATE']){ // mPDF 4.3.006
$cell['R'] = $properties['TEXT-ROTATE'];
}
if (isset($properties['BORDER'])) {
$bord = $this->border_details($properties['BORDER']);
if ($bord['s']) {
if (!$this->simpleTables){ // mPDF 4.2.017
$cell['border'] = _BORDER_ALL;
$cell['border_details']['R'] = $bord;
$cell['border_details']['L'] = $bord;
$cell['border_details']['T'] = $bord;
$cell['border_details']['B'] = $bord;
$cell['border_details']['L']['dom'] = $this->cell_border_dominance_L;
$cell['border_details']['R']['dom'] = $this->cell_border_dominance_R;
$cell['border_details']['T']['dom'] = $this->cell_border_dominance_T;
$cell['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){ // mPDF 4.2.017
if (isset($properties['BORDER-RIGHT']) && $properties['BORDER-RIGHT']) {
$cell['border_details']['R'] = $this->border_details($properties['BORDER-RIGHT']);
$this->setBorder($cell['border'], _BORDER_RIGHT, $cell['border_details']['R']['s']);
$cell['border_details']['R']['dom'] = $this->cell_border_dominance_R;
}
if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
$cell['border_details']['L'] = $this->border_details($properties['BORDER-LEFT']);
$this->setBorder($cell['border'], _BORDER_LEFT, $cell['border_details']['L']['s']);
$cell['border_details']['L']['dom'] = $this->cell_border_dominance_L;
}
if (isset($properties['BORDER-BOTTOM']) && $properties['BORDER-BOTTOM']) {
$cell['border_details']['B'] = $this->border_details($properties['BORDER-BOTTOM']);
$this->setBorder($cell['border'], _BORDER_BOTTOM, $cell['border_details']['B']['s']);
$cell['border_details']['B']['dom'] = $this->cell_border_dominance_B;
}
if (isset($properties['BORDER-TOP']) && $properties['BORDER-TOP']) {
$cell['border_details']['T'] = $this->border_details($properties['BORDER-TOP']);
$this->setBorder($cell['border'], _BORDER_TOP, $cell['border_details']['T']['s']);
$cell['border_details']['T']['dom'] = $this->cell_border_dominance_T;
}
}
else if ($this->simpleTables && $this->row==0 && $this->col==0){
if (isset($properties['BORDER-LEFT']) && $properties['BORDER-LEFT']) {
$bord = $this->border_details($properties['BORDER-LEFT']);
if ($bord['s']) { $table['simple']['border'] = _BORDER_ALL; }
else { $table['simple']['border'] = 0; }
$table['simple']['border_details']['R'] = $bord;
$table['simple']['border_details']['L'] = $bord;
$table['simple']['border_details']['T'] = $bord;
$table['simple']['border_details']['B'] = $bord;
}
}
if ($this->simpleTables && $this->row==0 && $this->col==0 && !$table['borders_separate']){ // mPDF 4.2.017
$table['border_details'] = $table['simple']['border_details'];
$table['border'] = $table['simple']['border'];
}
// mPDF 4.3.009 Binary packed data
if ($this->packTableData && !$this->simpleTables) {
$cell['borderbin'] = $this->_packCellBorder($cell);
unset($cell['border']);
unset($cell['border_details']);
}
// mPDF 4.3.006
if (isset($properties['PADDING-LEFT'])) {
$cell['padding']['L'] = $this->ConvertSize($properties['PADDING-LEFT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
}
if (isset($properties['PADDING-RIGHT'])) {
$cell['padding']['R'] = $this->ConvertSize($properties['PADDING-RIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
}
if (isset($properties['PADDING-BOTTOM'])) {
$cell['padding']['B'] = $this->ConvertSize($properties['PADDING-BOTTOM'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
}
if (isset($properties['PADDING-TOP'])) {
$cell['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 ) { $cell['wpercent'] = $w + 0; } // makes 80% -> 80
else if (!strpos($w,'%') && !$this->ignore_table_widths ) { $cell['w'] = $this->ConvertSize($w,$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
}
// mPDF 4.0
if (isset($properties['HEIGHT'])) { $cell['h'] = $this->ConvertSize($properties['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false); }
if (isset($properties['COLOR'])) {
$cor = $this->ConvertColor($properties['COLOR']);
if ($cor) {
$this->colorarray = $cor;
$this->SetTextColor($cor['R'],$cor['G'],$cor['B']);
$this->issetcolor=true;
}
}
if (isset($properties['FONT-FAMILY'])) {
if (!$this->isCJK) {
$this->SetFont($properties['FONT-FAMILY'],'',0,false);
}
}
if (isset($properties['FONT-SIZE'])) {
$mmsize = $this->ConvertSize($properties['FONT-SIZE'],$this->default_font_size/$this->k);
if ($mmsize) {
$this->SetFontSize($mmsize*($this->k),false);
}
}
// mPDF 4.2
$cell['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['WHITE-SPACE'])) {
if (strtoupper($properties['WHITE-SPACE']) == 'NOWRAP') { $cell['nowrap']= 1; }
}
$properties = array();
if (isset($attr['HEIGHT'])) $cell['h'] = $this->ConvertSize($attr['HEIGHT'],$this->blk[$this->blklvl]['inner_width'],$this->FontSize,false);
if (isset($attr['ALIGN'])) $cell['a'] = $align[strtolower($attr['ALIGN'])];
if (isset($attr['VALIGN'])) $cell['va'] = $align[strtolower($attr['VALIGN'])];
// mPDF 4.3.006
if (isset($attr['BGCOLOR'])) $cell['bgcolor'] = $attr['BGCOLOR'];
$cs = $rs = 1;
if (isset($attr['COLSPAN']) && $attr['COLSPAN']>1) $cs = $cell['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;
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 = $cell['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;
}
}
if (isset($attr['TEXT-ROTATE'])) { // mPDF 4.3.006
$cell['R'] = $attr['TEXT-ROTATE'];
}
if (isset($attr['NOWRAP']) && $attr['NOWRAP']) $cell['nowrap']= 1;
unset($cell );
break;
/*-- END TABLES --*/
/*-- LISTS --*/
// *********** LISTS ********************
case 'OL':
case 'UL':
$this->listjustfinished = false;
// mPDF 4.2
if ($this->blockjustfinished && !count($this->textbuffer) && $this->y != $this->tMargin && $this->collapseBlockMargins) { $lastbottommargin = $this->lastblockbottommargin; }
else { $lastbottommargin = 0; }
$this->lastblockbottommargin = 0;
$this->blockjustfinished=false;
// mPDF 3.0
$this->linebreakjustfinished=false;
$this->lastoptionaltag = ''; // Save current HTML specified optional endtag
$this->listCSSlvl++;
if((!$this->tableLevel) && ($this->listlvl == 0)) {
// mPDF 4.2
$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); // true = newblock
$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 --*/
// mPDF 4.2.018
if ($this->PDFA && $tag == 'UL') {
if (!$this->PDFAauto) { $this->PDFAwarnings[] = "List bullets cannot use core font Zapfdingbats in PDFA1-b. (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,'INLINE');
// List-type
// mPDF 4.0
$this->listtype = '';
if (isset($attr['TYPE']) && $attr['TYPE']) { $this->listtype = $attr['TYPE']; }
else if (isset($properties['LIST-STYLE-TYPE'])) {
// mPDF 4.0
$this->listtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
}
else if (isset($properties['LIST-STYLE'])) {
// mPDF 4.0
$this->listtype = $this->_getListStyle($properties['LIST-STYLE']);
}
if (!$this->listtype) {
if ($tag == 'OL') $this->listtype = '1';
if ($tag == 'UL') {
// mPDF 4.0
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
$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
// mPDF 3.0
if (!isset($this->listoccur[$this->listlvl]) || $this->listoccur[$this->listlvl] == 0) $this->listoccur[$this->listlvl] = 1;
else $this->listoccur[$this->listlvl]++;
$occur = $this->listoccur[$this->listlvl];
$this->listlist[$this->listlvl][$occur] = array('TYPE'=>$this->listtype,'MAXNUM'=>$this->listnum);
}
// TOP LEVEL ONLY
if ($this->listlvl == 1) {
if (isset($properties['MARGIN-TOP'])) {
// mPDF 4.2 Collaspe vertical block margins
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);
}
// mPDF 4.0
if (isset($this->blk[$this->blklvl]['line_height'])) {
$this->list_lineheight[$this->listlvl][$occur] = $this->blk[$this->blklvl]['line_height'];
}
}
$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'])]; }
// mPDF 4.0
if (isset($properties['LINE-HEIGHT'])) {
$this->list_lineheight[$this->listlvl][$occur] = $this->fixLineheight($properties['LINE-HEIGHT']);
}
// mPDF 4.2 Inherit
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; // mPDF 4.2
}
$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->cell[$this->row][$this->col]['textbuffer'][] = array("\n",$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['text'][] = "\n";
if (!isset($this->cell[$this->row][$this->col]['maxs'])) {
$this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
}
elseif($this->cell[$this->row][$this->col]['maxs'] < $this->cell[$this->row][$this->col]['s']) {
$this->cell[$this->row][$this->col]['maxs'] = $this->cell[$this->row][$this->col]['s'];
}
$this->cell[$this->row][$this->col]['s'] = 0 ;
}
if ($this->listlvl == 0) { //in case of malformed HTML code. Example:(...)- Content
Paragraph1
(...)
$this->listlvl++; // first depth level
$this->listnum = 0; // reset
$this->listlist[$this->listlvl] = array('TYPE'=>'disc','MAXNUM'=>$this->listnum);
}
$this->listnum++;
switch($this->listlist[$this->listlvl]['TYPE']) {
case 'A':
$blt = $this->dec2alpha($this->listnum,true).$this->list_number_suffix;
break;
case 'a':
$blt = $this->dec2alpha($this->listnum,false).$this->list_number_suffix;
break;
case 'I':
$blt = $this->dec2roman($this->listnum,true).$this->list_number_suffix;
break;
case 'i':
$blt = $this->dec2roman($this->listnum,false).$this->list_number_suffix;
break;
case '1':
$blt = $this->listnum.$this->list_number_suffix;
break;
default:
// mPDF 4.2
if ($this->listlvl % 3 == 1 && isset($this->CurrentFont['cw'][8226])) { $blt = "\xe2\x80\xa2"; } // •
else if ($this->listlvl % 3 == 2 && isset($this->CurrentFont['cw'][9900])) { $blt = "\xe2\x9a\xac"; } // ⚬
else if ($this->listlvl % 3 == 0 && isset($this->CurrentFont['cw'][9642])) { $blt = "\xe2\x96\xaa"; } // ▪
else { $blt = '-'; }
break;
}
/*-- UNICODE-FONTS --*/
// mPDF 3.0 - change to spaces
if ($this->is_MB) {
$ls = str_repeat("\xc2\xa0\xc2\xa0",($this->listlvl-1)*2) . $blt . ' ';
}
else {
/*-- END UNICODE-FONTS --*/
$ls = str_repeat(chr(160).chr(160),($this->listlvl-1)*2) . $blt . ' ';
/*-- UNICODE-FONTS --*/
}
/*-- END UNICODE-FONTS --*/
$this->cell[$this->row][$this->col]['textbuffer'][] = array($ls,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['text'][] = $ls;
$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)) {
$this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
$this->listnum++;
}
$this->textbuffer = array();
}
$this->listCSSlvl++;
$properties = $this->MergeCSS('LIST',$tag,$attr);
if (!empty($properties)) $this->setCSS($properties,'INLINE');
$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'])) {
// mPDF 4.0
$this->listitemtype = $this->_getListStyle($properties['LIST-STYLE-TYPE']);
}
else if (isset($properties['LIST-STYLE'])) {
// mPDF 4.0
$this->listitemtype = $this->_getListStyle($properties['LIST-STYLE']);
}
else $this->listitemtype = '';
break;
/*-- END LISTS --*/
}//end of switch
}
/*-- LISTS --*/
// mPDF 4.0
function _getListStyle($ls) {
if (stristr($ls,'disc')) { return 'disc'; }
else if (stristr($ls,'circle')) { return 'circle'; }
else if (stristr($ls,'square')) { return 'square'; }
else if (stristr($ls,'decimal')) { return '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 { 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']; }
$w = $this->GetStringWidth($texto);
if ($w == 0) { $w = 5; }
$objattr['type'] = 'select'; // need to add into objattr
$objattr['text'] = $texto;
// mPDD 1.4 Active Forms
if (isset($this->selectoption['NAME'])) { $objattr['name'] = $this->selectoption['NAME']; }
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_element_spacing['select']['outer']['h']*2)+($this->form_element_spacing['select']['inner']['h']*2) + ($this->FontSize*1.4);
$objattr['height'] = ($this->FontSize*$rows) + ($this->form_element_spacing['select']['outer']['v']*2)+($this->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->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle); // *TABLES*
$this->cell[$this->row][$this->col]['s'] += $objattr['width'] ; // *TABLES*
} // *TABLES*
else { // *TABLES*
$this->textbuffer[] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
} // *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' ) {
$this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
$this->blockjustfinished=true;
// mPDF 4.2
$this->lastblockbottommargin = $this->blk[$this->blklvl]['margin_bottom'];
/*-- LISTS --*/
// mPDF 4.0
if ($this->listlvl>0) { return; }
/*-- END LISTS --*/
/*-- TABLES --*/
if($this->tableLevel) {
// mPDF 3.0
if ($this->linebreakjustfinished) { $this->blockjustfinished=false; }
// mPDF 4.0
if (isset($this->InlineProperties['BLOCKINTABLE'])) {
if ($this->InlineProperties['BLOCKINTABLE']) { $this->restoreInlineProperties($this->InlineProperties['BLOCKINTABLE']); }
unset($this->InlineProperties['BLOCKINTABLE']);
}
return;
}
/*-- END TABLES --*/
$this->lastoptionaltag = '';
$this->divbegin=false;
// mPDF 3.0
$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; } // mPDF 3.0
// called from after e.g.
... Outputs block margin/border and padding
if (count($this->textbuffer) && $this->textbuffer[count($this->textbuffer)-1]) {
// mPDF 3.0 ...as long as not special content
if (substr($this->textbuffer[count($this->textbuffer)-1][0],0,3) != "\xbb\xa4\xac") { // not special content
if ($this->is_MB) { // *UNICODE-FONTS*
$this->textbuffer[count($this->textbuffer)-1][0] = preg_replace('/[ ]+$/u', '', $this->textbuffer[count($this->textbuffer)-1][0]); // *UNICODE-FONTS*
} // *UNICODE-FONTS*
else { // *UNICODE-FONTS*
$this->textbuffer[count($this->textbuffer)-1][0] = preg_replace('/[ ]+$/', '', $this->textbuffer[count($this->textbuffer)-1][0]);
} // *UNICODE-FONTS*
}
}
if (count($this->textbuffer) == 0 && $this->lastblocklevelchange != 0) {
$this->newFlowingBlock( $this->blk[$this->blklvl]['width'],$this->lineheight,'',false,false,2,true); // true = newblock
$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 --*/
//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'];
}
/*-- 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--;
$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'])) {
$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; }
// mPDF 3.0 ... but only the last one
if ($ntb>1 && $this->cell[$this->row][$this->col]['textbuffer'][$ntb-1][0] == "\n") {
unset($this->cell[$this->row][$this->col]['textbuffer'][$ntb-1]);
}
if ($this->tablethead) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_thead'][$this->row] = true; }
// mPDF 3.0
if ($this->usetableheader && ($this->row == 0 || $this->tablethead) && $this->tableLevel==1) {
$this->tableheadernrows = max($this->tableheadernrows, ($this->row+1));
}
// mPDF 4.0
if ($this->tabletfoot) { $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$this->row] = true; }
if ($this->tabletfoot && $this->tableLevel==1) {
$this->tablefooternrows = max($this->tablefooternrows, ($this->row+1 - $this->tableheadernrows));
}
$this->Reset();
}
if($tag=='TR' && $this->tableLevel) {
$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->thead_font_weight = '';
$this->SetStyle('B',false);
$this->thead_font_style = '';
$this->SetStyle('I',false);
$this->thead_valign_default = '';
$this->thead_textalign_default = '';
}
if($tag=='TFOOT') {
$this->lastoptionaltag = '';
unset($this->tablecascadeCSS[$this->tbCSSlvl]);
$this->tbCSSlvl--;
$this->tabletfoot = 0; // mPDF 4.0
$this->tfoot_font_weight = '';
$this->SetStyle('B',false);
$this->tfoot_font_style = '';
$this->SetStyle('I',false);
$this->tfoot_valign_default = '';
$this->tfoot_textalign_default = '';
}
if($tag=='TABLE') { // TABLE-END (
$this->tctr++;
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);
// mPDF 4.0 Move TABLE FOOTER TFOOT to end of table
if (isset($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot']) && count($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'])) {
$tfrows = array();
foreach($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'] AS $r=>$val) {
if ($val) { $tfrows[] = $r; }
}
$temp = array();
$temptf = array();
foreach($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] AS $k=>$row) {
if (in_array($k,$tfrows)) {
$temptf[] = $row;
}
else {
$temp[] = $row;
}
}
$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'] = array();
for($i=count($temp) ; $i<(count($temp)+count($temptf)); $i++) {
$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['is_tfoot'][$i] = true;
}
// Update nestedpos row references
if (count($this->table[($this->tableLevel+1)])) {
foreach($this->table[($this->tableLevel+1)] AS $nid=>$nested) {
$this->table[($this->tableLevel+1)][$nid]['nestedpos'][0] -= count($temptf);
}
}
$this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'] = array_merge($temp, $temptf);
}
// Fix Borders *********************************************
$this->_fixTableBorders($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]);
if ($this->progressBar) { $this->UpdateProgressBar(7,10,' '); } // *PROGRESS-BAR*
if ($this->ColActive) { $this->table_rotate = 0; } // *COLUMNS*
if ($this->table_rotate <> 0) {
$this->tablebuffer = array();
// Max width for rotated table
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5);
$this->tbrot_maxh = $this->blk[$this->blklvl]['inner_width'] ; // Max width for rotated table
$this->tbrot_align = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['a'] ;
}
$this->shrin_k = 1;
// mPDF 4.2
if ($this->shrink_tables_to_fit < 1) { $this->shrink_tables_to_fit = 1; }
if (!$this->shrink_this_table_to_fit) { $this->shrink_this_table_to_fit = $this->shrink_tables_to_fit; }
if ($this->tableLevel>1) {
// deal with nested table
$this->_tableColumnWidth($this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]],true);
$tmiw = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['miw'];
$tmaw = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['maw'];
$tl = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['tl'];
// Go down to lower table level
$this->tableLevel--;
// Reset lower level table
$this->base_table_properties = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['baseProperties'];
$this->cell = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['cells'];
$this->row = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['currrow'];
$this->col = $this->table[$this->tableLevel][$this->tbctr[$this->tableLevel]]['currcol'];
$objattr['type'] = 'nestedtable';
$objattr['nestedcontent'] = $this->tbctr[($this->tableLevel+1)];
$objattr['table'] = $this->tbctr[$this->tableLevel];
$objattr['row'] = $this->row;
$objattr['col'] = $this->col;
$objattr['level'] = $this->tableLevel;
$e = "\xbb\xa4\xactype=nestedtable,objattr=".serialize($objattr)."\xbb\xa4\xac";
$this->cell[$this->row][$this->col]['textbuffer'][] = array($e,$this->HREF,$this->currentfontstyle,$this->colorarray,$this->currentfontfamily,$this->SUP,$this->SUB,'',$this->strike,$this->outlineparam,$this->spanbgcolorarray,$this->currentfontsize,$this->ReqFontStyle);
$this->cell[$this->row][$this->col]['s'] += $tl ;
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
if ((isset($this->cell[$this->row][$this->col]['nestedmaw']) && $this->cell[$this->row][$this->col]['nestedmaw'] < $tmaw) || !isset($this->cell[$this->row][$this->col]['nestedmaw'])) { $this->cell[$this->row][$this->col]['nestedmaw'] = $tmaw ; }
if ((isset($this->cell[$this->row][$this->col]['nestedmiw']) && $this->cell[$this->row][$this->col]['nestedmiw'] < $tmiw) || !isset($this->cell[$this->row][$this->col]['nestedmiw'])) { $this->cell[$this->row][$this->col]['nestedmiw'] = $tmiw ; }
$this->cell[$this->row][$this->col]['nestedcontent'][] = $this->tbctr[($this->tableLevel+1)];
$this->tdbegin = true;
$this->nestedtablejustfinished = true;
$this->ignorefollowingspaces = true;
return;
}
$this->cMarginL = 0;
$this->cMarginR = 0;
$this->cMarginT = 0;
$this->cMarginB = 0;
$this->cellPaddingL = 0;
$this->cellPaddingR = 0;
$this->cellPaddingT = 0;
$this->cellPaddingB = 0;
if (!$this->kwt_saved) { $this->kwt_height = 0; }
list($check,$tablemiw) = $this->_tableColumnWidth($this->table[1][1],true);
$save_table = $this->table;
$reset_to_minimum_width = false;
$added_page = false;
if ($check > 1) {
if ($check > $this->shrink_this_table_to_fit && $this->table_rotate) {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
// mPDF 3.0
//$check = $tablemiw/$this->tbrot_maxw; // undo any shrink
$check = 1; // undo any shrink
}
$reset_to_minimum_width = true;
}
if ($reset_to_minimum_width) {
$this->shrin_k = $check;
$this->default_font_size /= $this->shrin_k;
$this->SetFontSize($this->default_font_size, false );
$this->shrinkTable($this->table[1][1],$this->shrin_k);
$this->_tableColumnWidth($this->table[1][1],false); // repeat
// Starting at $this->innermostTableLevel
// Shrink table values - and redo columnWidth
for($lvl=2;$lvl<=$this->innermostTableLevel;$lvl++) {
for ($nid=1; $nid<=$this->tbctr[$lvl]; $nid++) {
$this->shrinkTable($this->table[$lvl][$nid],$this->shrin_k);
$this->_tableColumnWidth($this->table[$lvl][$nid],false);
}
}
}
// Set table cell widths for top level table
// Use $shrin_k to resize but don't change again
$this->SetLineHeight('',$this->table_lineheight);
// Top level table
$this->_tableWidth($this->table[1][1]);
// Now work through any nested tables setting child table[w'] = parent cell['w']
// Now do nested tables _tableWidth
for($lvl=2;$lvl<=$this->innermostTableLevel;$lvl++) {
for ($nid=1; $nid<=$this->tbctr[$lvl]; $nid++) {
// HERE set child table width = cell width
list($parentrow, $parentcol, $parentnid) = $this->table[$lvl][$nid]['nestedpos'];
if (isset($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['colspan']) && $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['colspan']> 1) {
$parentwidth = 0;
for($cs=0;$cs<$this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['colspan'] ; $cs++) {
$parentwidth += $this->table[($lvl-1)][$parentnid]['wc'][$parentcol+$cs];
}
}
else { $parentwidth = $this->table[($lvl-1)][$parentnid]['wc'][$parentcol]; }
//$parentwidth -= ALLOW FOR PADDING ETC.in parent cell
// mPDF 4.3.006
if (!$this->simpleTables){ // mPDF 4.2.017
// mPDF 4.3.009
if ($this->packTableData) {
list($bt,$br,$bb,$bl) = $this->_getBorderWidths($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['borderbin']);
}
else {
$br = $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['border_details']['R']['w'];
$bl = $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['border_details']['L']['w'];
}
if ($this->table[$lvl-1][$parentnid]['borders_separate']) {
$parentwidth -= $br + $bl
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R']
+ $this->table[($lvl-1)][$parentnid]['border_spacing_H'];
}
else {
$parentwidth -= $br/2 + $bl/2
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R'];
}
}
else if ($this->simpleTables){
if ($this->table[$lvl-1][$parentnid]['borders_separate']) {
$parentwidth -= $this->table[($lvl-1)][$parentnid]['simple']['border_details']['L']['w']
+ $this->table[($lvl-1)][$parentnid]['simple']['border_details']['R']['w']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R']
+ $this->table[($lvl-1)][$parentnid]['border_spacing_H'];
}
else {
$parentwidth -= $this->table[($lvl-1)][$parentnid]['simple']['border_details']['L']['w']/2
+ $this->table[($lvl-1)][$parentnid]['simple']['border_details']['R']['w']/2
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R'];
}
}
if (isset($this->table[$lvl][$nid]['wpercent']) && $this->table[$lvl][$nid]['wpercent'] && $lvl>1) {
$this->table[$lvl][$nid]['w'] = $parentwidth;
}
else if ($parentwidth > $this->table[$lvl][$nid]['maw']) {
$this->table[$lvl][$nid]['w'] = $this->table[$lvl][$nid]['maw'];
}
else {
$this->table[$lvl][$nid]['w'] = $parentwidth;
}
$this->_tableWidth($this->table[$lvl][$nid]);
}
}
// Starting at $this->innermostTableLevel
// Cascade back up nested tables: setting heights back up the tree
for($lvl=$this->innermostTableLevel;$lvl>0;$lvl--) {
for ($nid=1; $nid<=$this->tbctr[$lvl]; $nid++) {
list($tableheight,$maxrowheight,$fullpage,$remainingpage) = $this->_tableHeight($this->table[$lvl][$nid]);
}
}
if ($this->progressBar) { $this->UpdateProgressBar(7,20,' '); } // *PROGRESS-BAR*
$recalculate = 1;
$forcerecalc = false; // mPDF 4.2.005
// RESIZING ALGORITHM
if ($maxrowheight > $fullpage) {
$recalculate = $this->tbsqrt($maxrowheight / $fullpage, 1);
$forcerecalc = true; // mPDF 4.2.005
}
else if ($this->table_rotate) { // NB $remainingpage == $fullpage == the width of the page
if ($tableheight > $remainingpage) {
// If can fit on remainder of page whilst respecting autsize value..
if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, 1)) <= $this->shrink_this_table_to_fit) {
$recalculate = $this->tbsqrt($tableheight / $remainingpage, 1);
}
else if (!$added_page) {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
// mPDF 3.0 added 0.001 to force it to recalculate
$recalculate = (1 / $this->shrin_k) + 0.001; // undo any shrink
}
}
}
else if ($this->table_keep_together) {
if ($tableheight > $fullpage) {
if (($this->shrin_k * $this->tbsqrt($tableheight / $fullpage, 1)) <= $this->shrink_this_table_to_fit) {
$recalculate = $this->tbsqrt($tableheight / $fullpage, 1);
}
else if ($this->tableMinSizePriority) { // mPDF 4.5.006
$this->table_keep_together = false;
$recalculate = 1.001;
}
else {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
$recalculate = $this->tbsqrt($tableheight / $fullpage, 1);
}
}
else if ($tableheight > $remainingpage) {
// If can fit on remainder of page whilst respecting autsize value..
if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, 1)) <= $this->shrink_this_table_to_fit) {
$recalculate = $this->tbsqrt($tableheight / $remainingpage, 1);
}
else {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
// mPDF 3.0 added 0.001 to force it to recalculate
$recalculate = (1 / $this->shrin_k) + 0.001; // undo any shrink
}
}
}
else { $recalculate = 1; }
if ($recalculate > $this->shrink_this_table_to_fit && !$forcerecalc) { $recalculate = $this->shrink_this_table_to_fit; } // mPDF 4.2.005
$iteration = 1; // mPDF 4.5.006
// RECALCULATE
while($recalculate <> 1) {
$this->shrin_k1 = $recalculate ;
$this->shrin_k *= $recalculate ;
$this->default_font_size /= ($this->shrin_k1) ;
$this->SetFontSize($this->default_font_size, false );
$this->SetLineHeight('',$this->table_lineheight);
$this->table = $save_table;
if ($this->shrin_k <> 1) { $this->shrinkTable($this->table[1][1],$this->shrin_k); }
$this->_tableColumnWidth($this->table[1][1],false); // repeat
// Starting at $this->innermostTableLevel
// Shrink table values - and redo columnWidth
for($lvl=2;$lvl<=$this->innermostTableLevel;$lvl++) {
for ($nid=1; $nid<=$this->tbctr[$lvl]; $nid++) {
if ($this->shrin_k <> 1) { $this->shrinkTable($this->table[$lvl][$nid],$this->shrin_k); }
$this->_tableColumnWidth($this->table[$lvl][$nid],false);
}
}
// Set table cell widths for top level table
// Top level table
$this->_tableWidth($this->table[1][1]);
// Now work through any nested tables setting child table[w'] = parent cell['w']
// Now do nested tables _tableWidth
for($lvl=2;$lvl<=$this->innermostTableLevel;$lvl++) {
for ($nid=1; $nid<=$this->tbctr[$lvl]; $nid++) {
// HERE set child table width = cell width
list($parentrow, $parentcol, $parentnid) = $this->table[$lvl][$nid]['nestedpos'];
if (isset($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['colspan']) && $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['colspan']> 1) {
$parentwidth = 0;
for($cs=0;$cs<$this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['colspan'] ; $cs++) {
$parentwidth += $this->table[($lvl-1)][$parentnid]['wc'][$parentcol+$cs];
}
}
else { $parentwidth = $this->table[($lvl-1)][$parentnid]['wc'][$parentcol]; }
//$parentwidth -= ALLOW FOR PADDING ETC.in parent cell
// mPDF 4.3.006
if (!$this->simpleTables){ // mPDF 4.2.017
// mPDF 4.3.009
if ($this->packTableData) {
list($bt,$br,$bb,$bl) = $this->_getBorderWidths($this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['borderbin']);
}
else {
$br = $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['border_details']['R']['w'];
$bl = $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['border_details']['L']['w'];
}
if ($this->table[$lvl-1][$parentnid]['borders_separate']) {
$parentwidth -= $br + $bl
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R']
+ $this->table[($lvl-1)][$parentnid]['border_spacing_H'];
}
else {
$parentwidth -= $br/2 + $bl/2
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R'];
}
}
else if ($this->simpleTables){
if ($this->table[$lvl-1][$parentnid]['borders_separate']) {
$parentwidth -= $this->table[($lvl-1)][$parentnid]['simple']['border_details']['L']['w']
+ $this->table[($lvl-1)][$parentnid]['simple']['border_details']['R']['w']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R']
+ $this->table[($lvl-1)][$parentnid]['border_spacing_H'];
}
else {
$parentwidth -= ($this->table[($lvl-1)][$parentnid]['simple']['border_details']['L']['w']
+ $this->table[($lvl-1)][$parentnid]['simple']['border_details']['R']['w']) /2
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['L']
+ $this->table[($lvl-1)][$parentnid]['cells'][$parentrow][$parentcol]['padding']['R'];
}
}
if (isset($this->table[$lvl][$nid]['wpercent']) && $this->table[$lvl][$nid]['wpercent'] && $lvl>1) {
$this->table[$lvl][$nid]['w'] = $parentwidth;
}
else if ($parentwidth > $this->table[$lvl][$nid]['maw']) {
$this->table[$lvl][$nid]['w'] = $this->table[$lvl][$nid]['maw'] ;
}
else {
$this->table[$lvl][$nid]['w'] = $parentwidth;
}
$this->_tableWidth($this->table[$lvl][$nid]);
}
}
// Starting at $this->innermostTableLevel
// Cascade back up nested tables: setting heights back up the tree
for($lvl=$this->innermostTableLevel;$lvl>0;$lvl--) {
for ($nid=1; $nid<=$this->tbctr[$lvl]; $nid++) {
list($tableheight,$maxrowheight,$fullpage,$remainingpage) = $this->_tableHeight($this->table[$lvl][$nid]);
}
}
// RESIZING ALGORITHM
if ($maxrowheight > $fullpage) { $recalculate = $this->tbsqrt($maxrowheight / $fullpage, $iteration); $iteration++; }
else if ($this->table_rotate && $tableheight > $remainingpage && !$added_page) {
// If can fit on remainder of page whilst respecting autosize value..
if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->shrink_this_table_to_fit) {
$recalculate = $this->tbsqrt($tableheight / $remainingpage, $iteration); $iteration++;
}
else {
if (!$added_page) {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
}
// mPDF 3.0 added 0.001 to force it to recalculate
$recalculate = (1 / $this->shrin_k) + 0.001; // undo any shrink
}
}
else if ($this->table_keep_together) {
if ($tableheight > $fullpage) {
if (($this->shrin_k * $this->tbsqrt($tableheight / $fullpage, $iteration)) <= $this->shrink_this_table_to_fit) {
$recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
}
else if ($this->tableMinSizePriority) { // mPDF 4.5.006
$this->table_keep_together = false;
$recalculate = (1 / $this->shrin_k) + 0.001;
}
else {
if (!$added_page) {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
}
$recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
}
}
else if ($tableheight > $remainingpage) {
// If can fit on remainder of page whilst respecting autosize value..
if (($this->shrin_k * $this->tbsqrt($tableheight / $remainingpage, $iteration)) <= $this->shrink_this_table_to_fit) {
$recalculate = $this->tbsqrt($tableheight / $remainingpage, $iteration); $iteration++;
}
else {
if (!$added_page) {
$this->AddPage($this->CurOrientation);
$added_page = true;
$this->kwt_moved = true;
$this->tbrot_maxw = $this->h - ($this->y + $this->bMargin + 5) - $this->kwt_height;
}
// mPDF 4.0
//$recalculate = $this->tbsqrt($tableheight / $fullpage, $iteration); $iteration++;
$recalculate = (1 / $this->shrin_k) + 0.001; // undo any shrink
}
}
else { $recalculate = 1; }
}
else { $recalculate = 1; }
}
// keep-with-table: if page has advanced, print out buffer now, else done in fn. _Tablewrite()
if ($this->kwt_saved && $this->kwt_moved) {
$this->printkwtbuffer();
$this->kwt_moved = false;
$this->kwt_saved = false;
}
if ($this->progressBar) { $this->UpdateProgressBar(7,30,' '); } // *PROGRESS-BAR*
// Recursively writes all tables starting at top level
$this->_tableWrite($this->table[1][1]);
if ($this->table_rotate && count($this->tablebuffer)) {
$this->PageBreakTrigger=$this->h-$this->bMargin;
$save_tr = $this->table_rotate;
$save_y = $this->y;
$this->table_rotate = 0;
$this->y = $this->tbrot_y0;
$h = $this->tbrot_w;
$this->DivLn($h,$this->blklvl,true);
$this->table_rotate = $save_tr;
$this->y = $save_y;
$this->printtablebuffer();
}
$this->table_rotate = 0; // flag used for table rotation
$this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
// mPDF 4.2
$this->blockjustfinished=true;
$this->lastblockbottommargin = $this->table[1][1]['margin']['B'];
//Reset values
// Keep-with-table
$this->kwt = false;
$this->kwt_y0 = 0;
$this->kwt_x0 = 0;
$this->kwt_height = 0;
$this->kwt_buffer = array();
$this->kwt_Links = array();
$this->kwt_Annots = array();
$this->kwt_moved = false;
$this->kwt_saved = false;
// mPDF 3.0
$this->kwt_Reference = array();
$this->kwt_BMoutlines = array();
$this->kwt_toc = array();
$this->shrin_k = 1;
$this->shrink_this_table_to_fit = 0;
unset($this->table);
$this->table=array(); //array
$this->tableLevel=0;
$this->tbctr=array();
$this->innermostTableLevel=0;
$this->tbCSSlvl = 0;
$this->tablecascadeCSS = array();
unset($this->cell);
$this->cell=array(); //array
$this->col=-1; //int
$this->row=-1; //int
$this->Reset();
$this->cellPaddingL = 0;
$this->cellPaddingT = 0;
$this->cellPaddingR = 0;
$this->cellPaddingB = 0;
$this->cMarginL = 0;
$this->cMarginT = 0;
$this->cMarginR = 0;
$this->cMarginB = 0;
$this->default_font_size = $this->original_default_font_size;
$this->default_font = $this->original_default_font;
$this->SetFontSize($this->default_font_size, false);
$this->SetFont($this->default_font,'',0,false);
$this->SetLineHeight();
if (isset($this->blk[$this->blklvl]['InlineProperties'])) { $this->restoreInlineProperties($this->blk[$this->blklvl]['InlineProperties']);}
if ($this->progressBar) { $this->UpdateProgressBar(7,100,' '); } // *PROGRESS-BAR*
}
/*-- END TABLES --*/
/*-- LISTS --*/
// *********** LISTS ********************
if($tag=='LI') {
$this->lastoptionaltag = '';
unset($this->listcascadeCSS[$this->listCSSlvl]);
$this->listCSSlvl--;
if (isset($this->listoccur[$this->listlvl]) && isset($this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]])) { $this->restoreInlineProperties($this->InlineProperties['LIST'][$this->listlvl][$this->listoccur[$this->listlvl]]); }
}
if(($tag=='UL') or ($tag=='OL')) {
$this->ignorefollowingspaces = true; //Eliminate exceeding left-side spaces
unset($this->listcascadeCSS[$this->listCSSlvl]);
$this->listCSSlvl--;
$this->lastoptionaltag = '';
/*-- TABLES --*/
// A simple list for inside a table
if($this->tableLevel) {
$this->listlist[$this->listlvl]['MAXNUM'] = $this->listnum; //save previous lvl's maxnum
unset($this->listlist[$this->listlvl]);
$this->listlvl--;
if (isset($this->listlist[$this->listlvl]['MAXNUM'])) { $this->listnum = $this->listlist[$this->listlvl]['MAXNUM']; } // restore previous levels
if ($this->listlvl == 0) { $this->listjustfinished = true; }
return;
}
/*-- END TABLES --*/
if ($this->listlvl > 1) { // returning one level
$this->listjustfinished=true;
if (!empty($this->textbuffer)) {
$this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
}
// mPDF 3.0
else {
$this->listnum--;
}
$this->textbuffer = array();
$occur = $this->listoccur[$this->listlvl];
$this->listlist[$this->listlvl][$occur]['MAXNUM'] = $this->listnum; //save previous lvl's maxnum
$this->listlvl--;
$occur = $this->listoccur[$this->listlvl];
$this->listnum = $this->listlist[$this->listlvl][$occur]['MAXNUM']; // recover previous level's number
$this->listtype = $this->listlist[$this->listlvl][$occur]['TYPE']; // recover previous level's type
if ($this->InlineProperties['LIST'][$this->listlvl][$occur]) { $this->restoreInlineProperties($this->InlineProperties['LIST'][$this->listlvl][$occur]); }
}
else { // We are closing the last OL/UL tag
if (!empty($this->textbuffer)) {
$this->listitem[] = array($this->listlvl,$this->listnum,$this->textbuffer,$this->listoccur[$this->listlvl],$this->listitemtype);
}
// mPDF 3.0
else {
$this->listnum--;
}
$occur = $this->listoccur[$this->listlvl];
$this->listlist[$this->listlvl][$occur]['MAXNUM'] = $this->listnum;
$this->textbuffer = array();
$this->listlvl--;
$this->printlistbuffer();
unset($this->InlineProperties['LIST']);
// SPACING AFTER LIST (Top level only)
$this->Ln(0);
if ($this->list_margin_bottom) {
$this->DivLn($this->list_margin_bottom,$this->blklvl,true,1); // collapsible
}
if (isset($this->blk[$this->blklvl]['InlineProperties'])) { $this->restoreInlineProperties($this->blk[$this->blklvl]['InlineProperties']);}
$this->listjustfinished = true;
$this->listCSSlvl = 0;
$this->listcascadeCSS = array();
// mPDF 4.2
$this->blockjustfinished=true;
$this->lastblockbottommargin = $this->list_margin_bottom;
}
}
/*-- END LISTS --*/
}
/*-- TABLES --*/
// This function determines the shrink factor when resizing tables
// val is the table_height / page_height_available
// returns a scaling factor used as $shrin_k to resize the table
// Overcompensating will be quicker but may unnecessarily shrink table too much
// Undercompensating means it will reiterate more times (taking more processing time)
function tbsqrt($val, $iteration=3) {
$k = 4; // Alters number of iterations until it returns $val itself - Must be > 2
// Probably best guess and most accurate
if ($iteration==1) return sqrt($val);
// Faster than using sqrt (because it won't undercompensate), and gives reasonable results
//return 1+(($val-1)/2);
if (2-(($iteration-2)/($k-2)) == 0) { return $val+0.00001; } // mPDF 4.5.005
return 1+(($val-1)/(2-(($iteration-2)/($k-2))));
}
/*-- END TABLES --*/
/*-- LISTS --*/
function printlistbuffer() {
//Save x coordinate
$x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
$this->cMarginL = 0;
$this->cMarginR = 0;
$currIndentLvl = -1;
$lastIndent = array();
$bak_page = $this->page;
$indent = 0; // mPDF 3.0
foreach($this->listitem as $item)
{
// COLS
$oldcolumn = $this->CurrCol;
$this->bulletarray = array();
//Get list's buffered data
$this->listlvl = $lvl = $item[0];
$num = $item[1];
$this->textbuffer = $item[2];
$occur = $item[3];
if ($item[4]) { $type = $item[4]; } // listitemtype
else { $type = $this->listlist[$lvl][$occur]['TYPE']; }
$maxnum = $this->listlist[$lvl][$occur]['MAXNUM'];
$this->restoreInlineProperties($this->InlineProperties['LIST'][$lvl][$occur]);
$this->SetFont($this->FontFamily,$this->FontStyle,$this->FontSizePt,true,true); // force to write
$clh = $this->FontSize;
// mPDF 4.2
$this->SetLineHeight($this->FontSizePt,$this->list_lineheight[$lvl][$occur]);
$this->listOcc = $occur;
$this->listnum = $num;
// Set the bullet fontsize
$bullfs = $this->InlineProperties['LISTITEM'][$lvl][$occur][$num]['size'];
$space_width = $this->GetStringWidth(' ') * 1.5;
//Set default width & height values
$this->divwidth = $this->blk[$this->blklvl]['inner_width'];
$this->divheight = $this->lineheight;
$typefont = $this->FontFamily;
switch($type) //Format type
{
case 'none':
$type = '';
$blt_width = 0;
break;
case 'A':
$anum = $this->dec2alpha($num,true);
$maxnum = $this->dec2alpha($maxnum,true);
if ($this->directionality == 'rtl') { $type = $this->list_number_suffix . $anum; }
else { $type = $anum . $this->list_number_suffix; }
$blt_width = $this->GetStringWidth(str_repeat('W',strlen($maxnum)).$this->list_number_suffix);
break;
case 'a':
$anum = $this->dec2alpha($num,false);
$maxnum = $this->dec2alpha($maxnum,false);
if ($this->directionality == 'rtl') { $type = $this->list_number_suffix . $anum; }
else { $type = $anum . $this->list_number_suffix; }
$blt_width = $this->GetStringWidth(str_repeat('m',strlen($maxnum)).$this->list_number_suffix);
break;
case 'I':
$anum = $this->dec2roman($num,true);
if ($this->directionality == 'rtl') { $type = $this->list_number_suffix . $anum; }
else { $type = $anum . $this->list_number_suffix; }
// mPDF 4.0
if ($maxnum>87) { $bbit = 87; }
else if ($maxnum>86) { $bbit = 86; }
else if ($maxnum>37) { $bbit = 38; }
else if ($maxnum>36) { $bbit = 37; }
else if ($maxnum>27) { $bbit = 28; }
else if ($maxnum>26) { $bbit = 27; }
else if ($maxnum>17) { $bbit = 18; }
else if ($maxnum>16) { $bbit = 17; }
else if ($maxnum>7) { $bbit = 8; }
else if ($maxnum>6) { $bbit = 7; }
else if ($maxnum>3) { $bbit = 4; }
else { $bbit = $maxnum; }
$maxlnum = $this->dec2roman($bbit,true);
$blt_width = $this->GetStringWidth($maxlnum.$this->list_number_suffix);
break;
case 'i':
$anum = $this->dec2roman($num,false);
if ($this->directionality == 'rtl') { $type = $this->list_number_suffix . $anum; }
else { $type = $anum . $this->list_number_suffix; }
// mPDF 4.0
if ($maxnum>87) { $bbit = 87; }
else if ($maxnum>86) { $bbit = 86; }
else if ($maxnum>37) { $bbit = 38; }
else if ($maxnum>36) { $bbit = 37; }
else if ($maxnum>27) { $bbit = 28; }
else if ($maxnum>26) { $bbit = 27; }
else if ($maxnum>17) { $bbit = 18; }
else if ($maxnum>16) { $bbit = 17; }
else if ($maxnum>7) { $bbit = 8; }
else if ($maxnum>6) { $bbit = 7; }
else if ($maxnum>3) { $bbit = 4; }
else { $bbit = $maxnum; }
$maxlnum = $this->dec2roman($bbit,false);
// mPDF 4.0
$blt_width = $this->GetStringWidth($maxlnum.$this->list_number_suffix);
break;
case 'disc':
// mPDF 4.2.018
if ($this->PDFA) {
if (isset($this->CurrentFont['cw'][8226])) { $type = "\xe2\x80\xa2"; } // •
else { $type = '-'; }
$blt_width = $this->GetStringWidth($type);
break;
}
$type = $this->chrs[108]; // bullet disc in Zapfdingbats 'l'
$typefont = 'zapfdingbats';
$blt_width = (0.791 * $this->FontSize/2.5);
break;
case 'circle':
// mPDF 4.2.018
if ($this->PDFA) {
if (isset($this->CurrentFont['cw'][9900])) { $type = "\xe2\x9a\xac"; } // ⚬
else { $type = '-'; }
$blt_width = $this->GetStringWidth($type);
break;
}
$type = $this->chrs[109]; // circle in Zapfdingbats 'm'
$typefont = 'zapfdingbats';
$blt_width = (0.873 * $this->FontSize/2.5);
break;
case 'square':
// mPDF 4.2.018
if ($this->PDFA) {
if (isset($this->CurrentFont['cw'][9642])) { $type = "\xe2\x96\xaa"; } // ▪
else { $type = '-'; }
$blt_width = $this->GetStringWidth($type);
break;
}
$type = $this->chrs[110]; //black square in Zapfdingbats font 'n'
$typefont = 'zapfdingbats';
$blt_width = (0.761 * $this->FontSize/2.5);
break;
case '1':
default:
if ($this->directionality == 'rtl') { $type = $this->list_number_suffix . $num; }
else { $type = $num . $this->list_number_suffix; }
$blt_width = $this->GetStringWidth(str_repeat('5',strlen($maxnum)).$this->list_number_suffix);
break;
}
if ($currIndentLvl < $lvl) {
if ($lvl > 1 || $this->list_indent_first_level) {
$indent += $this->list_indent[$lvl][$occur];
$lastIndent[$lvl] = $this->list_indent[$lvl][$occur];
}
}
else if ($currIndentLvl > $lvl) {
while ($currIndentLvl > $lvl) {
$indent -= $lastIndent[$currIndentLvl];
$currIndentLvl--;
}
}
$currIndentLvl = $lvl;
// mPDF 3.0
if (isset($this->list_align[$this->listlvl][$occur])) { $this->divalign = $this->list_align[$this->listlvl][$occur]; }
else { $this->divalign = ''; }
/*-- RTL --*/
if ($this->directionality == 'rtl') {
// mPDF 4.0
if ($this->list_align_style == 'L') { $lalign = 'R'; }
else { $lalign = 'L'; }
$this->divwidth = $this->blk[$this->blklvl]['width'] - ($indent + $blt_width + $space_width) ;
$xb = $this->blk[$this->blklvl]['inner_width'] + $this->blk[$this->blklvl]['border_left']['w'] + $this->blk[$this->blklvl]['padding_left'] - $indent - $blt_width; //Bullet position (relative)
//Output bullet
$this->bulletarray = array('w'=>$blt_width,'h'=>$clh,'txt'=>$type,'x'=>$xb,'align'=>$lalign,'font'=>$typefont,'level'=>$lvl, 'occur'=>$occur, 'num'=>$num, 'fontsize'=>$bullfs );
$this->x = $x;
}
else {
/*-- END RTL --*/
// mPDF 4.0
if ($this->list_align_style == 'L') { $lalign = 'L'; }
else { $lalign = 'R'; }
$this->divwidth = $this->blk[$this->blklvl]['width'] - ($indent + $blt_width + $space_width) ;
$xb = $this->blk[$this->blklvl]['padding_left'] + $this->blk[$this->blklvl]['border_left']['w'] - $blt_width - $space_width;
//Output bullet
$this->bulletarray = array('w'=>$blt_width,'h'=>$clh,'txt'=>$type,'x'=>$xb,'align'=>$lalign,'font'=>$typefont,'level'=>$lvl, 'occur'=>$occur, 'num'=>$num, 'fontsize'=>$bullfs );
$this->x = $x + $indent + $blt_width + $space_width;
} // *RTL*
//Print content
$this->printbuffer($this->textbuffer,'',false,true);
$this->textbuffer=array();
// Added to correct for OddEven Margins
if ($this->page != $bak_page) {
if (($this->page-$bak_page) % 2 == 1) { // mPDF 4.2.022
$x += $this->MarginCorrection;
}
$bak_page = $this->page;
}
/*-- COLUMNS --*/
// OR COLUMN CHANGE
if ($this->CurrCol != $oldcolumn) {
if ($this->directionality == 'rtl') { // *RTL*
$x -= ($this->CurrCol - $oldcolumn) * ($this->ColWidth+$this->ColGap); // *RTL*
} // *RTL*
else { // *RTL*
$x += ($this->CurrCol - $oldcolumn) * ($this->ColWidth+$this->ColGap);
} // *RTL*
$oldcolumn = $this->CurrCol;
}
/*-- END COLUMNS --*/
}
//Reset all used values
$this->listoccur = array();
$this->listitem = array();
$this->listlist = array();
$this->listlvl = 0;
$this->listnum = 0;
$this->listtype = '';
$this->textbuffer = array();
$this->divwidth = 0;
$this->divheight = 0;
$this->x = $this->lMargin + $this->blk[$this->blklvl]['outer_left_margin'];
}
/*-- END LISTS --*/
function printbuffer($arrayaux,$blockstate=0,$is_table=false,$is_list=false)
{
// $blockstate = 0; // NO margins/padding
// $blockstate = 1; // Top margins/padding only
// $blockstate = 2; // Bottom margins/padding only
// $blockstate = 3; // Top & bottom margins/padding
$this->spanbgcolorarray = array();
$this->spanbgcolor = false;
$paint_ht_corr = 0;
/*-- CSS-FLOAT --*/
if (count($this->floatDivs)) {
list($l_exists, $r_exists, $l_max, $r_max, $l_width, $r_width) = $this->GetFloatDivInfo($this->blklvl);
if (($this->blk[$this->blklvl]['inner_width']-$l_width-$r_width) < $this->GetStringWidth('WW')) {
// Too narrow to fit - try to move down past L or R float
if ($l_max < $r_max && ($this->blk[$this->blklvl]['inner_width']-$r_width) > $this->GetStringWidth('WW')) {
$this->ClearFloats('LEFT', $this->blklvl);
}
else if ($r_max < $l_max && ($this->blk[$this->blklvl]['inner_width']-$l_width) > $this->GetStringWidth('WW')) {
$this->ClearFloats('RIGHT', $this->blklvl);
}
else { $this->ClearFloats('BOTH', $this->blklvl); }
}
}
/*-- END CSS-FLOAT --*/
$bak_y = $this->y;
$bak_x = $this->x;
$align = '';
if (!$is_table && !$is_list) {
if (isset($this->blk[$this->blklvl]['align']) && $this->blk[$this->blklvl]['align']) { $align = $this->blk[$this->blklvl]['align']; }
// Block-align is set by e.g. <.. align="center"> Takes priority for this block but not inherited
if (isset($this->blk[$this->blklvl]['block-align']) && $this->blk[$this->blklvl]['block-align']) { $align = $this->blk[$this->blklvl]['block-align']; }
$this->divwidth = $this->blk[$this->blklvl]['width'];
}
else {
$align = $this->divalign;
}
$oldpage = $this->page;
// ADDED for Out of Block now done as Flowing Block
if ($this->divwidth == 0) {
$this->divwidth = $this->pgwidth;
}
if (!$is_table && !$is_list) { $this->SetLineHeight($this->FontSizePt,$this->blk[$this->blklvl]['line_height']); }
$this->divheight = $this->lineheight;
$old_height = $this->divheight;
// As a failsafe - if font has been set but not output to page
$this->SetFont($this->default_font,'',$this->default_font_size,true,true); // force output to page
$array_size = count($arrayaux);
$this->newFlowingBlock( $this->divwidth,$this->divheight,$align,$is_table,$is_list,$blockstate,true); // true = newblock
// Added - Otherwise