mPDF - Error generating PDF | Message: preg_replace ():

4

I'm using mPDF to generate the PDF:

    $this->load->helper('mpdf');
    $this->data['dadosboleto'] = $this->boleto_model->GerarBoletoCEF($id_cliente, $data_inicial, $data_final);
    $this->data['view'] = 'boleto/boleto';
    $this->load->view('tema/topo',$this->data);
    $html = $this->load->view('boleto/boleto_impressao', $this->data, true);
    pdf_create($html, 'boleto_'.$id_cliente."_". date('d-m-Y'), TRUE);

The error you make while generating is:

A PHP Error was encountered

  

Severity: 8192 Message: preg_replace (): The / e modifier is deprecated,   use preg_replace_callback instead Filename: mpdf / mpdf.php Line Number:   31592

This error happens only if I have HTML within the View being generated, if I only have a echo "teste" it works normally.

I'm using the CodeIgniter framework.

Addendum:

Based on our friend Yure's response, it looks like this:

AndthiswouldbehowtoappearcorrectlyinPDF:

Whatcanitbe?Hereistheview: link for being too long, I preferred to put it on PasteBin.

    
asked by anonymous 26.11.2015 / 05:20

2 answers

1

Try to use the following so as not to display the error, but you could also update the library to its latest version:

    error_reporting(E_ALL ^ E_DEPRECATED);

    $this->load->helper('mpdf');
    $this->data['dadosboleto'] = $this->boleto_model->GerarBoletoCEF($id_cliente, $data_inicial, $data_final);
    $this->data['view'] = 'boleto/boleto';
    $this->load->view('tema/topo',$this->data);
    $html = $this->load->view('boleto/boleto_impressao', $this->data, true);
    pdf_create($html, 'boleto_'.$id_cliente."_". date('d-m-Y'), TRUE);
    
26.11.2015 / 14:46
3

As mentioned in the comments, the modifier e (eval) of the functions preg _ * has been discontinued in php5.5 and removed in 7.0, instead the preg_replace_callback () .

To correct the problem, open the problem file, replace the lines with the e modifier with the code below:

$str = preg_replace_callback('/\&\#([0-9]+)\;/m', function($m) use ($lo){return code2utf($m[1],$lo); }, $str);
$str = preg_replace_callback('/\&\#x([0-9a-fA-F]+)\;/m', function($m) use ($lo){return codeHex2utf($m[1],$lo);}, $str);

Based on: mpdf error - preg_replace (): The / e modifier is deprecated, use preg_replace_callback instead

    
26.11.2015 / 18:25