我使用TCPDF
customising footer
为我的客户端应用生成pdf。我的客户希望在footer
中显示动态的数据以及页码。我面临的问题是,当数据长度超过pdf宽度时,数据不会移动到下一行,而某些文本会被裁剪。
Can somebody suggest me solution by which I can shift some text to new line? similar to the one be do in HTML by adding <br>.
或
Is there a way by which the text moves to next line automatically when the length of the text in footer exceeds the pdf width?
答案 0 :(得分:1)
按示例3扩展类或使用以下代码
class MYPDF extends TCPDF {
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
$foot = 'Line 1 \n Line 2 \n 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages()';
$this->MultiCell(0, 10, $foot, 0, 'C');
}
}
// create new PDF document
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);