Hi everyone,
I am still looking for the right solution, but while I'm investigating I have to share that @compleus proposal is not the right way to go. First of all, adding a condition "Tools::getValue('printer') == 1" means the pdf file will not be saved when you finally succeed to display the pdf file instead of the blank page with errors inside by clicking on a the link.
Second, even if its not the cause of the issue, you are not required to put an "else" AND a "return" for the normal behavior case. For readability it's best to only use one syntax at a time.
Why removing "else" ? => When you calling the "parent:render()" function with a return, there is no way to access the next "return parent::render($display);" in the same execution cycle.
Additionally, but this is just a personal requirement, I would like the credit notes (oddly named OrderSlip in Prestashop) to also be stored, because like invoices, they are accounting documents that I need to be able to download easily.
So even though the following code doesn't solve the problem of blank PDF while saving it, I show you a more elegant way to write the code:
class PDF extends PDFCore { public function render($display = true) { if(in_array($this->template, [PDF::TEMPLATE_INVOICE, PDF::TEMPLATE_ORDER_SLIP])) return parent::render('F'); return parent::render($display); } }