說明
本 method 無傳入參數, 當文件遇到需分頁情況時便會呼叫此 method, 在此 method 內寫入判斷式, 執行後回傳一布林值以回應主程式否執行分頁. 實作方面預設會依據 SetAutoPageBreak() 所設定的模式傳回值.本 method 不應直接呼叫, 而會由系統自動呼叫, 故應先建立一個繼承自 FPDF 的類別, 並將此 method 實作置於此子類別內.
範例
本例會有 3 直欄版面:
// 先繼承 FPDF, 建立一個新的類別 PDF
class PDF extends FPDF
{ var $col=0;
function SetCol($col)
{ //Move position to a column
$this->col=$col;
$x=10+$col*65;
$this->SetLeftMargin($x);
$this->SetX($x);
}
function AcceptPageBreak()
{ if($this->col<2)
{ // Go to next column
$this->SetCol($this->col+1);
$this->SetY(10);
return false;
}
else
{ // Go back to first column and issue page break
$this->SetCol(0);
return true;
}
}
}
$pdf=new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',12);
for($i=1;$i<=300;$i++)
$pdf->Cell(0,5,"Line $i",0,1);
$pdf->Output();
沒有留言:
張貼留言