custom PHP tcpdf footer with top and bottom border

后端 未结 2 1456
情歌与酒
情歌与酒 2021-01-28 10:05

First time use TCPDF, great library.

I try to create a custom footer, however i want to create a custom footer that include the page number and date inside a div with to

2条回答
  •  广开言路
    2021-01-28 10:10

    Karel is right on this.

    you could however ignore the Footer() function if it's getting you in trouble with the dynamic of it. seems to me that you would like to have a div in your footer.

    to do this you have to get rid of the default footer first:

    $this->setPrintFooter(false);
    

    and then create your own footer function.

    public function _footer($input) {
        $html = $input;
    
        $this->setY(-15); // so the footer is an actual footer.
    
        $this->writeHTMLCell(
            $width = 0, // width of the cell, not the input
            $height = 0, // height of the cell..
            $x,
            $y,
            $html = '', // your input.
            $border = 0,
            $ln = 0,
            $fill = false,
            $reseth = true,
            $align = '',
            $autopadding = true 
        );
    }
    

    the values of the above function are the defaults. so you may want to edit them.

    with a call like this:

    $div = ''>
    $pdf->_footer($div);
    

    you create your HTML cell with the $div input.

    to get the page numbers and stuff like that just checkout the TCPDF documentation page: http://www.tcpdf.org/doc/code/classTCPDF.html

    hope this helps a little bit to understand it. this is just an example from scratch. edit it as you like and try out some stuff to get your PDF document going.

提交回复
热议问题