这是我的控制器功能,我正在运行一个循环来创建多个文档pdf 并合并为一个。
public function tick_pdf(){
$tt='';
$name="iftekhar";
$title="Event Football";
$num=4;
for($i=0;$i<4;$i++){
$this->pdfHeader($row->EventId);
$this->pdf->fontpath = 'font/';
//$this->pdf->AddPage();
$this->pdf->Ln(10);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Name",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$name,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Title",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$title,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Number",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$num,0,1);
$this->pdf->SetFont('Arial','B',12);
$this->pdf->Cell(10);
$this->pdf->Cell(60,10,"Date",0,0,'L');
$this->pdf->Cell(10,10,":",0,0,'L');
$this->pdf->MultiCell(60,10,$date,0,1);
$tt.=$this->pdf->Output('', 'S');
}
echo $tt;
}
但我在浏览器中遇到错误 &#34;未定义的索引:数据 文件名:libraries / fpdf.php 行号:1659&#34;我使用fpdf生成pdf
答案 0 :(得分:0)
如果您需要创建多个PDF文档,则需要多个类实例。实际上,您只使用一个实例。
也不可能通过简单地连接它们的字节($ tt。= ...)来连接PDF文档。通常,无法在单个请求中向客户端发送多个PDF文档。
如果要创建多个页面,只需在AddPage()之前删除注释,删除变量$ tt并在循环外移动Output()调用。