Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mPDF disable page number, header and footer on first page

Tags:

mpdf

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

  1. First page is a cover page.
  2. Second page is Table Of Content page.
  3. Third page is content page.

So the problem is :

  1. There is header,footer,page number in cover page and TOC page. How do I remove that?
  2. The content page number start with no 3. How do I reset it to become no 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 */
  );

And for TOC page, I add this tag in the html

<tocpagebreak />
like image 973
cyberfly Avatar asked Dec 24 '12 09:12

cyberfly


1 Answers

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>

I'm pretty sure the same can be achieved using the equivalent mpdf methods.

like image 175
felixgirault Avatar answered Nov 08 '22 15:11

felixgirault