Iftakharul Alam
Iftakharul Alam

Reputation: 3321

Mpdf issue in codeigniter 3

I am working a project in codeigniter 3 and I am using mpdf v5.6. The mpdf example working perfectly but when I integrate mpdf with codeigniter 3 its throws some errors. my controller code is

public function pdf()
    {
        $this->load->library('mpdf');
        $this->mpdf->WriteHTML('<p>Hello There</p>');
        $this->mpdf->Output();
    }

The error as like

A PHP Error was encountered

Severity: 8192

Message: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

Filename: includes/functions.php

Line Number: 74 
Backtrace:

File: /Users/bappa/Desktop/codeigniter/mpdf/includes/functions.php
Line: 74
Function: preg_replace

File: /Users/bappa/Desktop/codeigniter/application/libraries/Mpdf.php
Line: 31062
Function: strcode2utf

File: /Users/bappa/Desktop/codeigniter/application/libraries/Mpdf.php
Line: 12302
Function: purify_utf8

File: /Users/bappa/Desktop/codeigniter/application/controllers/Welcome.php
Line: 29
Function: WriteHTML

File: /Users/bappa/Desktop/codeigniter/index.php
Line: 292
Function: require_once

and at the end of error page

mPDF error: Some data has already been output to browser, can't send PDF file

Where is the problem? Thank you.

Upvotes: 1

Views: 3192

Answers (1)

Niranjan N Raju
Niranjan N Raju

Reputation: 11987

Open that line which is causing the error. I think the error line is this,

 $str = preg_replace('/&#([0-9]+)\;/me', "code2utf('\1',{$lo})",$str);
 $str = preg_replace('/&#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\1',{$lo})",$str);

Replace those lines with,

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

See this issue in github

Upvotes: 4

Related Questions