• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2085
  • Last Modified:

fpdf dynamic footer height

The tutorial about the footer here http://www.fpdf.org/
shows a method for a static height footer.

How can make the footer height dynamic when the footer contains an image or a multicell with more than 1 line?

Thank you.
0
myyis
Asked:
myyis
  • 3
  • 2
1 Solution
 
Dan CraciunIT ConsultantCommented:
Reading the code, making the footer "dynamic" is as easy as adding more elements to it.
It's simply positioned 1.5 cm from the bottom, so any content you add to the footer will be pushed up.

HTH,
Dan
0
 
myyisAuthor Commented:
The extra content does not make it pushed up, they disappear at the bottom margin
0
 
Ray PaseurCommented:
I do not think there is a "dynamic" answer, so this is just an explanation of the philosophy behind two different languages.  

First, HTML: It is a semantic markup language, but many years ago it was used (or abused) for layout capabilities, too (think tables, etc).  HTML is somewhat flexible in the way it wraps text and adjusts container sizes to account for differences in the dimensions of the viewports.  

Next PDF: It is a document layout language, devoid of semantic meaning, and inflexible in the way it wraps text.  PDF is intended to prescribe in extreme detail the exact positioning of data elements on the printed page.  So the idea of a "dynamic height" in a PDF document is kind of counter-intuitive, in the same way that a dynamic height would not make sense in automobile wheel - the parts have to fit together in a car.  They have to fit together in a PDF document, too.

I think you will get the best results from your work with FPDF (or TCPDF) if you approach the page layout logically from the top left to the bottom right, putting everything exactly into its place in the document.  That means if you have some footers that are one size and some that are another size, you need two different footer algorithms. The resulting PDFs can render the footers exactly the way you want them, but your program logic will have to control which footer layout you add to the document.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
myyisAuthor Commented:
I see but there should be a simpler way.
Because the header height is automatically adjusted without any extra effort while the footer height is static. I believe the fpdf community had found a solution to this problem.
0
 
Ray PaseurCommented:
Top-to-bottom organization (which is what FPDF and TCPDF use) readily allows for header height to be "dynamic" because it just means pushing other things down the page.  But where do you "push" the data when you've gotten to the end of the page?  I don't believe these libraries give you the option to "push" the data up the page.  You can manually calculate the position of any data element you want.  I'm not suggesting that a dynamic footer is a bad idea; I'm just trying to show you how to get past this issue in a practical step, without wasting your time.

Here are the choices as I see them:

Allocate the footer area large enough to hold the largest data element that you need in the footer.  That way everything will fit.  Then if you have a smaller data component, you will have some white space in the footer.

Or, write program logic that predetermines the size of the footer and uses that information to decide the size you will allocate to the page of information above the footer.  By doing that you can be sure that the footer will always fit with a minimum of unused white space.

My preference would be to allocate the larger footer area; I think this will give you the fastest path to a solution.
0
 
myyisAuthor Commented:
Helped! Thank you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now