dompdf - text on a single page / page_script doesnt work
<p>I'm using dompdf 0.7.0 and try to write down text in PHP on my pdf after rendering. I need text on specific pages and found the following from Answer from Brian
<a href="https://stackoverflow.com/questions/30193587/dompdf-page-num-not-on-first-page">DomPDF {PAGE_NUM} not on first page</a></p>

<p>The function page_script sound like the correct answer. 
I could check if loop is currently on page 3 or whatever.</p>

<p>Does I have to enable any options for this function?</p>

<p>Example:</p>

<pre><code>    $dompdf = new Dompdf( $options );
    $dompdf-&gt;set_option('default_font', 'open sans');
    $dompdf-&gt;set_option('fontHeightRatio', 1);
    $dompdf-&gt;setPaper('A4')


    $dompdf-&gt;set_option('enable_html5_parser', true);
    $dompdf-&gt;set_option('enable_php', true);

    $dompdf-&gt;loadHtml( $html );
    $dompdf-&gt;render();

    $canvas = $dompdf-&gt;get_canvas();
    $canvas-&gt;page_script('
    if ($PAGE_NUM &gt; 1) {
        $current_page = $PAGE_NUM-1;
        $total_pages = $PAGE_COUNT-1;
        $canvas-&gt;text(0, 0, "$current_page / $total_pages", "open sans condensed", 10, array(0,0,0));
    }
   ');
</code></pre>

<p>It still be shown on my first page.</p>