【发布时间】:2017-10-23 13:06:05
【问题描述】:
我需要为我的 prestashop 自定义 .pdf 发票,
问题是做起来太乏味了:
- 更改.tpl
- 生成.pdf
- 预览更改
我想(同时)将发票输出为 HTML,并希望能够使用开发人员工具检查元素..
有什么解决方法吗?我猜想覆盖是可能的,但我在谷歌没有找到任何东西..
【问题讨论】:
标签: html pdf prestashop prestashop-1.6 invoice
我需要为我的 prestashop 自定义 .pdf 发票,
问题是做起来太乏味了:
我想(同时)将发票输出为 HTML,并希望能够使用开发人员工具检查元素..
有什么解决方法吗?我猜想覆盖是可能的,但我在谷歌没有找到任何东西..
【问题讨论】:
标签: html pdf prestashop prestashop-1.6 invoice
您可以通过将 classes/pdf/PDF.php 中的 render 函数覆盖为:
public function render($display = true)
{
$render = false;
$this->pdf_renderer->setFontForLang(Context::getContext()->language->iso_code);
foreach ($this->objects as $object) {
$this->pdf_renderer->startPageGroup();
$template = $this->getTemplateObject($object);
if (!$template) {
continue;
}
if (empty($this->filename)) {
$this->filename = $template->getFilename();
if (count($this->objects) > 1) {
$this->filename = $template->getBulkFilename();
}
}
$template->assignHookData($object);
// for previewing html
echo $template->getHeader();
echo $template->getContent();
echo $template->getFooter();
exit;
$this->pdf_renderer->createHeader($template->getHeader());
$this->pdf_renderer->createFooter($template->getFooter());
$this->pdf_renderer->createPagination($template->getPagination());
$this->pdf_renderer->createContent($template->getContent());
$this->pdf_renderer->writePage();
$render = true;
unset($template);
}
if ($render) {
// clean the output buffer
if (ob_get_level() && ob_get_length() > 0) {
ob_clean();
}
return $this->pdf_renderer->render($this->filename, $display);
}
}
为页眉、内容和页脚添加了回显。对于分页,我不确定它是如何工作的,还没有测试过。
【讨论】:
我找到了这个:https://github.com/itext/rups/。
如果您想了解更多详细信息,我们在 StackOverflow 中有一个帖子:
Best tool tool for inspecting PDF files?
【讨论】: