sitesme Posted November 10, 2013 Share Posted November 10, 2013 Hi, Sometimes PDF invoices go over 1 page and a second page is created sometimes with just 1 line of text. I am trying to maximize the space on my PDF invoices, therefore I was looking to have the invoice like this: http://d.pr/i/5RIo/48JglSxF Basically, the "Invoiced to" box should move to the right side of the "Invoice number" box. Any idea on how to achieve this? I had a look at the invoicepdf.tpl but I have no clue how to do it. Many thanks 0 Quote Link to comment Share on other sites More sharing options...
IgnitionHosting Posted November 10, 2013 Share Posted November 10, 2013 I've had a play with the invoice templates. I believe you'll need to move this code from line 64 onwards $addressypos = $pdf->GetY();$pdf->SetFont('freesans','B',10); $pdf->Cell(0,4,$_LANG["invoicesinvoicedto"],0,1); $pdf->SetFont('freesans','',9); if ($clientsdetails["companyname"]) { $pdf->Cell(0,4,$clientsdetails["companyname"],0,1,'L'); $pdf->Cell(0,4,$_LANG["invoicesattn"].": ".$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L'); } else { $pdf->Cell(0,4,$clientsdetails["firstname"]." ".$clientsdetails["lastname"],0,1,'L'); } $pdf->Cell(0,4,$clientsdetails["address1"],0,1,'L'); if ($clientsdetails["address2"]) { $pdf->Cell(0,4,$clientsdetails["address2"],0,1,'L'); } $pdf->Cell(0,4,$clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L'); $pdf->Cell(0,4,$clientsdetails["country"],0,1,'L'); if ($customfields) { $pdf->Ln(); foreach ($customfields AS $customfield) { $pdf->Cell(0,4,$customfield['fieldname'].': '.$customfield['value'],0,1,'L'); } } to the section commented off as # Header Bar which is on line 45 You'll probably need to make additional changes to get it aligned to the right hand side, but this should get you set in the right direction! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 11, 2013 Share Posted November 11, 2013 the alternative would be to throw it into a html table, invoice numbers and dates on left side, customer address on the right... or perhaps split it into thirds, with the central part empty - i've done this on ours to split invoice no, date and due date. 0 Quote Link to comment Share on other sites More sharing options...
sitesme Posted November 13, 2013 Author Share Posted November 13, 2013 Hi, Thank you for the suggestions, but the idea from IgnitionHosting just moved the client details ABOVE the company details. The point was to get the client details aligned to the right inside the grey box where invoice number / dates are (on the left). I was just able to move a few fields such as city, and country to the same line as the address and remove state as we don't use it, and decreasing a few spacing lines between the different sections. It looks better and I can fit the PDF into one page only for almost all invoices now. Thank you for the alternative brian! but I'm not sure if the HTML code will mess up the PDF generator as I don't see much of HTML in the whole page. I guess there are better ways to create the PDF without HTML code. I just wish I had a little bit of more knowledge on this: http://www.tcpdf.org/doc/code/classTCPDF.html If anyone comes up with an "easy" fix for this, please let me know. I would still prefer to have the customer on the right side of the grey box to maximize the invoice's spacing around the page. Thank you Joel 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 13, 2013 Share Posted November 13, 2013 Hi Joel, Thank you for the alternative brian! but I'm not sure if the HTML code will mess up the PDF generator as I don't see much of HTML in the whole page. I guess there are better ways to create the PDF without HTML code.I just wish I had a little bit of more knowledge on this: http://www.tcpdf.org/doc/code/classTCPDF.html take a look at the code that shows the invoice items in the pdf invoice - it's already using a 100% width html table! it's tweaked into a way tcpdf can handle it, but definitely html. # Invoice Items $tblhtml = '<table width="100%" bgcolor="#ccc" cellspacing="1" cellpadding="2" border="0"> <tr height="30" bgcolor="#efefef" style="font-weight:bold;text-align:center;"> <td width="80%">'.$_LANG['invoicesdescription'].'</td> <td width="20%">'.$_LANG['quotelinetotal'].'</td> </tr>'; foreach ($invoiceitems AS $item) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="left">'.nl2br($item['description']).'<br /></td> <td align="center">'.$item['amount'].'</td> </tr>'; } $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">'.$_LANG['invoicessubtotal'].'</td> <td align="center">'.$subtotal.'</td> </tr>'; if ($taxname) $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">'.$taxrate.'% '.$taxname.'</td> <td align="center">'.$tax.'</td> </tr>'; if ($taxname2) $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">'.$taxrate2.'% '.$taxname2.'</td> <td align="center">'.$tax2.'</td> </tr>'; $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">'.$_LANG['invoicescredit'].'</td> <td align="center">'.$credit.'</td> </tr> <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">'.$_LANG['invoicestotal'].'</td> <td align="center">'.$total.'</td> </tr> </table>'; $pdf->writeHTML($tblhtml, true, false, false, false, ''); it should be pretty straightforward to do what you want by using a table. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 13, 2013 Share Posted November 13, 2013 Joel, check your PM - i've pasted you a fixed invoicepdf.tpl Brian 0 Quote Link to comment Share on other sites More sharing options...
theman777 Posted January 7, 2014 Share Posted January 7, 2014 Joel, check your PM - i've pasted you a fixed invoicepdf.tpl Brian Could you send me that to? That would be great 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 7, 2014 Share Posted January 7, 2014 Could you send me that to?That would be great no problem - PM sent. 0 Quote Link to comment Share on other sites More sharing options...
cosmic Posted January 23, 2014 Share Posted January 23, 2014 Hi, Is it possible to send me a copy of that please? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 25, 2014 Share Posted January 25, 2014 Hi, Is it possible to send me a copy of that please? happy to, but you'll need five posts before you can enable the PM system here. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.