voilà en essayant plusieurs manières de générer un tableau en pdf (à partir d'un fichier php), j'ai a chaque fois des fatal du type Fatal error: Call to undefined function: basictable().
Je pense donc que ces fonctions ne sont pas reconnues. mais...
<?php
ob_start();//pour éviter l'erreur output
require('fpdf.php');//la librairie d'Olivier(Fpdf)
require('PhpToPdf.php');
$pdf=new FPDF('P','mm','A4'); //je crée mon objet pdf,avec certaine caratéristique facultative
$pdf->AddPage();//je crée la page
$pdf->SetFont("Arial","B",16);
$pdf->Text(90,10,"DUPLEX");
$pdf->Image("./logos/logo.jpg", 90, 12);
class PDF extends FPDF
{
//Chargement des données
function LoadData($file)
{
//Lecture des lignes du fichier
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
//Tableau simple
function BasicTable($header,$data)
{
//En-tête
foreach($header as $col)
$this->Cell(40,7,$col,1);
$this->Ln();
//Données
foreach($data as $row)
{
foreach($row as $col)
$this->Cell(40,6,$col,1);
$this->Ln();
}
}
//Tableau amélioré
function ImprovedTable($header,$data)
{
//Largeurs des colonnes
$w=array(40,35,45,40);
//En-tête
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C');
$this->Ln();
//Données
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR');
$this->Cell($w[1],6,$row[1],'LR');
$this->Cell($w[2],6,number_format($row[2],0,',',' '),'LR',0,'R');
$this->Cell($w[3],6,number_format($row[3],0,',',' '),'LR',0,'R');
$this->Ln();
}
//Trait de terminaison
$this->Cell(array_sum($w),0,'','T');
}
//Tableau coloré
function FancyTable($header,$data)
{
//Couleurs, épaisseur du trait et police grasse
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//En-tête
$w=array(40,35,45,40);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
//Restauration des couleurs et de la police
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
//Données
$fill=0;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,number_format($row[2],0,',',' '),'LR',0,'R',$fill);
$this->Cell($w[3],6,number_format($row[3],0,',',' '),'LR',0,'R',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$header=array('Pays','Capitale','Superficie (km²)','Pop. (milliers)');
//Chargement des données
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->BasicTable($header,'vvv');
$pdf->AddPage();
$pdf->ImprovedTable($header,'vvv');
$pdf->AddPage();
$pdf->FancyTable($header,'vvv');
ob_end_clean();//je clean le header
$pdf->output();//j'affiche ma page
?>
Une idée sur l'erreur et sa solution surtout ?