Jump to content

Modifying layout of customer information at top of invoicepdf.tpl

Recommended Posts

By default, the invoicepdf.tpl file displays the Invoice # (# Header Bar) information and then the Bill To (# Clients Details) information in the PDF with the two sets of data laid out vertically (see attached). Our preference is to have these two items laid out side by side / horizontally for aesthetics and to eliminate creating unnecessary pages. The end results should be similar to the layout WHMCS uses on their invoices.


I looked at setting up a table and simply moving the existing code into the columns but I can't get the logic right. The code below details the existing logic for the two items in question.


Are there any suggestions on how to restructure this so it is laid out horizontally?


Thanks in advance!!


Vinny with Happy Cow Studios

c'mon, get happy!


# Header Bar
$invoiceprefix = $_LANG["invoicenumber"];
** This code should be uncommented for EU companies using the sequential invoice numbering so that when unpaid it is shown as a proforma invoice **
if ($status!="Paid") {
   $invoiceprefix = $_LANG["proformainvoicenumber"];
$pdf->Cell(0,6,$_LANG["invoicesdatecreated"].': '.$datecreated.'',0,1,'L','1');
$pdf->Cell(0,6,$_LANG["invoicesdatedue"].': '.$duedate.'',0,1,'L','1');

$startpage = $pdf->GetPage();

# Clients Details
$addressypos = $pdf->GetY();
if ($clientsdetails["companyname"]) {
   $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');
if ($clientsdetails["address2"]) {
$pdf->Cell(0,4,$clientsdetails["city"].", ".$clientsdetails["state"].", ".$clientsdetails["postcode"],0,1,'L');
if ($customfields) {
   foreach ($customfields AS $customfield) {
       $pdf->Cell(0,4,$customfield['fieldname'].': '.$customfield['value'],0,1,'L');


Link to comment
Share on other sites

Thanks so much for the prompt reply.


I concur it would be best / easiest to do this with an html table but I have not been able to figure out what the code should like like to create a table with two cells. Can you enlighten me?



the easiest way would be to do it as a 100% width html table - two cells, 50% each.
Link to comment
Share on other sites

here's a sample from an invoice template design that I did for a client - it's a 100% html table split into 3 that shows the invoice number, invoice date and due date on one line (also to save space)...


for you, you would take out one of the table columns and change the 33% to 50% - and then you should be good to go! :idea:




$invhtml = '<table width="100%" cellspacing="1" cellpadding="2" border="0">
   <tr height="30" style="text-align:center;">
       <td width="33%"><strong>Invoice Number: </strong>'.$invoicenum.'</td>
       <td width="33%"><strong>Invoice Date: </strong>'.$datecreated.'</td>
       <td width="33%"><strong>Due Date: </strong>'.$duedate.'</td>

$pdf->writeHTML($invhtml, true, false, false, false, '');

Link to comment
Share on other sites

Hi brian!,


You have been a big help with my questions. I understand the above logic and it works great with the changes but what I can't figure out it how to embed the # Header Bar and # Customer Details into the table. Can you provide me some direction?


Thanks again. Your help has been spot on!



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated