blueinferno2001 Posted May 21, 2013 Share Posted May 21, 2013 (edited) Hi everyone, is there a way I can modify the paper size in generated PDF files such as invoices, delivery slips? Thank you Edited June 6, 2013 by blueinferno2001 (see edit history) Link to comment Share on other sites More sharing options...
eleazar Posted May 22, 2013 Share Posted May 22, 2013 (edited) Hi, modifying paper size would mean to modify the complete files in case you won't risk wordwraps or line breaks where they shouldn't be. Or do you just speak of margins? Margins may be modified in function writePage() of /classes/pdf/PDFgenerator.php (lines153-155) : public function writePage() { $this->SetHeaderMargin(5); $this->SetFooterMargin(18); $this->setMargins(10, 40, 10); $this->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); $this->AddPage(); $this->writeHTML($this->content, true, false, true, false, ''); } Paper size can be modified in the same file. Look for function __construct. There must be a line like this: parent::__construct('P', 'mm', 'A4', true, 'UTF-8', $use_cache, false); You may modify size here. Edited May 23, 2013 by eleazar (see edit history) Link to comment Share on other sites More sharing options...
blueinferno2001 Posted May 27, 2013 Author Share Posted May 27, 2013 no, not just the margins but the entire paper size.. i want it to be 21 something left-right and 10 something from top-bottom. i tried changing the 'A4' to 'A5' and set to L (landscape) but it didn't come out as I wanted. as far as i know prestashop only provides templates for A4, A5, A6 (perhaps), letter, legal and a few more. My desired paper size doesn't included in the list. if i need to create my own paper size template, i'd like to know how and where i can put the codes. Link to comment Share on other sites More sharing options...
eleazar Posted May 27, 2013 Share Posted May 27, 2013 Have a look at /tools/pdf/tcpdf.php Search for "Get page dimensions from format name" (must be line 2169) and scroll down to understand what happens here. Link to comment Share on other sites More sharing options...
blueinferno2001 Posted May 28, 2013 Author Share Posted May 28, 2013 I tried adding my own custom size in tcpdf.php line 2486: case 'A42': {$pf = array( 595.276, 431.890); break;} and changed line 47 in classes\pdf\PDFGenerator.php into: parent::__construct('P', 'mm', 'A42', true, 'UTF-8', $use_cache, false); and also line 120 in tool\fpdf\fpdf.php into: $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a42'=>array(595.28,430.89), 'a5'=>array(420.94,595.28), 'letter'=>array(612,792), 'legal'=>array(612,1008)); but the result was again not as I expected. The content still occupied the whole A4 paper while it supposed to fill only the top half. Link to comment Share on other sites More sharing options...
blueinferno2001 Posted June 4, 2013 Author Share Posted June 4, 2013 Hi, it works. I changed parent::__construct('L', 'mm', 'A5', true, 'UTF-8', $use_cache, false); into parent::__construct('L', 'mm', 'A5', true, 'UTF-8', $use_cache, false); looks like it was just a printer issue I had earlier. Link to comment Share on other sites More sharing options...
eleazar Posted June 4, 2013 Share Posted June 4, 2013 Perfect! Would please mark this thread as solved. Link to comment Share on other sites More sharing options...
blueinferno2001 Posted June 6, 2013 Author Share Posted June 6, 2013 how do i mark it solved? Link to comment Share on other sites More sharing options...
eleazar Posted June 6, 2013 Share Posted June 6, 2013 Open your first post with a click on Edit. Then click on More Reply Options. Add a prefix [solved] to the headline. That's all. Link to comment Share on other sites More sharing options...
blueinferno2001 Posted June 6, 2013 Author Share Posted June 6, 2013 i believe you meant "Use Full Editor" done! Link to comment Share on other sites More sharing options...
elevationprint Posted November 3, 2016 Share Posted November 3, 2016 Hi, it works. I changed parent::__construct('L', 'mm', 'A5', true, 'UTF-8', $use_cache, false); into parent::__construct('L', 'mm', 'A5', true, 'UTF-8', $use_cache, false); looks like it was just a printer issue I had earlier. I dont see the difference. What was changed specifically? Link to comment Share on other sites More sharing options...
rocky Posted November 3, 2016 Share Posted November 3, 2016 It seems he changed line 82 (in PrestaShop v1.6.1.8) of classes/PDFGenerator.php: parent::__construct($orientation, 'mm', 'A4', true, 'UTF-8', $use_cache, false); He must have changed it from 'A4' to 'A5'. Try changing it to 'usletter' to see if that gives you the US letter format you want. Link to comment Share on other sites More sharing options...
elevationprint Posted November 3, 2016 Share Posted November 3, 2016 Okay. I get it now. I did try L but that made it a 3x5 card. Link to comment Share on other sites More sharing options...
Tomás Crespo Posted May 17, 2022 Share Posted May 17, 2022 But... this change will affect all PDFs in Prestashop, isn't it? What if I want keep default size (A4) for all documents (invoice, order...) and I only want to change the size of a new pdf document of my custom module (shipment label = A5)? Can I override some class (PDF Generator?) in my module? Thanks 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