本文介绍了如何在mPDF文档中获取页数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果使用mPDF库的PDF文档,有人知道如何获取生成的页数吗?
Does anybody knows how to get the number of generated pages if a PDF document using mPDF library?
推荐答案
将其添加到主要的mPDF类中:
add this to a main mPDF class:
function getPageCount() {
return count($this->pages);
}
然后添加一个html-parser这样的字符串:
then add a html-parser such string:
$html = str_replace('{PAGECNT}', $this->getPageCount(), $html);
执行这些操作后,您可以在已解析的HTML中直接插入{PAGECNT}以获取结果.这在您需要指示页面时很有用:
after these actions you can insert {PAGECNT} directly in your parsed HTML to get the result. This is useful is you need to indicate a page:
这篇关于如何在mPDF文档中获取页数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!