2016-07-21 28 views
-1

我使用PrestaShop 1.6.1.4,我想用dompdf更改库tcpdf。PrestaShop库替换

我使用这个表格来创建发票。

图书馆交流的最佳做法是什么?

+1

欢迎来到Stack Overflow!我尽可能地猜测你的问题,然后编辑你的问题。但是,添加代码和说明以便更多知道该主题的人员将看到它。如果需要识别特定问题,请编辑您遇到的特定错误消息。祝你好运! – manetsus

回答

0

我在里面创建覆盖工具文件夹,我把我们dompdf-master在这里找到https://github.com/dompdf/dompdf

取而代之覆盖/ classes/pdf我复制PDFGenerator.php,有类/ pdf。

在PDFGenerator.php添加:

require_once('/../override/tools/dompdf-master/dompdf/Dompdf.php'); 
require_once('/../override/tools/dompdf-master/autoload.inc.php'); 
include('/../override/tools/dompdf-master/dompdf/dompdf_config.inc.php'); 
use Dompdf\Dompdf; 
use Dompdf\Options; 

类变为:

class PDFGenerator extends DOMPDF 

消除渲染()函数和其替换为:

public function render($filename, $display = true) 
{ 
    if (empty($filename)) { 
     throw new PrestaShopException('Missing filename.'); 
    } 

    $html = $this->header.$this->content.$this->footer; 
    //die($html);  

    $options = new Options(); 
    $options->set('A4','potrait'); 
    $options->set('enable_css_float',true); 
    $options->set('isHtml5ParserEnabled', true); 

    $dompdf = new DOMPDF($options); 
    $dompdf->load_html($html); 

    $dompdf->render(); 

    $dompdf->stream($filename); 
} 

然后我删除高速缓存/class_index.php