简体   繁体   中英

create custom html footer inn tcpdf

I would like to create an html footer with tcpdf. I found this documentation to create a custom footer: https://tcpdf.org/examples/example_003/

But I have no idea how I can realize it with this html content:

<table class="tblFooter" cellpadding="5">
            <tr>
                <td>
                    Box 1
                </td>
                <td>
                    Box2
                </td>
                <td>
                    Box3
                </td>
            </tr>
        </table>

Can you help me please? Thank you very much:)

You have to extend the TCPDF class to add custom Header-Footer. Providing an example for your reference.

class MYPDF extends TCPDF {

        public function Header() {
        
            $hdrhtml ='
                
                <br /><br />
                
                <table border="0" width="650" cellspacing="1">
                    <tr>
                        <td align="center">
                            <br />
                            <font style="font-size: 10px;"><b>Some text<br /></b></font>
                            <font style="font-size: 10px;">Some Text</font>
                        </td>
                    </tr>
                </table>
            ';        
        
          $this->writeHTML($hdrhtml, true, false, true, false, '');
        
        }
        
        public function Footer() {
        
          $fhtml = '
            <table class="tblFooter" cellpadding="5">
            <tr>
                <td>
                    Box 1
                </td>
                <td>
                    Box2
                </td>
                <td>
                    Box3
                </td>
            </tr>
        </table>
          ';
          
          $this->writeHTML($fhtml, true, false, true, false, '');
          
        }

}

$pdf                = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins, left-top-right
$pdf->SetMargins(20, 10, 10);

// remove default header/footer
//$pdf->setPrintHeader(false);
//$pdf->setPrintFooter(false);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, 50);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM