简体   繁体   English

如何获取MPDF中的总页数?

[英]How to get the total number of pages in MPDF?

I'm using PHP MPDF to create PDF files.我正在使用 PHP MPDF 创建 PDF 个文件。 At the footer I'm able to print the current page number using在页脚,我可以使用打印当前页码

{PAGENO}

But how do I get the total number of pages in the PDF file?但是如何获取 PDF 文件中的总页数呢? So that in the footer I can print like:这样在页脚中我可以像这样打印:

Page (Current Page) of (Total number of pages)   
Page 1 of 6

According to the official documentation : 根据官方文件

$mpdf=new mPDF();
$mpdf->setFooter("Page {PAGENO} of {nb}");

您可以使用{nb}它为您提供mpdf中的总页数

I use the following in my html header template:我在我的 html header 模板中使用以下内容:

{PAGENO}/{nb}

For example,on 1st of total of 3 pages, the result will be:例如,在总共 3 页的第 1 页,结果将是:

1/3 1/3

So, you can write it wherever you want in your HTML code like header, footer, body...因此,您可以在 HTML 代码中的任何位置编写它,例如 header、页脚、正文...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM