How can I get the total number of pages in DOMPDF?

Pedro picture Pedro · Mar 30, 2011 · Viewed 23.6k times · Source

For example Page 1 of 5.

There's an example online of how to get teh Page 1 part but not the of 5 part. This is it:

.pagenum:before { content: "Page " counter(page); }

I'm using version 0.6 and $PAGE_NUM and $PAGE_COUNT does not work.

Answer

Fabien Ménager picture Fabien Ménager · Mar 30, 2011

By default, inline PHP is disabled for security reasons, you need to enable it yourself in dompdf_config.custom.inc.php. See here.

For now, total page count is not supported with the CSS you are using, we are planning to make it work in 0.6 final though.