Hi to all.
I need to add my own html template to the module and generate a PDF.
I made HTMLTemplateCustomPdf.php
<?php class HTMLTemplateCustomPdf extends HTMLTemplate { public $custom_model; public function __construct($custom_object, $smarty) { $this->custom_model = $custom_object; $this->smarty = $smarty; $id_lang = Context::getContext()->language->id; $this->title = HTMLTemplateCustomPdf::l('Custom Title'); $this->shop = new Shop(Context::getContext()->shop->id); } public function getContent() { $this->smarty->assign(array( 'custom_model' => $this->custom_model, )); return $this->smarty->fetch(_PS_MODULE_DIR_.'my_module/pdf/template.tpl'); } public function getFilename() { return 'custom_pdf.pdf'; } public function getBulkFilename() { return 'custom_pdf.pdf'; } }
In the module I call the function for generating PDF:
$custom_object = array('data' => 'test data'); require_once (_PS_MODULE_DIR_ . 'my_module/pdf/HTMLTemplateCustomPdf.php'); $pdf = new PDF($custom_object, 'CustomPdf', Context::getContext()->smarty); $pdf->render();
I get an error:
Can anyone help me with this?
Thank you