iT邦幫忙

0

PHP TCPDF 把文字每頁置底

  • 分享至 

  • xImage

我看了官方(custom Header and Footer),Example看到Footer只能顯示頁面數字,我想多加自己寫好的放左顯示頁面數字上方,並在每頁顯示出來,但找不到方法。

ckp6250 iT邦好手 1 級 ‧ 2021-10-29 20:53:32 檢舉
請把您寫好的部份貼出來,這樣大家才好幫您加油添醋。
nick12345 iT邦新手 4 級 ‧ 2021-10-30 16:00:20 檢舉
public function printOutPDF()
{

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 001');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');

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

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

// set margins
$pdf->SetMargins(10, 8, 10);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(10, 8, 1);

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

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once(dirname(__FILE__) . '/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------

// set default font subsetting mode
$pdf->setFontSubsetting(true);

// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('msungstdlight', '', 12, '', true);

// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();

// set text shadow effect
$pdf->setTextShadow(false);

// Set some content to print
$html = '
<table>
<tr>
<td>Header</td>
</tr>
</table><br>

<table>
<tr>
<td>content</td>
</tr>
</table>

<table>
<tr>
<td>
<span style="font-size:15px;"><br><hr width="60%";></span><br>
<span style="font-size:12px;">Signature<br>
</td>

<td>
<span style="font-size:15px;"><br><hr width="60%";></span><br>
<span style="font-size:12px;">Company Signature</span><br>
<span style="font-size:12px;">Name:</span><br>
<span style="font-size:12px;">Date:</span></td>
</tr>
</table>
';

// Print text using writeHTMLCell()
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);

// ---------------------------------------------------------

// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output('example_001.pdf', 'I');

//============================================================+
// END OF FILE
//============================================================+

}
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

1
海綿寶寶
iT邦大神 1 級 ‧ 2021-10-29 22:29:17

參考這篇合不合用

nick12345 iT邦新手 4 級 ‧ 2021-10-30 16:01:24 檢舉

有看過,但是我不只要頁面數,我有想放進去

0
ckp6250
iT邦好手 1 級 ‧ 2021-11-02 16:53:40

https://stackoverflow.com/questions/42553709/how-can-i-use-a-multiline-footer-in-tcpdf

要使用 $pdf->MultiCell 的方式,我有測過了,可行。

我要發表回答

立即登入回答