How To Modify The Invoice Layout


You can choose to have invoices in portrait or landscape mode. The choice is made under Setup->Configuration Settings.

If you choose portrait invoices then there is very limited space to show item descriptions - although invoices will fold better to go in window envelopes.

It is often the case that you wish to adjust where fields or the logo appear on the invoice. To modify the layout of the invoice it is relatively easy to modify the script that produces the pdf invoice report -with just a basic understanding of how pdf reports are created in webERP.

The portrait invoice is created using the script

PrintCustTransPortrait.php

the invoice page headings are created using the script

includes/PDFTransPageHeaderPortrait.inc

the landscape invoice is created using the script

PrintCustTrans.php

the invoice page headings are created using the script

includes/PDFTransPageHeader.inc

If you open the relevant scripts up in an editor with php syntax highlighting you should be able to make english sense of the code as the code is written with long english variable names as far as possible.

The position where fields print out is given by co-ordinates - mostly these are passed to the pdf functions using the variables YPos and XPos - YPos being the vertical coordinate and XPos being the horizontal coordinate.

The pdf reports are oriented so that the origin 0,0 is at the bottom left of the report.

Nearly all PDF reports created in webERP use includes/PDFStarter.php

this script defines the paper sizes and certain variables such as

switch ($PaperSize) {

  case 'A4':

	$DocumentPaper = 'A4'; $DocumentOrientation ='P';

	  $Page_Width=595;
	  $Page_Height=842;
	  $Top_Margin=30;
	  $Bottom_Margin=30;
	  $Left_Margin=40;
	  $Right_Margin=30;
	  break;


These variables defined are used throughout reports.

So the coordinates of the top right corner of a sheet of A4 paper in portrait mode is $Page_Width, $Page_Height. The coordinates of the top right most point where printing is allowed would be

($Page_Height-$Top_Margin), ($Page_Width-$Right_Margin)

The middle of the page is of course $Page_Width/2

Modifying where fields appear on the reports is simply a case of modifying the coordinates where they are printed.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki