Manual Page Break in TCPDF

I’m using <br pagebreak=”true”/>. Find method writeHTML and code if ($dom[$key][‘tag’] AND isset($dom[$key][‘attribute’][‘pagebreak’])) { // check for pagebreak if (($dom[$key][‘attribute’][‘pagebreak’] == ‘true’) OR ($dom[$key][‘attribute’][‘pagebreak’] == ‘left’) OR ($dom[$key][‘attribute’][‘pagebreak’] == ‘right’)) { // add a page (or trig AcceptPageBreak() for multicolumn mode) $this->checkPageBreak($this->PageBreakTrigger + 1); } if ((($dom[$key][‘attribute’][‘pagebreak’] == ‘left’) AND (((!$this->rtl) AND (($this->page % 2) … Read more

How do I avoid a page break immediately after a heading

This is an extremely hacky solution, but it works for me: h1 { page-break-inside: avoid; } h1::after { content: “”; display: block; height: 100px; margin-bottom: -100px; } Basically I create an invisible element that increases the size of the <h1> without affecting the content after it. When page-break-inside: avoid is applied and the whole <h1> … Read more

CSS Page-Break Not Working in all Browsers

Parent elements can not have float on them. Setting float:none on all parent elements makes page-break-before:always work correctly. Other things that can break page-break are: using page-break inside tables floating elements inline-block elements block elements with borders