PHP 7 HTML2PDF.JS Example to Add Page Break Inside PDF Document in Browser Using Javascript

You are currently viewing PHP 7 HTML2PDF.JS Example to Add Page Break Inside PDF Document in Browser Using Javascript

PHP 7 HTML2PDF.js Example to Add Page Break inside PDF Document in Browser Using Javascript

<span class="hljs-keyword">protected</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_tag_open_PAGE</span>(<span class="hljs-params"><span class="hljs-variable">$param</span></span>) </span>{}
 

<span class="hljs-tag"><<span class="hljs-name">page</span> <span class="hljs-attr">orientation</span>=<span class="hljs-string">"l"</span>></span>
... some content ...
<span class="hljs-tag"></<span class="hljs-name">page</span>></span>
<span class="hljs-tag"><<span class="hljs-name">page</span> <span class="hljs-attr">orientation</span>=<span class="hljs-string">"p"</span>></span>
... some content ...
<span class="hljs-tag"></<span class="hljs-name">page</span>></span>

<span class="hljs-keyword">protected</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_tag_close_DIV</span>(<span class="hljs-params"><span class="hljs-variable">$param</span>, <span class="hljs-variable">$other</span>=<span class="hljs-string">'div'</span></span>)
</span>{
    <span class="hljs-keyword">if</span> (<span class="hljs-keyword">$this</span>->parsingCss->value[<span class="hljs-string">'page-break-after'</span>] == <span class="hljs-string">"always"</span>)
      <span class="hljs-keyword">$this</span>->_setNewPage(<span class="hljs-literal">null</span>, <span class="hljs-string">''</span>, <span class="hljs-literal">null</span>, <span class="hljs-keyword">$this</span>->_defaultTop);
      <span class="hljs-keyword">$this</span>->parsingCss->setPosition();
    ...
}
 

<span class="hljs-comment">//add a new style declaration</span>
<span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">initStyle</span>()
</span>{
    ...
    <span class="hljs-keyword">$this</span>->value[<span class="hljs-string">'page-break-after'</span>] = <span class="hljs-literal">null</span>;
}
 

<span class="hljs-keyword">case</span> <span class="hljs-string">'page-break-after'</span>:
    <span class="hljs-keyword">$this</span>->value[<span class="hljs-variable">$nom</span>] = <span class="hljs-variable">$val</span>;
    <span class="hljs-keyword">break</span>;
 

<span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"page-break-after:always; clear:both"</span>></span><span class="hljs-tag"></<span class="hljs-name">div</span>></span>

<span class="hljs-keyword">protected</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_tag_close_P</span>(<span class="hljs-params"><span class="hljs-variable">$param</span></span>)</span>{
 

   <span class="hljs-keyword">if</span>(<span class="hljs-keyword">$this</span>->parsingCss->value[<span class="hljs-string">'page-break-after'</span>] == <span class="hljs-string">"always"</span>)
        <span class="hljs-keyword">$this</span>->_setNewPage();
 

<span class="hljs-keyword">protected</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_tag_close_DIV</span>(<span class="hljs-params"><span class="hljs-variable">$param</span>, <span class="hljs-variable">$other</span>=<span class="hljs-string">'div'</span></span>)</span>{
 

<span class="hljs-keyword">if</span>(<span class="hljs-keyword">$this</span>->parsingCss->value[<span class="hljs-string">'page-break-after'</span>] == <span class="hljs-string">"always"</span>)
        <span class="hljs-keyword">$this</span>->_setNewPage();

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply