PDF Templates

Hello from germany,

can someone provide me the information where to customize the PDF middle part in quotes or invoices...
I just found the header and footer information. But i want, if possible, adjust the rows and row titles.

is it also possible to change the amount shown as 1,000.00 to 1.000,00 ?

thx in advance
best regards richard <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>; <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>;
«13

Comments

  • 25 Comments sorted by Votes Date Added
  • i shall use the invoice module as an example.

    vtigercrm\modules\invoice\pdf_templates

    the above is where you will find the header and footer.

    vtigercrm\modules\invoice\pdf_templates\lastpage

    the above is where you will find the body.

    it is quite easy to edit the layout. the current pdf template has included all the things you will probably ever need. so what i did was copy some of what was already there and change it a bit, and then i deleted quite a lot of what was there too.

    i dont know what the second question is all about i'm afraid.
  • hello audiopleb,

    thank you for the reply. but i still do not know how to modify the body.
    in both folders you mentioned are just two files, header.php and footer.php!?

    so which file did you modify?

    best regards
    tolpan
  • "vtigercrm\modules\invoice\pdf_templates\lastpage\"

    that is where you should find two pages. note that "lastpage" is a folder.

    body.php and footer.php.

    if you have not got these files then... well i dont know.

    try downloading vtiger again? have a look through the files and see if it is there?
  • ok found body.php !

    but ther i can adjust only the lastpage!

    is ist also possible to adjust the firstpage? i need a german version, so i translated already the header.php and footer!

    and i wanted to make the first row bigger.

    thx in advance
    tolpan
  • ok, unlike version 4, the main body.php file for the templates in version 5 is shared between the invoicing and the quotes etc so is not in the same directory as the header and footer php scripts for the modules.

    the body file for the first page for v5 should be under your webroot in the directory: /include/fpdf/templates

    if not then look in the createpdf.php file for the module you are altering.
    near the bottom you will find the $pdf->addpage() function which references the files for the header, body, and footer php scripts.

    look to see where it is referencing the file.

    it may be a good idea for you to copy the body file to the same directory as your header and footer scripts for the module so that you can make changes that don't screw up the other modules <!-- s:) --><img src="{smilies_path}/icon_smile.gif" alt=":)" title="smile" /><!-- s:) -->

    for example, for the quotes module, copy the body.php from the include/fpdf/templates directory to the modules/quotes/pdf_templates directory and then modify the createpdf.php file as follows:

    original entry:
    include("pdf_templates/header.php");
    include("include/fpdf/templates/body.php");
    include("pdf_templates/footer.php");

    modified entry:
    include("pdf_templates/header.php");
    include("pdf_templates/body.php");
    include("pdf_templates/footer.php");

    you can now edit this body file as you wish.

    i just wish they hadn't changed the way the queries in these work as i had my templates working perfectly in 4.2.4 and now have to completely rewrite them again for v5 <!-- s:( --><img src="{smilies_path}/icon_sad.gif" alt=":(" title="sad" /><!-- s:( -->
  • tricky one.

    the basic template draws the boxes for the totals and then before populating each box, creates one $data variable with the label text, the currency symbol and the amount for that total with a number of spaces in between that i suppose are there to keep the totals lined up (i miss my 4.2.4 templates <!-- s:( --><img src="{smilies_path}/icon_sad.gif" alt=":(" title="sad" /><!-- s:( -->).

    so, the first step is to split this into two sections, copy and paste the basic entries for this for each total, the original will be your label text, you can take this opportunity to change the text if you like.

    the copy will just be the total, change the setxy value to position the top corner and use the $pdf->cell command rather than the $pdf-multicell command for this. format as follows (remember that the starting position is the top left corner as specified in the $pdf-setxy command):

    $pdf->cell([cell-length], [cell-height], [data], [border], cellnum], [justify]);

    to explain, cell length is obviously how long the cell should be (if it is a little off on the starting position then change the starting point by altering the appropriate setxy value).

    cell height is how tall each cell should be - in this case the height will always be 6.

    the data will probably be in a variable or combination of variables, if you copied the original entry and modified the contents of the $data var then use that, otherwise use one of the following:

    $price_subtotal is the net total.
    $price_shipping is the total for shipping.
    $price_salestax is the amount of tax/vat/whatever <!-- s:) --><img src="{smilies_path}/icon_smile.gif" alt=":)" title="smile" /><!-- s:) -->.
    $price_shipping_tax is the tax/vat on shipping.
    $price_total is the grand total.

    remember to add the currency symbol.

    you may just want to create your own variable eg if i wanted to get a var called $mytotal for the grand total with the currency symbol then i would use:
    $mytotal="£".$price_total;

    if i wanted to get a single tax figure (in the uk there is only one vat rate so we wouldn't have a seperate entry for shipping) i would use.

    $totalvat=$price_salestax+$price_shipping_tax;
    $mytotal="£".$totalvat;

    note that i did the mathematical calculation on a seperate line...!

    anyway, back to the variables.

    border is a boolean entry for wether you want a line around your cell or not - entirely up to you, 1 for yes, 0 for no.

    cellnum is irrelevant in this case, just set it to 0 and you will be fine.

    justify is fairly straightforward, set it to "l" for left justification, "r" for right justification, or "c" for centred - please use the quotes - they are important.

    put it all together you get:

    $pdf->cell(29, 6, $mytotal, 1, 0, "r");

    to create a single cell starting at the current coordinates for the pdf creator that is 29 long, 6 tall, has a border and is right justified.

    i would give you my code, but since i have completely modified all of the queries etc that would be more likely to confuse you than anything else.

    i hope this helps.

    cheers,
    mike...
  • yes it is a fair job to tackle that is why i would like to see in future releases tha ability to modify most elements in the admin area.
  • thanks for your explicit posts.

    i have changed the body.php so it can be used in spanish.
    i have successfully removed the tax column and product description column.

    the problem i´m facing is that
    can anyone tell me where can i translate:
    - the watermark
    - the headings of customer name, valid till, quote number, etc.

    any help would be appreciatted

    rpw
  • ok,

    the watermark is an easy one since if you change the picklist for the quote or invoice stage through the relevant section of the picklist editor it will just work.
    simply translate the entries with the inbuilt editor to your own language.

    the headings for the body of the quote or invoice are a bit more tricky since the headings are filled in automatically using the headings for the array.

    the section that you want would seem to be where the createpdf.php file for the module in question creates the product_line array.

    specifically you have the following:

    $product_line[$j]["product name"] = $product_name[$i];
    $product_line[$j]["description"] = $prod_description[$i];
    $product_line[$j]["qty"] = $qty[$i];
    $product_line[$j]["price"] = $list_price[$i];
    $product_line[$j]["discount"] = $discount_total[$i];
    $product_line[$j]["total"] = $prod_total[$i];

    this is where the column names are created.
    change the text to whatever you like, but make sure that in the body.php file you change the values of the headings to match the text you use here.

    so, if i was to change "product name" in the quote pdf creator to "my product" i would first edit the modules/quotes/createpdf.php file and change the line from:

    $product_line[$j]["product name"] = $product_name[$i];

    to:

    $product_line[$j]["my product"] = $product_name[$i];

    and then, i would go to the relevant body.php file and find the lines that refer to "product name" and change them accordingly.

    ie: instead of:

    $colsalign["product name"] = "l";

    i would have:

    $colsalign["my product"] = "l";

    and instead of:

    $cols["product name"] = "70";

    i would have:

    $cols["my product"] = "70";

    everything else should stay the same.

    note, don't change your column size value to 70 just because my sample value is 70, leave the number at the size your quote is using.
    i have different values in my own quotes completely and have modified the sizes substantiallû.

    baùically á decideä to useproductcode anl product name rcther thán produët name cnd prodßct descðiption cs it maôches moðe closedy with my old iìvoicing¨system and lets€me put íore liní items ín each zage of çach quote (have that se| at 12 úather t`an the äefault ’* and hkue remoted a fe× of the€totals drom thebottom gf the pcge as i¨don't uye them én the system.
    §
    hope tèis helpy.

    enâoy <!-- s:) --><img src="{smilies_path}/icon_smile.gif" alt=":)" title="smile" /><!-- s:) -->
  • and i completely misread your question - sorry about that, the values you want for the text in the bubbles at the top of the page are under pdf_templates in the header.php file.

    they use the "addrecblock" function of the fpdf library.

    look for the lines:

    $pdf->addrecblock($account_name, "customer name", $termblock);

    $pdf->addrecblock($valid_till, "valid till",$dueblock);

    $pdf->addrecblock($quote_id, "quote number",$invblock);

    just change the text in the quotes accordingly.

    however:
    please note that the addrecblock function of the fpdf library included with vtiger v5 takes the size of the record block to be created by the length of the title.....

    so make sure you either go into the fpdf procedure definition file and change this accordingly or put enough spaces in your title for each of these three record blocks to match the maximum size of your customer names in the database!

    sorry about any confusion caused by my previous post - i answered a question you hadn't actually asked.

    still, i am sure it will be useful for somebody <!-- s:) --><img src="{smilies_path}/icon_smile.gif" alt=":)" title="smile" /><!-- s:) -->
Sign In or Register to comment.