Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footer doesn't show on long and multiple pages #1860

Open
1 task done
catherinek opened this issue Apr 21, 2023 · 2 comments
Open
1 task done

Footer doesn't show on long and multiple pages #1860

catherinek opened this issue Apr 21, 2023 · 2 comments

Comments

@catherinek
Copy link

catherinek commented Apr 21, 2023

Guidelines

Description of the bug

I'm trying to write a story which consists of different chapters into a pdf file.

My codes generate a PDF file with the following page footers:

Page 1 on file: [no footer] (it's the Table of Contents)
Page 2 on file: Chapter 1 Page 1 (because I reset the page number here)
Page 3 on file: [no footer]
Page 4 on file: [no footer]
Page 5 on file: Chapter 2 Page 4
Page 6 on file: [no footer]
Page 7 on file: [no footer]
Page 8 on file: [no footer]
Page 9 on file: Chapter 3 Page 8
Page 10 on file: [no footer]
Page 11 on file: [no footer] ....

I believe this is a bug that the pages in between have no footers. Or is my implementation flawed? Please advice.

mPDF version

8.0.13

PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)

7.4, php-fpm on centos

Reproducible PHP CSS HTML snippet suffering by the error

$mpdf = new \Mpdf\Mpdf();
$mpdf->writeHTML('<h3>Table of Contents</h3>'.$TOC_list, 2);

foreach ($chapters as $i => $chapter) {
    $mpdf->AddPage('', '', ($i == 0 ? '1' : ''));
    $mpdf->SetHTMLFooter('<table width="100%">
    <tr>
        <td width="70%">'.$chapter->title.'</td>
        <td width="30%" align="right">Page {PAGENO}</td>
    </tr>
</table>', 'O');

    $mpdf->writeHTML($chapter->body, 2); // please note that the body can be multiple pages long
}
$mpdf->Output();
@finwe
Copy link
Member

finwe commented Apr 30, 2023

The code example is not exactly reproducible, is it?

@melloradamj
Copy link

For anybody else looking and running into the same issue with the body content hiding the footer, here is the solution that helped me:

"set the footer before any content. This is because the footer's height calculation is done before any content processing. But if you add a footer later with SetHTMLFooter, mPDF doesn't recalculate the footer's height, so it will be 0."

https://stackoverflow.com/a/58383718

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants