PrestaShop库替换 [英] PrestaShop libraries replacement
问题描述
我使用PrestaShop 1.6.1.4,我想用dompdf更改库tcpdf。
我使用此表单来创建发票。
进行库交换的最佳做法是什么?
我在其中创建的覆盖工具文件夹并且我把我们在这里找到的dompdf-master https://github.com/dompdf/dompdf 。。 p>
相反,我复制了PDFGenerator.php内的override / classes / pdf中,在classes / 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’);
使用Dompdf\Dompdf;
使用Dompdf\Options;
课程变为:
类PDFGenerator扩展DOMPDF
取消render()函数并将其替换为:
公共函数render($ filename,$ display = true)
{
if(empty( $ filename)){
抛出新的PrestaShopException('Missing filename。');
}
$ html = $ this-> header。$ this-> content。$ this->页脚;
// die($ html);
$ options = new Options();
$ options-> set('A4','potrait');
$ options-> set('enable_css_float',true);
$ options-> set('isHtml5ParserEnabled',true);
$ dompdf =新的DOMPDF($ options);
$ dompdf-> load_html($ html);
$ dompdf-> render();
$ dompdf-> stream($ filename);
}
然后我删除了cache / class_index.php
I use PrestaShop 1.6.1.4 and I want to change the library tcpdf with dompdf.
I use this form for creating invoices.
What are the best practices for a library exchange?
I created inside override the tools folder and I put us dompdf-master found here https://github.com/dompdf/dompdf.
Instead inside override/classes/pdf i copied PDFGenerator.php, there is in classes/pdf.
In PDFGenerator.php add:
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;
The class becomes:
class PDFGenerator extends DOMPDF
Eliminates the render() function and replace it with:
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);
}
Then i deleted cache/class_index.php
这篇关于PrestaShop库替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!