Ciao, sto utilizzando fpdf per generare una stampa pdf.
Utilizzo il tutorial n.5 che ho modificato in questo modo:

Codice PHP:
class PDF extends FPDF
{
//Load data
function LoadData($file)
{
    
//Path file da stampare
    
$dir 'class/fpdf/filetoprint/';
    
$file$dir$file;

    
//Read file lines
    
$lines=file($file);
    
$data=array();
    foreach(
$lines as $line)
        
$data[]=explode(';',chop($line));
    return 
$data;
}

//Better table
function ImprovedTable($header,$data)
{
    
//Column widths
    
$w=array(10,11,40,55,30,7,8,7,10,10);
    
//Header
    
for($i=0;$i<count($header);$i++)
        
$this->Cell($w[$i],7,$header[$i],1,0,'L');
    
$this->Ln();

    
//Data
    
foreach($data as $row)
    {
        
$this->Cell($w[0],4,$row[0],'1',0,'L',$fill);
        
$this->Cell($w[1],4,$row[1],'1',0,'L',$fill);
        
$this->Cell($w[2],4,$row[2],'1',0,'L',$fill);
        
$this->Cell($w[3],4,$row[3],'1',0,'L',$fill);
        
$this->Cell($w[4],4,$row[4],'1',0,'L',$fill);
        
$this->Cell($w[5],4,$row[5],'1',0,'C',$fill);
        
$this->Cell($w[6],4,$row[6],'1',0,'C',$fill);
        
$this->Cell($w[7],4,$row[7],'1',0,'C',$fill);
        
$this->Cell($w[8],4,$row[8],'1',0,'C',$fill);
        
$this->Cell($w[9],4,$row[9],'1',0,'C',$fill);
        
$this->Ln();
    }
    
//Closure line
    
$this->Cell(array_sum($w),0,'','T');
}

}

$pdf=new PDF();
//Column titles
$header=array('NUM','COD','MARCA','CATEGORIA','COLORE','STG','TIPO','SE','TG','QTA');
//Data loading
$data=$pdf->LoadData('articoli.txt');
$pdf->SetFont('Arial','',6);
$pdf->AddPage();
$pdf->ImprovedTable($header,$data);
$pdf->Output();
?> 

Vorrei poter posizionare ogni elemento dell'header a dx al centro o a sx , come avviene con i dati caricati da loadata.
Ho provato a modificare la funzione

//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'L');
$this->Ln();

in questo modo

//Header

foreach($header as $cols)
{
$this->Cell($w[0],6,$cols[0],'1',0,'L',$fill);
$this->Cell($w[1],6,$cols[1],'1',0,'L',$fill);
$this->Cell($w[2],6,$cols[2],'1',0,'L',$fill);
$this->Cell($w[3],6,$cols[3],'1',0,'L',$fill);
$this->Cell($w[4],6,$cols[4],'1',0,'L',$fill);
$this->Cell($w[5],6,$cols[5],'1',0,'C',$fill);
$this->Cell($w[6],6,$cols[6],'1',0,'C',$fill);
$this->Cell($w[7],6,$cols[7],'1',0,'C',$fill);
$this->Cell($w[8],6,$cols[8],'1',0,'C',$fill);
$this->Cell($w[9],6,$cols[9],'1',0,'C',$fill);
$this->Ln();
}
Purtroppo la formattazione viene completamente sballata.. non riesco a capire dove sbaglio.

Mi date una mano?
Grazie
Ciao