... Outputs block margin/border and padding
if (count($this->mpdf->textbuffer) && $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1]) {
if (0 !== strpos($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], "\xbb\xa4\xac")) { // not special content
// Right trim last content and adjust OTLdata
if (preg_match('/[ ]+$/', $this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0], $m)) {
$strip = strlen($m[0]);
$this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0] = substr(
$this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0],
0,
strlen($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][0]) - $strip
);
/* -- OTL -- */
if (!empty($this->mpdf->CurrentFont['useOTL'])) {
$this->otl->trimOTLdata($this->mpdf->textbuffer[count($this->mpdf->textbuffer) - 1][18], false); // mPDF 6 ZZZ99K
}
/* -- END OTL -- */
}
}
}
if (count($this->mpdf->textbuffer) == 0 && $this->mpdf->lastblocklevelchange != 0) {
/*$this->mpdf->newFlowingBlock(
$this->mpdf->blk[$this->mpdf->blklvl]['width'],
$this->mpdf->lineheight,
'',
false,
2,
true,
(isset($this->mpdf->blk[$this->mpdf->blklvl]['direction']) ? $this->mpdf->blk[$this->mpdf->blklvl]['direction'] : 'ltr')
);*/
$this->mpdf->newFlowingBlock(
$this->mpdf->blk[$this->mpdf->blklvl]['width'],
$this->mpdf->lineheight,
'',
false,
$blockstate,
true,
(isset($this->mpdf->blk[$this->mpdf->blklvl]['direction']) ? $this->mpdf->blk[$this->mpdf->blklvl]['direction'] : 'ltr')
);
$this->mpdf->finishFlowingBlock(true); // true = END of flowing block
$this->mpdf->PaintDivBB('', $blockstate);
} else {
$this->mpdf->printbuffer($this->mpdf->textbuffer, $blockstate);
}
$this->mpdf->textbuffer = [];
if ($this->mpdf->kwt) {
$this->mpdf->kwt_height = $this->mpdf->y - $this->mpdf->kwt_y0;
}
/* -- CSS-IMAGE-FLOAT -- */
$this->mpdf->printfloatbuffer();
/* -- END CSS-IMAGE-FLOAT -- */
if ($tag === 'PRE') {
$this->mpdf->ispre = false;
}
/* -- CSS-FLOAT -- */
if ($this->mpdf->blk[$this->mpdf->blklvl]['float'] === 'R') {
// If width not set, here would need to adjust and output buffer
$s = $this->mpdf->PrintPageBackgrounds();
// Writes after the marker so not overwritten later by page background etc.
$this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
$this->mpdf->pageBackgrounds = [];
$this->mpdf->Reset();
$this->mpdf->pageoutput[$this->mpdf->page] = [];
for ($i = ($this->mpdf->blklvl - 1); $i >= 0; $i--) {
if (isset($this->mpdf->blk[$i]['float_endpos'])) {
$this->mpdf->blk[$i]['float_endpos'] = max($this->mpdf->blk[$i]['float_endpos'], $this->mpdf->page * 1000 + $this->mpdf->y);
} else {
$this->mpdf->blk[$i]['float_endpos'] = $this->mpdf->page * 1000 + $this->mpdf->y;
}
}
$this->mpdf->floatDivs[] = [
'side' => 'R',
'startpage' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'],
'y0' => $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
'startpos' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'] * 1000 + $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
'endpage' => $this->mpdf->page,
'y1' => $this->mpdf->y,
'endpos' => $this->mpdf->page * 1000 + $this->mpdf->y,
'w' => $this->mpdf->blk[$this->mpdf->blklvl]['float_width'],
'blklvl' => $this->mpdf->blklvl,
'blockContext' => $this->mpdf->blk[$this->mpdf->blklvl - 1]['blockContext']
];
$this->mpdf->y = $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'];
$this->mpdf->page = $this->mpdf->blk[$this->mpdf->blklvl]['startpage'];
$this->mpdf->ResetMargins();
$this->mpdf->pageoutput[$this->mpdf->page] = [];
}
if ($this->mpdf->blk[$this->mpdf->blklvl]['float'] === 'L') {
// If width not set, here would need to adjust and output buffer
$s = $this->mpdf->PrintPageBackgrounds();
// Writes after the marker so not overwritten later by page background etc.
$this->mpdf->pages[$this->mpdf->page] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf->uniqstr . ')/', '\\1' . "\n" . $s . "\n", $this->mpdf->pages[$this->mpdf->page]);
$this->mpdf->pageBackgrounds = [];
$this->mpdf->Reset();
$this->mpdf->pageoutput[$this->mpdf->page] = [];
for ($i = ($this->mpdf->blklvl - 1); $i >= 0; $i--) {
if (isset($this->mpdf->blk[$i]['float_endpos'])) {
$this->mpdf->blk[$i]['float_endpos'] = max($this->mpdf->blk[$i]['float_endpos'], $this->mpdf->page * 1000 + $this->mpdf->y);
} else {
$this->mpdf->blk[$i]['float_endpos'] = $this->mpdf->page * 1000 + $this->mpdf->y;
}
}
$this->mpdf->floatDivs[] = [
'side' => 'L',
'startpage' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'],
'y0' => $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
'startpos' => $this->mpdf->blk[$this->mpdf->blklvl]['startpage'] * 1000 + $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'],
'endpage' => $this->mpdf->page,
'y1' => $this->mpdf->y,
'endpos' => $this->mpdf->page * 1000 + $this->mpdf->y,
'w' => $this->mpdf->blk[$this->mpdf->blklvl]['float_width'],
'blklvl' => $this->mpdf->blklvl,
'blockContext' => $this->mpdf->blk[$this->mpdf->blklvl - 1]['blockContext']
];
$this->mpdf->y = $this->mpdf->blk[$this->mpdf->blklvl]['float_start_y'];
$this->mpdf->page = $this->mpdf->blk[$this->mpdf->blklvl]['startpage'];
$this->mpdf->ResetMargins();
$this->mpdf->pageoutput[$this->mpdf->page] = [];
}
/* -- END CSS-FLOAT -- */
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['visibility']) && $this->mpdf->blk[$this->mpdf->blklvl]['visibility'] !== 'visible') {
$this->mpdf->SetVisibility('visible');
}
$page_break_after = '';
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['page_break_after'])) {
$page_break_after = $this->mpdf->blk[$this->mpdf->blklvl]['page_break_after'];
}
// Reset values
$this->mpdf->Reset();
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['z-index']) && $this->mpdf->blk[$this->mpdf->blklvl]['z-index'] > 0) {
$this->mpdf->EndLayer();
}
// mPDF 6 page-break-inside:avoid
if ($this->mpdf->blk[$this->mpdf->blklvl]['keep_block_together']) {
$movepage = false;
// If page-break-inside:avoid section has broken to new page but fits on one side - then move:
if (($this->mpdf->page - $this->mpdf->kt_p00) == 1 && $this->mpdf->y < $this->mpdf->kt_y00) {
$movepage = true;
}
if (($this->mpdf->page - $this->mpdf->kt_p00) > 0) {
for ($i = $this->mpdf->page; $i > $this->mpdf->kt_p00; $i--) {
unset($this->mpdf->pages[$i]);
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bb_painted'][$i])) {
unset($this->mpdf->blk[$this->mpdf->blklvl]['bb_painted'][$i]);
}
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['marginCorrected'][$i])) {
unset($this->mpdf->blk[$this->mpdf->blklvl]['marginCorrected'][$i]);
}
if (isset($this->mpdf->pageoutput[$i])) {
unset($this->mpdf->pageoutput[$i]);
}
}
$this->mpdf->page = $this->mpdf->kt_p00;
}
$this->mpdf->keep_block_together = 0;
$this->mpdf->pageoutput[$this->mpdf->page] = [];
$this->mpdf->y = $this->mpdf->kt_y00;
$ihtml = $this->mpdf->blk[$this->mpdf->blklvl]['array_i'] - 1;
$ahtml[$ihtml + 1] .= ' pagebreakavoidchecked="true";'; // avoid re-iterating; read in OpenTag()
unset($this->mpdf->blk[$this->mpdf->blklvl]);
$this->mpdf->blklvl--;
for ($blklvl = 1; $blklvl <= $this->mpdf->blklvl; $blklvl++) {
$this->mpdf->blk[$blklvl]['y0'] = $this->mpdf->blk[$blklvl]['initial_y0'];
$this->mpdf->blk[$blklvl]['x0'] = $this->mpdf->blk[$blklvl]['initial_x0'];
$this->mpdf->blk[$blklvl]['startpage'] = $this->mpdf->blk[$blklvl]['initial_startpage'];
}
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['x0'])) {
$this->mpdf->x = $this->mpdf->blk[$this->mpdf->blklvl]['x0'];
} else {
$this->mpdf->x = $this->mpdf->lMargin;
}
$this->mpdf->lastblocklevelchange = 0;
$this->mpdf->ResetMargins();
if ($movepage) {
$this->mpdf->AddPage();
}
return;
}
if ($this->mpdf->blklvl > 0) { // ==0 SHOULDN'T HAPPEN - NOT XHTML
if ($this->mpdf->blk[$this->mpdf->blklvl]['tag'] == $tag) {
unset($this->mpdf->blk[$this->mpdf->blklvl]);
$this->mpdf->blklvl--;
}
//else { echo $tag; exit; } // debug - forces error if incorrectly nested html tags
}
$this->mpdf->lastblocklevelchange = -1;
// Reset Inline-type properties
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties'])) {
$this->mpdf->restoreInlineProperties($this->mpdf->blk[$this->mpdf->blklvl]['InlineProperties']);
}
$this->mpdf->x = $this->mpdf->lMargin + $this->mpdf->blk[$this->mpdf->blklvl]['outer_left_margin'];
if (!$this->mpdf->tableLevel && $page_break_after) {
$save_blklvl = $this->mpdf->blklvl;
$save_blk = $this->mpdf->blk;
$save_silp = $this->mpdf->saveInlineProperties();
$save_ilp = $this->mpdf->InlineProperties;
$save_bflp = $this->mpdf->InlineBDF;
$save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
// mPDF 6 pagebreaktype
$startpage = $this->mpdf->page;
$pagebreaktype = $this->mpdf->defaultPagebreakType;
if ($this->mpdf->ColActive) {
$pagebreaktype = 'cloneall';
}
// mPDF 6 pagebreaktype
$this->mpdf->_preForcedPagebreak($pagebreaktype);
if ($page_break_after === 'RIGHT') {
$this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-ODD');
} elseif ($page_break_after === 'LEFT') {
$this->mpdf->AddPage($this->mpdf->CurOrientation, 'NEXT-EVEN');
} else {
$this->mpdf->AddPage($this->mpdf->CurOrientation);
}
// mPDF 6 pagebreaktype
$this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
$this->mpdf->InlineProperties = $save_ilp;
$this->mpdf->InlineBDF = $save_bflp;
$this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
$this->mpdf->restoreInlineProperties($save_silp);
}
// mPDF 6 bidi
// Block
// If unicode-bidi set, any embedding levels, isolates, or overrides reopened in the continuing block
if (isset($this->mpdf->blk[$this->mpdf->blklvl]['bidicode'])) {
$blockpre = $this->mpdf->_setBidiCodes('start', $this->mpdf->blk[$this->mpdf->blklvl]['bidicode']);
if ($blockpre) {
$this->mpdf->OTLdata = [];
if ($this->mpdf->tableLevel) {
$this->mpdf->_saveCellTextBuffer($blockpre);
} else {
$this->mpdf->_saveTextBuffer($blockpre);
}
}
}
}
}