我使用CodeIgniter中的mpdf库来生成PDF文件。
我希望4个文件是从单一的for循环生成。但它只生成一个文件。
下面是代码
$dataArr = $notificationReports['data'];
$chunkReport = count($dataArr);
if($chunkReport > 1000){
$chunkSize = ($chunkReport / 4);
$chunks = array_chunk($dataArr,$chunkSize);
for($i = 0; $i <= 3; $i++){
$this->load->library('mpdf56/mpdf');
$paper='A4';
$notificationReports['data'] = $chunks[$i];
$notificationReports['heading'] = array(
'S. NO',
'SENT DATE',
'SENT BY',
'SENT TO',
'MESSAGE',
'SMS'
);
$mpdf=new mPDF('utf-8',$paper,'','','','','',10,'',3,'L');
$html = $this->load->view('reports/pdf_view_report',$notificationReports,true);
$mpdf->WriteHTML($html);
$mpdf->Output($title.".pdf",'D');
unset($mpdf);
unset($notificationReports);
unset($html);
甚至我已经删除了这些未设置的方法,不仅如此,我还通过在代码上应用注释来打印这些数据。循环中的数据很好,但不会生成多个文件。它只生成单个文件。
有什么建议吗?
发布于 2015-11-18 17:02:41
我也在做类似的事情,
我变了
$mpdf->Output($title.".pdf",'D');
至
$mpdf->Output('c:/pdf/'.$title.".pdf",'F');
这将在指定的位置创建文件
发布于 2014-10-10 02:41:08
你有没有试过这个:
$mpdf->Output($title.$i.".pdf",'D');
而不是
$mpdf->Output($title.".pdf",'D');
https://stackoverflow.com/questions/26283014
复制相似问题