我試圖使用TCPDF來創建一個PDF,並需要在最後一頁TCPDF更改頁腳
在不同的頁腳使用下面的代碼我可以在第一頁不同的頁腳上,但不是最後
我已經看了幾個帖子關於這個,但不能使它工作
任何幫助實現這將是非常讚賞
public function Footer() {
$tpages = $this->getAliasNbPages();
$pages = $this->getPage();
$footer = 'NORMAL' . $pages . $tpages;
if ($pages == 1) $footer = 'FIRST' . $pages . $tpages;
if ($pages == $tpages) $footer = 'LAST' . $pages . $tpages;
$this->Cell(0, 10, $footer, 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
這給我
1頁 - FIRST13 頁2 - NORMAL23 第3頁(最後一頁)NORMAL23
答:
public function Footer() {
$tpages = $this->getAliasNbPages();
$pages = $this->getPage();
$footer = 'NORMAL' . $pages . $tpages;
if ($pages == 1) $footer = 'FIRST' . $pages . $tpages;
if ($this->end == true) $footer = 'LAST' . $pages . $tpages;
$this->Cell(0, 10, $footer, 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
function display() {
#function that has main text
$this->AddPage();
$html = '1st page';
$this->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$this->AddPage();
$html = '2nd page';
$this->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$this->AddPage();
$html = 'Last page';
$this->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
$this->end = true;
}
你找到一個解?我也遇到了調用總頁數_before_output()的問題。現在我在我的pdf課程中使用內部計數器。 – Kim 2012-08-17 14:19:24
我剛剛制定瞭如何使它工作 - 我添加了一個變量,以生成正文的例程結束 - 頁腳檢查,如果這個變量設置,如果它打印結束頁腳 – mjsolo 2012-08-20 08:18:10
你可以更新你的問題到添加修復它的代碼? – Kim 2012-08-21 11:28:26