簡體   English   中英

創建自定義 html 頁腳客棧 tcpdf

[英]create custom html footer inn tcpdf

我想用 tcpdf 創建一個 html 頁腳。 我發現此文檔用於創建自定義頁腳: https://tcpdf.org/examples/example_003/

但我不知道如何用這個 html 內容來實現它:

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

你能幫我嗎? 非常感謝你:)

您必須擴展 TCPDF class 以添加自定義頁眉頁腳。 提供示例供您參考。

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM