我想用 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>
你能幫我嗎?非常感謝 :)
uj5u.com熱心網友回復:
您必須擴展 TCPDF 類以添加自定義頁眉頁腳。提供一個示例供您參考。
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 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);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/311211.html
上一篇:用php修改現有的pdf檔案
