<?

    
//reference the class so you can use it
    
require_once('../tcpdf/tcpdf.php');

    
// create new PDF document
    
$pdf = new TCPDF(PDF_PAGE_ORIENTATIONPDF_UNITPDF_PAGE_FORMATtrue); 

    
//do not show header or footer
    
$pdf->SetPrintHeader(false); $pdf->SetPrintFooter(false);

    
// add a page - landscape style
    
$pdf->AddPage("L");

    
// set font
    
$pdf->SetFont("freeserif"""11);
    
    
/////////////////////////////////////////////
    //        START TABLE HEADER
    /////////////////////////////////////////////
        
    //Colors, line width and bold font for the header
    
$pdf->SetFillColor(1147132); //background color of next Cell
    
$pdf->SetTextColor(255); //font color of next cell
    
$pdf->SetFont('','B'); //b for bold
    
$pdf->SetDrawColor(0); //cell borders - similiar to border color
    
$pdf->SetLineWidth(.3); //similiar to cellspacing
    
    
$cols=array('Rank','Player','Pts. Avg.','Total Pts.');//Column titles 
    
$width=array(20,50,40,30); //amount of elements must correspond with $header array above
    
    
for($i=0;$i<count($cols);$i++)
    {
        
//void Cell( float $w, [float $h = 0], [string $txt = ''], [mixed $border = 0], 
        //[int $ln = 0], [string $align = ''], [int $fill = 0], [mixed $link = ''], [int $stretch = 0])  
        
$pdf->Cell($width[$i],7,$cols[$i],1,0,'C',1); 
    }
    
    
$pdf->Ln(); //new row
    
    ////////////////////////////////////////////////
    //        START TABLE BODY
    ////////////////////////////////////////////////

    //styling for normal non header cells
    
$pdf->SetTextColor(0); //black
    
$pdf->SetFont('',''); 

    
//the data - normally would come from DB, web service etc. 
    
$rank = array('1','2','3');
    
$player = array('Tiger Woods,  USA','Phil Mickelson,  USA ','Padraig Harrington,  Irl ');
    
$playerWWW = array('http://tigerwoods.com/','http://philmickelson.com/','http://padraigharrington.com/');
    
$avgPts = array('10','9','8');
    
$totPts = array('100','90','80');

    
//create & populate table cells
    
for($i 0$i count($rank); $i++)
    {
        if(
$i == "2")//highlight Harrington because he Irish...
        
{
            
$pdf->SetFillColor(89239152); //green
        
}
        else
        {
            
$pdf->SetFillColor(255); //white
        
}
        
        
$playerANDlink "<a href=\"$playerWWW[$i]\">$player[$i]</a>";
        
        
//int MultiCell( float $w, float $h, string $txt, [mixed $border = 0], [string $align = 'J'], 
        //[int $fill = 0], [int $ln = 1], [int $x = ''], [int $y = ''], [boolean $reseth = true], 
        //[int $stretch = 0], [boolean $ishtml = false]) 
        
$pdf->MultiCell($width[0],7,$rank[$i],1,'C',1,0,'','',1,0,1); 
        
$pdf->MultiCell($width[1],7,$playerANDlink,1,'C',1,0,'','',1,0,1); 
        
$pdf->MultiCell($width[2],7,$avgPts[$i],1,'C',1,0,'','',1,0,1);
        
$pdf->MultiCell($width[3],7,$totPts[$i],1,'C',1,0,'','',1,0,1);
        
        
$pdf->Ln(); //new row
    
}

    
//output the PDF to the browser
    
$pdf->Output("./pdfs/example.pdf""F"); //F for file

?>