We need to make this better!

Suppose you want to put a page header on your report, like that example, John Doe Enterprises, Sales Report. We will need a page element, with 25 lines, 1 pixel border, 500 pixels width, with no cell spacing, cell padding of 5 pixels, with header and footer on it, and on every page I want to see the sum of the value field on it.
The new XML file, sales2.xml, will look like this:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<REPORT>
   <TITLE>Sales Report</TITLE>
   <BACKGROUND_COLOR>#FFFFFF</BACKGROUND_COLOR>
   <PAGE BORDER="1" SIZE="25" CELLSPACING="0" CELLPADDING="5" WIDTH="500">
      <HEADER>
         <ROW>
            <COL COLSPAN="5">John Doe Enterprises</COL>
         </ROW>
         <ROW>
            <COL COLSPAN="5">Sales Report</COL>
         </ROW>
      </HEADER>		
      <FOOTER>
         <ROW>
            <COL ALIGN="RIGHT" COLSPAN="4">page total</COL>
            <COL ALIGN="LEFT" NUMBERFORMATEX="2" TYPE="EXPRESSION">$this->getSum("value")</COL>
         </ROW>
      </FOOTER>		
   </PAGE>
   <GROUPS>
      <GROUP NAME="maingroup">
         <FIELDS>
            <ROW>
               <COL TYPE="FIELD">id</COL>
               <COL TYPE="FIELD">name</COL>
               <COL TYPE="FIELD">city</COL>
               <COL TYPE="FIELD">product</COL>
               <COL TYPE="FIELD">value</COL>
            </ROW>
         </FIELDS>
      </GROUP>
   </GROUPS>
</REPORT>
Create a file similar to sales.php and change $oRpt->setXML("sales.xml") to $oRpt->setXML("sales2.xml") (or you can use the same file, its your choice) and run it on the browser. This time will looks like this:

sales.xml result file

Better, uh? But where's the colors ... wait! We need to see some explanation of the new stuff above before going ahead.
Just take a look on the PAGE element. It haves some attributes like SIZE, CELLPADDING, CELLSPACING and WIDTH.
The most part of the PHPReports elements have a lot of attributes, but a cool way to learn about that is reading the PDF manual and the DTD file.
The DTD file is a validating file where you can submit your XML report file for validation, I mean, to check if everything its ok. You'll need to put a line like this on your XML file:
<!DOCTYPE REPORT SYSTEM "PHPReport.dtd">
				
just after the first line, the xml version blah blah blah. It will allow the validating program to use, on this case, the PHPReport.dtd file to validate your XML file. Believe me, when you make a big or not XML report file, is very useful you validate it before send it to the browser.
You can use a tool like RXP to validate your XML file, the syntax is like this:
rxp -V -o 0 <file.xml>
A important thing that happened on the XML file above is a instruction in the PAGE FOOTER element:
a $this->getSum("value"). What that means?
It means that instruction is part of some methods called grouping methods, that are methods you can use to retrieve a result from the current processing group. Results like sum, min, max, average ... these methods are also more detailed on the PDF manual. You need to use the $this-> reference before the name of the method, to point it to the current group.

One important rule is that everytime you use a grouping function, the COL element must have a TYPE="EXPRESSION" attribute. This way PHPReports will evaluate all the stuff you have on the COL and put the result there. You can use the TYPE="EXPRESSION" attribute to make some hacks too like for example <COL TYPE="EXPRESSION">"the current date is ".date("d/m/Y")</COL> will append the string with the current date and put the value on the COL element.