ps8modules Posted March 24, 2021 Share Posted March 24, 2021 (edited) 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 Edited March 25, 2021 by WebSoft (see edit history) Link to comment Share on other sites More sharing options...
ps8modules Posted March 25, 2021 Author Share Posted March 25, 2021 (edited) No help? I need to create my own tpl template. I need to send data to a tpl template. I need to create a PDF from both FO and BO. Is it really that complicated? Tested: https://belvg.com/blog/pdf-in-prestashop.html NOT WORK ! Edited March 25, 2021 by WebSoft (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted May 5, 2021 Share Posted May 5, 2021 What is your PrestaShop version? I see the error: get_class() expects parameter 1 to be object, string given. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now