【问题标题】:mPDF disable page number, header and footer on first pagemPDF 在首页禁用页码、页眉和页脚
【发布时间】:2012-12-10 18:36:27
【问题描述】:

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

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

所以问题是:

  1. 封面页和目录页有页眉、页脚、页码。如何删除它?
  2. 内容页码以 no 3 开头。如何将其重置为 no 1?

下面是用于包含页眉和页脚的代码

$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 中添加了这个标签

<tocpagebreak />

【问题讨论】:

    标签: mpdf


    【解决方案1】:

    您可以先将页脚设置为不可见,然后在您希望编号开始时将其重置。 例如(使用html标签):

    <!-- 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 方法可以实现相同的效果。

    【讨论】:

      猜你喜欢
      • 2014-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多