How to change the vTiger CRM PDF layout

Files used to generate the PDF


/www/vtigercrm//include/fpdf/pdfconfig.php

// Has thing like change items per page and the $bottom variable
/www/vtigercrm/modules/Quotes/CreatePDF.php

// This script retrieves data and assembles parts of the PDF
/www/vtigercrm/modules/Quotes/pdf_templates/

// Files in this directory contain parts of the PDF (header, footer, and last page)

/vtigercrm/include/fpdf/templates/

// Files in this directory contain body parts for invoices, sale orders, and quotes
/vtigercrm/include/fpdf/pdf.php

// This script contains the functions related to layout of invoice PDF’s, such as font size, font style, font color, as well as other settings. Β !!Be careful – always copy your original file and edit the copy.
/vtigercrm/include/fpdf/body.php

// The main body of the invoice. This is the file specified in modules/Invoice/CreatePDF.php You can copy and rename body.php to like body-rev1.php, and edit it as you please, call it out in CreatePDF.php and tweak from there.
/vtigercrm/include/tcpdf/templates/body.php

// vtiger 5.0.4 The main body of the invoice. This is the file specified in modules/Invoice/CreatePDF.php You can copy and rename body.php to like body-rev1.php, and edit it as you please, call it out in CreatePDF.php and tweak from there.

General layout editing


body.php:

  • The x,y,width is specified for the bubble size and position
  • The numbers can be aligned by deleting spaces in the output lines
  • Since CreatePDF.php controls the output for header.php, footer.php and

body.php, move pieces from footer to body if you like, align them and play with the alignment.

  • Check for commented out items regarding sales tax in CreatePDF.php and body.php
  • I added comments from the invoice to the pdf invoice by adding it in CreatePDF and body.php – used mysql to verify the field names were right and it showed up right the first time.

Changing the formating


Text alignment

FILE:

Alignment is controlled by values in an array named “$colsAlign”. For exemple, to center the values in column ‘Total’, change

$colsAlign[“Total”] = “R”;

to

$colsAlign[“Total”] = “C”;

Set font and size

FILE: vtiger/include/fpdf/pdf.php

Change the line:

$this->SetFont( "Helvetica", "", 8);

To whatever you want. There is line for each element in the invoice/quote. One for the table, one for address etc. With the exception of a bubble block which as the names suggests is the block with rounded courners.

Change alignment of company logo

FILE: modules/Invoice/pdf_templates/header.php

To change the alignment of the company logo you need to to go to and change the figures in line 17:

 // ************** Begin company information *****************
 $imageBlock=array("22","6","0","0");

Radius of box curves

FILE: vtigercrm/include/fpdf/pdf.php

Replace ALL values 2.5 and all values 4.5 with a new number greater than 0 i.e. 1.0

 $this->RoundedRect($r1-16, $y1-1, 52, $y2+1, 2.5, 'DF');

Changing the structure


Stop the last page from printing

FILE: vtigercrm/modules/quote/CreatePDF.php

Change the following:

 // would you like and end page?  1 for yes 0 for no
 $endpage="1";

Change to $endpage=”0″; and this will stop the final page from printing.

Vertical lines

FILE: vtigercrm/include/fdpdf/pdf.php

FILE: vtigercrm/include/fdpdf/templates/body.php

The lines and columns may be changed in the /include/fpdf/templates/body.php file.

Ans:The lines between 39 and 59 are for the columns width. The lines from 90 change the contents and the form of the total block To modify the vertical lines have a look at the ./include/fpdf/pdf.php file (from line 328).

Change the products per page

FILE: /include/fpdf/pdfconfig.php

Change the $products_per_page=”6″ variable to whatever you want. This will change it in quotes and invoices. You may also need to change the $bottom variable to inlarge the table.

Change the size of the main table

FILE: /include/fpdf/pdfconfig.php

Change the $bottom variable

Stop an Item from printing

