custom PHP tcpdf footer with top and bottom border

后端 未结 2 1451
情歌与酒
情歌与酒 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

    You can extend the TCPDF class and add your custom Footer function. Here's an example that I've used, see if it fits and modify to your own needs. It doesn't use a

    to render the footer, that wasn't possible at the time I wrote this (might be now though, TCPDF is evolving rapidly).

    class MyPDF extends TCPDF {
        public function Footer() {
            $this->SetY(-15);
            $this->SetFont('helvetica', 'I', 8);
            $this->Cell(0, 10,
                        'Page ' . $this->getAliasNumPage() . ' of total ' .
                        $this->getAliasNbPages(), 0, false, 'C', 0, '',
                        0, false, 'T', 'M');
        }
        public function Header() {
            // add custom header stuff here
        }
    }
    
    $pdf = new MyPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,
                     true, 'UTF-8', false);
    

提交回复
热议问题