[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

fpdf dynamic footer height

Posted on 2014-04-20
6
Medium Priority
?
2,015 Views
Last Modified: 2014-04-24
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
Comment
Question by:myyis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 40012038
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
 
LVL 1

Author Comment

by:myyis
ID: 40012137
The extra content does not make it pushed up, they disappear at the bottom margin
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40012267
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:myyis
ID: 40012281
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
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 40012294
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
 
LVL 1

Author Closing Comment

by:myyis
ID: 40021455
Helped! Thank you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question