Basic php use // to stop a single line of code from running, if you need to stop a whole segment put a */ before and a /* after.

For example to stop the contact name from printing you would change:

// Contact Name block
$conBlock=array("79","65");
$pdf->addRecBlock($contact_name, "Contact Name",$conBlock);

to:

// Contact Name block
//$conBlock=array("79","65");
//$pdf->addRecBlock($contact_name, "Contact Name",$conBlock);

This way do not have to delete as you may change your mind.

Add in product comments

FILE: vtigercrm/modules/quotes/CreatePDF.php

On line 153 you want to replace this:

$product_name[$i] = $associated_products[$i]['productName'.$i]

with this:

$product_name[$i] = $associated_products[$i]['productName'.$i]."\n-".$associated_products[$i]['comment'.$i];

Custom Fields in PDF

You must change your createpdf.php

Just after populating datas you can add this kind of code. It has been made in order to select customized fields cf_531, cf_545, cf_501 and include them in invoices

Code:

$add_query = "select vtiger_accountscf.* from vtiger_invoice, vtiger_accountscf
where vtiger_invoice.accountid=vtiger_accountscf.accountid AND invoiceid=".$id;
$result = $adb->query($add_query);
$num_rows = $adb->num_rows($result);

if ($num_rows == 1)
{
$reglement=$adb->query_result($result,0,"cf_531");
$mode=$adb->query_result($result,0,"cf_545");
$ntva=$adb->query_result($result,0,"cf_501");
}

Then you can modify your footer or header and include the value of the fields.

Alternative PDF versions


Alternative invoice and quote pdf template are available based from different community contributions:

– see here

and

– see vtiger Forge at http://forge.vtiger.com/projects/crm-now-pdf/

Comments

10 responses to “How to change the vTiger CRM PDF layout”

  1. taylor lautner Avatar

    hi remarkable little site ya got there πŸ™‚ I am using the very same theme on my own but for whatever nutty issue it appears to reload sooner on this blog although your own provides way more multimedia. Are you making use of some plug ins or widgets which speed it up? Do you think you could quite possibly display the widgets so that I can use these on my web pages so twilight new moon followers could watch twilight breaking dawn online trailers and clips faster I would always be pleased – many thanks ahead of time πŸ™‚

  2. Karren Barrieau Avatar

    lolol where’s a beer whenever you need one

  3. Fausto Pagliari Avatar

    I like to visit your blog a couple times a week for new entries. I was wondering if you have any other niches you write about? You’re a very good writer!

  4. SHARON Avatar

    Appreciate your article. It was well said.

  5. Tawanna Mcluen Avatar

    I wish more people would write sites like this that are actually fun to read. With all the garbage floating around on the internet, it is rare to read a site like yours instead.

  6. shipping a car Avatar

    Hey I was just looking at your article on my Drioid and I was thinking about how good it will work on the new ipad thats coming out. Fleeting thought…. Anyway thanks!

  7. bhanu Avatar

    hi
    m using vtigercrm-5.2.1. how to remove the vtigercrm.com link in vtigecrm login page thanks in advance
    thanks&regards
    prasad

  8. no! Avatar
    no!

    Hi, I am confuse with body.php, I do delete those file and nothing happen. Also I do change fpdf and nothing happen. Is it really relate to layout. I want to make layout pdf in one page. Like term and condition in first page. Anyone can help pls. Thanks.

  9. Yes! Avatar
    Yes!

    I know pdf maker can make it, but what I want just from default vtiger pdf. I do remove what inside fpdf folder to new folder -> vtigerCRM\include\fpdf\New Folder and nothing happen! seem it doesn’t relate with layout. I use vtiger 5.30 I want make the layout in one page only, moving term and condiions and description to first page. Anyone can help pls. Thanks.

  10. Phil Zlatkin Avatar

    Hi! Do you know if they make any plugins to help with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success. If you know of any please share. Thanks!|

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.