Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8062919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:50:25+00:00 2026-06-05T10:50:25+00:00

I’m generating PDFs using mPDF library, and my header and footer vary in size

  • 0

I’m generating PDFs using mPDF library, and my header and footer vary in size depending on a couple of parameters.

A static solution would be to set the footer margin, which will solve the overlapping – but as the footer may vary in size this is not a solution I feel happy with. Is there a way to get the footer dimensions and apply the margin accordingly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:50:28+00:00Added an answer on June 5, 2026 at 10:50 am

    The problem lies in the documentation of mpdf. I think margin_footer and margin_header is the margin between the document body and these. Instead, margin_footer and margin_header is the document margins, as one would think margin_top and margin_bottom would be.

    So, changing the bottom and top margin will decide where the document body starts. And changing the header/footer margin will decide the printing margins.

    Hope it helps!

    Updated answer

    mPDF documentation is a bit off for the constructor call, I guess. The margin_top/bottom argument is actually the content margin, and does not apply for margin_header/footer arguments. (If I recall correctly). The margin_top/bottom is the absolute margin from the top of the document, and should include the height of the header/footer.

    Here is the correct way of handling the margins:

    /**
     * Create a new PDF document
     *
     * @param string $mode
     * @param string $format
     * @param int $font_size
     * @param string $font
     * @param int $margin_left
     * @param int $margin_right
     * @param int $margin_top (Margin between content and header, not to be mixed with margin_header - which is document margin)
     * @param int $margin_bottom (Margin between content and footer, not to be mixed with margin_footer - which is document margin)
     * @param int $margin_header
     * @param int $margin_footer
     * @param string $orientation (P, L)
     */
    new mPDF($mode, $format, $font_size, $font, $margin_left, $margin_right, $margin_top, $margin_bottom, $margin_header, $margin_footer, $orientation);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.