mPDF 在第一页禁用页码、页眉和页脚
问题描述:
我刚刚在我的项目中使用了 mPDF,现在遇到了这个问题.首先让我描述一下我的 PDF 结构:
I just used mPDF on my project and now stuck on this problem. First let me describe my PDF structure:
- 第一页是封面.
- 第二页是目录页.
- 第三页是内容页.
所以问题是:
- 封面和目录页有页眉、页脚、页码.我如何删除它?
- 内容页码以第 3 开头.如何将其重置为第 1?
下面是用于包含页眉和页脚的代码
Below is the code is used to include header and footer
$mpdf->SetHeader('{DATE j-m-Y}|{PAGENO}/2|My document');
$mpdf->SetFooter('{PAGENO}'); /* defines footer for Odd and Even Pages - placed at Outer margin */
$mpdf->SetFooter(array(
'L' => array(
'content' => 'Text to go on the left',
'font-family' => 'sans-serif',
'font-style' => 'B', /* blank, B, I, or BI */
'font-size' => '10', /* in pts */
),
'C' => array(
'content' => '- {PAGENO} -',
'font-family' => 'serif',
'font-style' => 'BI',
'font-size' => '18', /* gives default */
),
'R' => array(
'content' => 'Printed @ {DATE j-m-Y H:m}',
'font-family' => 'monospace',
'font-style' => '',
'font-size' => '10',
),
'line' => 1, /* 1 to include line below header/above footer */
), 'E' /* defines footer for Even Pages */
);
对于 TOC 页面,我在 html 中添加了这个标签
And for TOC page, I add this tag in the html
<tocpagebreak />
答
您可以先将页脚设置为不可见,然后在您希望编号开始时重新设置.例如(使用 html 标签):
You can setup your footer to be invisible at first, and then reset it when you want the numbering to start. For example (using html tags):
<!-- sets up the footer -->
<pagefooter name="footer" content-center="{PAGENO}"></pagefooter>
<!-- disables it -->
<setpagefooter value="off"></setpagefooter>
<p>Some content for the first pages</p>
<!-- activates the footer and resets the numbering -->
<pagebreak odd-footer-name="footer" odd-footer-value="on" resetpagenum="1"></pagebreak>
我很确定使用等效的 mpdf 方法可以实现相同的效果.
I'm pretty sure the same can be achieved using the equivalent mpdf methods.