I am using mpdf library in CodeIgniter for generating PDF files.
I want 4 files to be generated from single for loop. But it is only generating one file.
Below is the code
$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);
Even I have removed these unset methods, and not only this, I have printed this data by applying comments on the code. Data inside the loop is fine, but only not generating multiple files. It is only generating single file.
Any suggestions?
Have you tried this:
$mpdf->Output($title.$i.".pdf",'D');
Instead of
$mpdf->Output($title.".pdf",'D');
I was also working on similar thing,
I changed
$mpdf->Output($title.".pdf",'D');
TO
$mpdf->Output('c:/pdf/'.$title.".pdf",'F');
This create file in the location specified