0

I want to create zip file from mpdf generated pdf file. It contains more than one pdf. Simply single pdf download is working. But i want to download bulk pdf that is to be archieved in to zip file. public function getpdf($param2,$param1) {

  $this->load->library('pdf');
  $this->load->library('form_validation');
  $this->load->library('session'); 

  $this->load->helper('url'); 
  $this->load->library('m_pdf');
  $pdf = $this->m_pdf->load();
  $this->load->model('User_model');



  $data['studinfo_users'] = $this->User_model->getstuddet_users($param1); 
  $data['appinfo'] = $this->User_model->appinfo($param1,$param2); 
  $data['amountinfo'] = $this->User_model->amountinfo($param1,$param2);    

   $wm = base_url() . 'images/img.jpg';
   $pdf->SetWatermarkImage($wm);
   $pdf->showWatermarkImage = true;
   $pdf->SetTopMargin('10%');

  $html = $this->load->view('users/ack', $data, true);
  $pdf->SetHTMLHeader('<div style="text-align: left;"><img src="images/logo.jpg" width="80px" /></div>', 10,15,20, true);

  $pdf->WriteHTML($html); // write the HTML into the PDF
  $output = $param1.'_'.$param2 .'-'. date('Y_m_d_H_i_s') . '_.pdf';
  $pdf->Output("$output", 'D'); // save to file because we can
 // $this->pdf->stream('ack.pdf',array('Attachment'=>0));
  exit();
}

this is single pdf file download. working well. But i want to download muliple pdf file as zip file.that's why i am using foreach to get the parameters.

$data['appinfo_dat'] = $this->User_model->appinfo_dat($dat1,$dat2);

  $i = 0;
       $param1 = [];
    $param2 = [];

  foreach($data['appinfo_dat'] as $key => $val){
   $param1[] = $val['param1'];
 $param2[] = $val['param2'];
kvr
  • 27
  • 7
  • Could you please check this - https://stackoverflow.com/questions/11540339/creating-zip-file – Dmitry Leiko Jan 24 '20 at 09:11
  • That was normally create zip file from uploaded files. But my question is generate pdf file and zip that file. – kvr Jan 24 '20 at 09:27
  • @kvr it's the same. Create PDF -> save it on server -> create ZIP. – shaggy Jan 24 '20 at 09:46
  • Does this answer your question? [Creating .zip file](https://stackoverflow.com/questions/11540339/creating-zip-file) – shaggy Jan 24 '20 at 09:46

0 Answers0