2015-04-03 18 views
5

kullanın.mpdf hatası - preg_replace():/e değiştirici kullanımdan kaldırılmıştır, yerine kodlamada pdf dosyaları oluşturmak için MPDF kullanarak preg_replace_callback yerine

function save_pdf($std_id) 
    { 
    $data['section1_report']= $this->common_model->get_details('tbl_section1',array('id'=>$std_id)); 
    $html = $this->load->view('reports/section1',$data,true); 
     // print_r($html);exit; 
    $this->load->library('pdf'); 
    $pdf = $this->pdf->load(); 
    $pdf->WriteHTML($html); 
    $pdf->Output(); 
} 

benim pdf kütüphanesi gibi benim denetleyici işlevi göz i görünümü dosyasından section1 pdf dosyası oluşturmak istiyorum

<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
    class pdf {  
     function pdf() 
     { 
     $CI = & get_instance(); 
     log_message('Debug', 'mPDF class is loaded.'); 
     } 

    function load($param=NULL) 
    { 
     include_once APPPATH.'/mpdf/mpdf.php';   
     if ($params == NULL) 
     { 
      $param = '"en-GB-x","A4","","",10,10,10,10,6,3';   
     }   
     return new mPDF($param); 
    } 
    } 

olduğunu. i denetleyici işlevini save_pdf çağırdığınızda ancak, ı print_r($html);exit;, bu görünüm file.i tüm içeriği mpdf/includes/functions.php içinde preg_replace_callback yerine preg_replace kullanılan görüntüler zaman ben

enter image description here

aşağıdaki gibi hataları var ama hala görüntüleniyor Bu

enter image description here

gibi hata i mpdf belgeleri inceledi ve düz php düzgün çalışıyor. ama pdf dosyasını Codeigniter içinde oluşturmak istiyorum. mpdf'da bu tür hataları nasıl çözebilirim? Codeigniter'da pdf file'u mpdf kullanarak oluşturabileceğim herhangi bir yardım için minnettarım. teşekkür ederim.

+1

Sadece "CodeDrive ile MPDF" girdim, ör. https://davidsimpson.me/2013/05/19/using-mpdf-with-codeigniter/ – Vickel

cevap

16

deneyin yerine hatları 79 ve bununla functions.php 80:

$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); 

Kaynak:

0

https://github.com/carlholmberg/mpdf/issues/1 yerime başkasının bu çizgiler: Bu satır ile

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

:

$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); 

ve doğru şekilde çalıştı.

0
$str = preg_replace('/\&\#([0-9]+)\;/me', "code2utf('\\1',{$lo})",$str); 
$str = preg_replace('/\&\#x([0-9a-fA-F]+)\;/me', "codeHex2utf('\\1',{$lo})",$str); 
// Remove above and add below code in includes/functions.php 
$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); 

// Also comment below line in mpdf.php 
$html = preg_replace('/\{DATE\s+(.*?)\}/e',"date('\\1')",$html); 
İlgili konular