我有一个客户名单谁需要得到一个动态生成的pdf。
class PDF extends FPDF
{
// Page header
function Header()
{
global $backToTOC;
// Logo
$this->Image('logo.jpg',70,10);
$this->Write(5,'Back to TOC',$backToTOC);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(5,'Contact support: 1-800-support');
$this->Cell(5,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
foreach ($customer as $k => $v)
{
$pdf = new PDF();
$pdf->AliasNbPages();
//....pdf stuff.....
$pdf->Output($v.'.pdf','F');
}这样做的结果是除以零的错误。
PHP Warning: Division by zero in /var/www/lib/fpdf/fpdf.php on line 796页脚页码显示为0。有什么想法吗?
发布于 2014-06-02 17:46:56
Cell方法要求第二个参数是单元格高度,而不是单元格内容(请参见Cell method)。调用时:
$this->Cell(5,'Page '.$this->PageNo().'/{nb}',0,0,'C');您使用'Page '.$this->PageNo().'/{nb}'作为height,使用0作为content。它应该是:
$this->Cell(5, $cellHeight, 'Page '.$this->PageNo().'/{nb}',0,0,'C');发布于 2014-05-19 23:57:14
尝试在创建PDF对象后立即设置字体,它在我的机器上工作。
另外,如果它不工作,请粘贴堆栈跟踪。
https://stackoverflow.com/questions/23500904
复制相似问题