CJF077 Posted October 9, 2018 Share Posted October 9, 2018 Hi Guys, I have a requirement to make a few minor changes to the PDF. I need to reduce the size of the logo or move the box with the invoice number down a few lines. It is currently covering the logo. Also the transactions box at the bottom, i would like to either remove or add another box which has details of our bank account for transfer of payment. Any help / guidance is appreciated. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 10, 2018 Share Posted October 10, 2018 10 hours ago, CJF077 said: I need to reduce the size of the logo or move the box with the invoice number down a few lines. It is currently covering the logo. $pdf->Image(ROOTDIR . '/assets/img/' . $logoFilename, 15, 25, 75); in the default example in invoicepdf.tpl, those three numbers after the filename are for X position (left->right), Y position (top->bottom) and width (unless specified, height will be calculated to maintain proportion to the width)... therefore, altering that 3rd number (75) will change the size of the logo...though it's not always straightforward as it can make the logo fuzzy when printed, so a few test prints may be required. alternatively, if you want to lower the box, you would increase the number in line ~53... $pdf->Ln(5); 10 hours ago, CJF077 said: Also the transactions box at the bottom, i would like to either remove or add another box which has details of our bank account for transfer of payment. one option to cover both eventualities, would be to wrap the Transactions box with an if statement to check if the invoice is currently unpaid - if it is, there will be no transactions to output and so it outputs payment methods (e.g bank transfer).. otherwise, it outputs the transactions... in summary, there is no point in showing transactions if they haven't paid yet - and if they have paid, there's no point in showing them payment methods! if ($status!="Unpaid") { # Transactions $pdf->SetFont($pdfFont, 'B', 12); $pdf->Cell(0, 4, Lang::trans('invoicestransactions'), 0, 1); $pdf->Ln(5); $pdf->SetFont($pdfFont, '', 9); $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="25%">' . Lang::trans('invoicestransdate') . '</td> <td width="25%">' . Lang::trans('invoicestransgateway') . '</td> <td width="30%">' . Lang::trans('invoicestransid') . '</td> <td width="20%">' . Lang::trans('invoicestransamount') . '</td> </tr>'; if (!count($transactions)) { $tblhtml .= ' <tr bgcolor="#fff"> <td colspan="4" align="center">' . Lang::trans('invoicestransnonefound') . '</td> </tr>'; } else { foreach ($transactions AS $trans) { $tblhtml .= ' <tr bgcolor="#fff"> <td align="center">' . $trans['date'] . '</td> <td align="center">' . $trans['gateway'] . '</td> <td align="center">' . $trans['transid'] . '</td> <td align="center">' . $trans['amount'] . '</td> </tr>'; } } $tblhtml .= ' <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td colspan="3" align="right">' . Lang::trans('invoicesbalance') . '</td> <td align="center">' . $balance . '</td> </tr> </table>'; $pdf->writeHTML($tblhtml, true, false, false, false, ''); } else { #Payment Method $pdf->SetFont('freesans','B',12); $pdf->Cell(0,4,"Payment",0,1); $pdf->Ln(5); $pdf->SetFont('freesans','',8); $paymethhtml = '<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="33%" bgcolor="#efefef" style="text-align:center;"><strong>Bank Transfer</strong></td> <td width="67%" bgcolor="#ffffff" style="text-align:center;">Reference Number: <strong>INV '.$invoicenum.'</strong> Sort Code: <strong>12-34-56</strong> Account Number: <strong>12345678</strong></td> </tr> </table>'; $pdf->writeHTML($paymethhtml, true, false, false, false, ''); } 1 Quote Link to comment Share on other sites More sharing options...
CJF077 Posted October 11, 2018 Author Share Posted October 11, 2018 Great work. Fixed my issue straight away. In regards to the logo, is there anyway to have text on the right hand side, eg website / email address. Currently the invoice has only the logo and no additional contact information. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 11, 2018 Share Posted October 11, 2018 7 hours ago, CJF077 said: In regards to the logo, is there anyway to have text on the right hand side, eg website / email address. Currently the invoice has only the logo and no additional contact information. the usual way to do it would be to enter those details in the Pay To box in General Settings -> General Tab and enter your postal/contact details there... http://help.whmcs.com/m/system/l/698239-change-the-pay-to-address-on-invoices ... and the invoice templates are designed to output those details aligned to the right-hand side of the logo. the other way would be to edit the template directly and add those details in there in the layout of your choice. 0 Quote Link to comment Share on other sites More sharing options...
CJF077 Posted October 12, 2018 Author Share Posted October 12, 2018 15 hours ago, brian! said: the usual way to do it would be to enter those details in the Pay To box in General Settings -> General Tab and enter your postal/contact details there... http://help.whmcs.com/m/system/l/698239-change-the-pay-to-address-on-invoices ... and the invoice templates are designed to output those details aligned to the right-hand side of the logo. the other way would be to edit the template directly and add those details in there in the layout of your choice. I tried this but the formatting appeared to be out. The top was in bold, and larger font and then the rest was in different sizes. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 12, 2018 Share Posted October 12, 2018 8 hours ago, CJF077 said: I tried this but the formatting appeared to be out. The top was in bold, and larger font and then the rest was in different sizes. that's how it's defined by default in the invoicepdf.tpl - it's in a right-aligned cell and the opening line isn't in bold, just a larger font size. # Company Details $pdf->SetXY(15, 42); $pdf->SetFont($pdfFont, '', 13); foreach ($companyaddress as $addressLine) { $pdf->Cell(180, 4, trim($addressLine), 0, 1, 'R'); $pdf->SetFont($pdfFont, '', 9); } so if you were to change that value of 13 to 9, all lines should be the same font size. 0 Quote Link to comment Share on other sites More sharing options...
CJF077 Posted October 13, 2018 Author Share Posted October 13, 2018 13 hours ago, brian! said: that's how it's defined by default in the invoicepdf.tpl - it's in a right-aligned cell and the opening line isn't in bold, just a larger font size. # Company Details $pdf->SetXY(15, 42); $pdf->SetFont($pdfFont, '', 13); foreach ($companyaddress as $addressLine) { $pdf->Cell(180, 4, trim($addressLine), 0, 1, 'R'); $pdf->SetFont($pdfFont, '', 9); } so if you were to change that value of 13 to 9, all lines should be the same font size. Thank you for this. Is there anyway within this to make bold text? A good example would be: Email: email@email.comPhone: 123 456 789Web: www.example.com 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 13, 2018 Share Posted October 13, 2018 On 13/10/2018 at 01:58, CJF077 said: Is there anyway within this to make bold text? once your into the realms of wanting to do that, then it's often easier to use a 100% width table - especially if you're familiar with basic HTML. a basic example would be... # Company Details $pdf->SetXY(15, 42); $pdf->SetFont($pdfFont, '', 9); $companyhtml = '<table width="100%" cellspacing="1" cellpadding="0" border="0"> <tr><td width="70%"></td><td width="10%" align="right"><strong>Email:</strong></td><td width="20%">support@whmcs.com</td></tr> <tr><td width="70%"></td><td width="10%" align="right"><strong>Phone:</strong></td><td width="20%">123 456 789</td></tr> </table>'; $pdf->writeHTML($companyhtml, true, false, false, false, ''); $pdf->Ln(5); when I create custom invoice pdf templates for clients, i'll usually put the logo in the table too and use css styling - this makes it simpler if they want to make minor changes themselves rather than learn the intricacies of TCPDF! another option is to remove the 45-degree status banner to increase available space for your company/contact details, but hopefully the above simple table tweak should be sufficient for your needs. 0 Quote Link to comment Share on other sites More sharing options...
CJF077 Posted October 14, 2018 Author Share Posted October 14, 2018 Thanks this seemed to work but the alignment of the text appears to be out. Any ideas? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 14, 2018 Share Posted October 14, 2018 6 hours ago, CJF077 said: Thanks this seemed to work but the alignment of the text appears to be out. it looks correct to me according to what the above html code is supposed to do - e.g align the text headings to the right... you could remove the align="right" from each table row and that would auto align each to the left (that could look weird). I suppose if you wanted to do it as per your example, you would change it to... $companyhtml = '<table width="100%" cellspacing="1" cellpadding="0" border="0"> <tr><td width="70%"></td><td width="30%"><strong>Email: </strong>support@whmcs.com</td></tr> <tr><td width="70%"></td><td width="30%"><strong>Phone: </strong>123 456 789</td></tr> </table>'; 1 Quote Link to comment Share on other sites More sharing options...
CJF077 Posted October 15, 2018 Author Share Posted October 15, 2018 Great work! Thank you! 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.