0

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

2
Contributors
1
Reply
13
Views
1 Year
Discussion Span
Last Post by gabrielcastillo
0

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()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.