skip to Main Content

I am using PHPv8 with TCPDF v6.3.0.

I have an HTML footer being printed on every page (basically it’s just an image right now).

On the very last page, it prints the exact way I want it to. However on any other/previous pages, it prints like it’s zoomed in or enlarged and I can’t figure out for the life of me why.

I have tried turning off the AutoPageBreak, I have played around with the margins, all sorts of stuff, but I can’t figure out why it keeps doing it.

If my PDF is a single page, it works perfectly. If it’s more than 1, then it breaks like this every time.

0-(N-1) pages:

Last page:

I am expecting the footer to be the same on every page like it does on the last page currently.

2

Answers


  1. Chosen as BEST ANSWER

    So the solution to MY problem was as follows.

    My footer image was ~1200x60px, so I resized it down to about 600x30px and it looks exactly the same on all the pages now. I think the problem is that TCPDF wasn't resizing/scaling the image in the footer properly, so it was putting the image in the ORIGINAL size on the PDF. Now that the image is saved to the actual size of the generated PDF [width], it looks exactly like I need!

    The issue still remains that TCPDF does this, so it's good to know how to "locally" resolve this incase anyone else has this problem like I did.


  2. It is clear from the images that your left/right margins are broken when you have multiple pages.

    This is almost always caused by missing an end statement that must appear AFTER you display the image.

    </div></table></p> 
    

    etc, are often overlooked.

    More than likely the reason it doesn’t happen when you only have one page is because the number of closing components match up with the number of opening components.

    The only solution is for you to check your code line by line.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search