According to this document: https://github.com/dompdf/dompdf/wiki/Usage
I can output a page number by using several flags.
I have tried using methods described their in every permutation I can think of and nothing seems to work.
I have enabled the "isPhpEnabled" flag.
php code:
// Set options.
$options = new \Dompdf\Options();
$options->set('dpi', 100);
$options->set('isPhpEnabled', TRUE);
// Build pdf.
$dompdf = new \Dompdf\Dompdf($options);
$dompdf->setProtocol('http://');
$dompdf->setBaseHost('scheduler.local');
$dompdf->loadHtml($template->__toString());
$dompdf->render();
$dompdf->stream('note');
html
<div class="footer fixed-section">
<div class="left">
<span class="report-time">08/05/2016 09:43:06</span><br>
<span class="promo">Generated by QuickEMR.com</span>
</div>
<div class="center">
<span class="signature-warning">Document Electronically Signed</span>
</div>
<div class="right">
<span class="page-number">Page <script type="text/php">echo $PAGE_NUM</script></span>
</div>
</div>
I have tried replacing <script type="text/php">echo $PAGE_NUM</script> with
<script type="text/php">$PAGE_NUM</script><script type="text/php">echo $PAGE_NUM;</script><script type="text/php"><?php $PAGE_NUM ?></script><script type="text/php"><?php echo $PAGE_NUM; ?></script><?php echo $PAGE_NUM; ?><?php $PAGE_NUM; ?>None of these variations work. Is this feature broken?
You're not using embedded script correctly. Embedded script is designed to give you access to the underlying PDF rendering engine, not echo into the HTML stream. To print the current page number in the document you have to manually place it using the Canvas::text() or Canvas::page_text() method.
Achieving correct text placement using this method can be difficult. Since all you need in the above sample is the current page you can just use CSS:
<style>
.footer .page-number:after { content: counter(page); }
</style>
<div class="footer fixed-section">
<div class="left">
<span class="report-time">08/05/2016 09:43:06</span><br>
<span class="promo">Generated by QuickEMR.com</span>
</div>
<div class="center">
<span class="signature-warning">Document Electronically Signed</span>
</div>
<div class="right">
<span class="page-number">Page </span>
</div>
</div>
However, if you also need the total number of pages you'll currently need to use embedded script.
hi how to pageNumber with pageTotal number/total
ping @bsweeney
Page total is not currently available via CSS. You would have to utilize the Canvas page_text method either through embedded script or via object access.
Most helpful comment
hi how to pageNumber with pageTotal number/total