mPDF 在第一页禁用页码、页眉和页脚 [英] mPDF disable page number, header and footer on first page

查看:206
本文介绍了mPDF 在第一页禁用页码、页眉和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我的项目中使用了 mPDF,现在遇到了这个问题.首先让我描述一下我的 PDF 结构:

I just used mPDF on my project and now stuck on this problem. First let me describe my PDF structure:

  1. 第一页是封面.
  2. 第二页是目录页.
  3. 第三页是内容页.

所以问题是:

  1. 封面和目录页有页眉、页脚、页码.我如何删除它?
  2. 内容页码以第 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.

这篇关于mPDF 在第一页禁用页码、页眉和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