TiMa123 Posted August 19, 2010 Share Posted August 19, 2010 Hi guys,There's a problem that I'm facing right now. The addresses of some of my customers are so big that they do not fit on one line. When I create an invoice for them, the address screws up - as in, it's too big to display and everything displays on the same line. Therefore, delivery address & invoice address both overlap with each other and it looks like one stretched line with lot of over-written content.I need a bit of help in getting big addresses to two lines or need be 3 lines. Any idea how I should go about it?I'm aware that I have to edit the PDF.php file in classes, and I'm assuming this is the code I have to edit. $pdf->Ln(5); $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address1), 0, 'L'); $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address1), 0, 'L'); $pdf->Ln(5); if (!empty($invoice_address->address2) OR !empty($delivery_address->address2)) { $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address2), 0, 'L'); $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address2), 0, 'L'); $pdf->Ln(5); PS: One of the customizations that has been done on my store is to append Address (2) to Address (1) when an address is being entered. This was done to increase usability.Please help! Link to comment Share on other sites More sharing options...
rocky Posted August 20, 2010 Share Posted August 20, 2010 Try changing lines 400-402 of classes/PDF.php (in PrestaShop v1.3.1) from: $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address1), 0, 'L'); $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address1), 0, 'L'); $pdf->Ln(5); to: $delivery_address1 = split("\n", wordwrap($delivery_address->address1, 50)); $invoice_address1 = split("\n", wordwrap($invoice_address->address1, 50)); for ($i = 0; $i < max(sizeof($delivery_address1), sizeof($invoice_address1)); $i++) { $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), isset($delivery_address1[$i]) ? $delivery_address1[$i] : ''), 0, 'L'); $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), isset($invoice_address1[$i]) ? $invoice_address1[$i] : ''), 0, 'L'); $pdf->Ln(5); } Change 50 to the maximum number characters per line. Link to comment Share on other sites More sharing options...
TiMa123 Posted August 20, 2010 Author Share Posted August 20, 2010 Works awesome as always. Thanks for the help man! 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