I have a base64-encoded string on database row. How to create a .pdf file from this encoded string using codeigniter and mpdf ?

 foreach($report as $files)
 /* send email confirmation*/
        $this->data['email'] = TRUE;
        require_once APPPATH.'third_party/MPDF561/mpdf.php';
        $mpdf=new mPDF('c','A4','','',10,10,20,20,10,10);
        $mpdf->SetDisplayMode('fullpage');

        $this->load->helper('custom_email');
        $emailTo        ="email@address.here";
        $emailFrom      =$this->config->item('email');
        $emailSubject   ='Subject Here';
        $emailMessage   ='Your PDF files is here';

        $pdf_base64 = $files['row_pdf'];
        $pdf_base64_handler = fopen($pdf_base64,'r');
        $pdf_content = fread ($pdf_base64_handler,filesize($pdf_base64));
        $pdf_decoded = base64_decode ($pdf_content);

        $mpdf->WriteHTML($pdf_decoded);
        //save to path
        $path = $this->config->item('folder').strip($files['first_name'].' '.$files['last_name'].'.pdf';
        $this->Output($path, 'F');

        send_custom_email($emailTo, $emailFrom, $emailSubject, $emailMessage, array($path));
        //delete from path after send email
        if(file_exists($path))unlink ($path);

from code above i'm not get anything, pdf create failed. no result on $path

do a var_dump($pdf_decoded) after the var assignment and see if you get your decoded content.

Also, Where are you getting send_custom_email() function from? If you have created a custom function, within the same class, it should be $this->send_custom_email()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.