PrestaShop库更换

时间:2016-07-21 07:44:25

标签: php prestashop prestashop-1.6 dompdf

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

我使用此表单创建发票。

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

1 个答案:

答案 0 :(得分:0)

我创建了内部覆盖工具文件夹,我在这里找到了dompdf-master http://prntscr.com/bwxclx

相反,在override / 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

消除render()函数并将其替换为:

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

然后我删除了cache / class_index.php