Somepub Posted April 25, 2017 Posted April 25, 2017 I have solution for saving invoices to my server I override the pdf files Here is my code: PDF.PHP <?php class PDF extends PDFCore { public function render($display = true) { if($this->template == PDF::TEMPLATE_INVOICE) parent::render('F', true); //This renders to automatic save return parent::render($display); } } ?> PDFGenerator.PHP <?php class PDFGenerator extends PDFGeneratorCore { public function render($filename, $display = true) { if (empty($filename)) { throw new PrestaShopException('Missing filename.'); } $this->lastPage(); if ($display === true) { $output = 'D'; } elseif ($display === false) { $output = 'S'; } elseif ($display == 'D') { $output = 'D'; } elseif ($display == 'S') { $output = 'S'; } elseif ($display == 'F') { $output = 'F'; $filename = '/place/folder/invoices/print_it/'.str_replace("#", "", $filename); //file name starts with #, replacing for printing } else { $output = 'I'; } return $this->output($filename, $output); } } ?> All is working fine with my automatic invoice save, but when I'm downloading invoice manually(clicking view invoice in adminpanel), I'm getting an error or just a blank pdf file. So I can understand that this problem occurs with PDF.PHP file.. I tried to render both, but that dident help: PDF.PHP <?php class PDF extends PDFCore { public function render($display = true) { if($this->template == PDF::TEMPLATE_INVOICE) parent::render('F', true); parent::render('I', true); return parent::render($display); } } ?> It only renders the first of the parent::render, if parent::render('I', true) was first, I could download invoices manually, but automatic invoice save would be blank Soo.. is there any solution to this? Share this post Link to post Share on other sites More sharing options...
compleus Posted October 21, 2017 Posted October 21, 2017 Hello, Did you find a solution i have the same problem ? thanks in advance Share this post Link to post Share on other sites More sharing options...
Somepub Posted October 23, 2017 Posted October 23, 2017 Hello @compleus, I did found a solution for this! class PDF extends PDFCore { public function render($display = true) { if($this->template == PDF::TEMPLATE_INVOICE && Tools::getValue('printer') == 1) { // Output PDF to local file parent::render('F'); //echo "<script>window.close();</script>"; // added javascript for automatic closure after link print clicked } else { return parent::render($display); // Saving manually } } } The link for downloading pdf: http://www.example.com/admin/index.php?controller=AdminPdf&submitAction=generateInvoicePDF&id_order=3230&print=1 Share this post Link to post Share on other sites More sharing options...
LucasV Posted January 8, 2022 Posted January 8, 2022 Hi @Somepub, I'd like to integrate this aswel on my PS installation. I can't seem to find the pdf.php file. Where do I find these files and where do I override them? Thanks! Lucas Share this post Link to post Share on other sites More sharing options...
LucasV Posted January 8, 2022 Posted January 8, 2022 1 minute ago, LucasV said: Hi @Somepub, I'd like to integrate this aswel on my PS installation. I can't seem to find the pdf.php file. Where do I find these files and where do I override them? Thanks! Lucas Just found the files in classes/pdf/ Now I'm still lokkig for the correct way to override. Share this post Link to post 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