I'm using FPDF (generate PDF from PHP). I want to show all the items in my array in the table titles, but only some are shown, like the list is too big to fit, but is not properly formatted. I yet don't understand how to move the dimensions for my table header.
This is my code:
<?php
require('fpdf.php');
class PDF extends FPDF
{
//Load data
function LoadData($file)
{
//Read file lines
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
//Colored table
function FancyTable($header,$data)
{
//Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Header
$w=array(40,35,40,45);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf = new PDF('L', 'mm', 'A4');
//Column titles
$header=array('Name','Surname','Date','Start','Br Start','Br End','Start','End','Centre');
//Data loading
$data=$pdf->LoadData('countries.txt');
$pdf->SetFont('Arial','',12);
$pdf->AddPage();
$pdf->FancyTable($header,$data);
$pdf->Output();
?>
In your code:
$w=array(40,35,40,45);
for($i=0;$i<count($header);$i++)
if count($header) > 4 then you're in trouble... which is the case as I see in your screenshot. For the non defined values you will have 0 as the first parameter... which means full width.
PS: turn on error reporting to see your errors, for sure php throws them.