Menu

#873 Strange behaviour defining a footer for the last page when using AutoPageBreak and writeHTML

v1.0_(example)
closed
None
7
2017-07-24
2013-12-27
Millen
No

Hi,

I'm developing a report that has a different footer on it's last page. Following Nicola's recommended approach I've overriden the Close() function on my custom TCPDF subclass like so:

public function Close() {
    $this->last_page_flag = true;
    parent::Close();
}

And then on the Footer() function I do something like:

function Footer(){
    if($this->last_page_flag){
        $footer_html = '...'; //HTML for the footer on the last page
    }
    else{
        $footer_html = '...'; //HTML for the rest of the pages
    }

    $this->setY(-$this->_footerMargin);
    $this->writeHTML($footer_html);
}

I'm using writeHTML to print HTML tables with the content of the report. This content can span several pages so I'm using AutoPageBreak. This implementation works most of the time, but there are certain situations where it prints the incorrect footer (doesn't print the last page footer when it's actually the last page). This happens when the content approaches the autopagebreak threshold (although never reaching it). In the first attachment (correct-footer.png) you can see an example of the correct footer (I've erased all the sensitive information on the header). If I add a few lines to the report (still only 1 page) it prints the wrong footer, that is, the footer for all the pages but the last (second attachment, wrong-footer.png). As you can see there's only 1 page on the report and it's the last obviously, so it should print the footer that you can see on example 1. This bug happens only when AutoPageBreak is set to true. If I disable AutoPageBreak example 2 works fine (prints the footer of the last page).

2 Attachments

Discussion

  • Millen

    Millen - 2013-12-27
    Post awaiting moderation.
  • Nicola Asuni

    Nicola Asuni - 2013-12-27

    This is not a TCDPF bug but a specific problem of your implementation.
    Please ask help in the Help forum.

     
  • Nicola Asuni

    Nicola Asuni - 2013-12-27
    • status: open --> closed
     
  • Abrar Sheikh

    Abrar Sheikh - 2017-07-24

    Hi i have the same problem. Could you please help me how to resolve this issue.

     

Log in to post a comment.