html to pdf using php

I tried to write a php to read csv file and what I want is when someone clicked a link on the webpage it should process the csv file and then convert it in to a pdf file

I need to fix my little coding, I can’t figure out what is the wrong with this code ? please help me…

my code

[php]

require(‘fpdf\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(’;’,trim($line));
return $data;
}

function ImprovedTable($header, $data)
{
// Column widths
$w = array(50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 , 50, 50, 50);
// Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,‘C’);
$this->Ln();
// Data
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,$row[2],‘LR’);
$this->Cell($w[3],6,$row[3],‘LR’);
$this->Cell($w[4],6,$row[4],‘LR’);
$this->Cell($w[5],6,$row[5],‘LR’);
$this->Cell($w[6],6,$row[6],‘LR’);
$this->Cell($w[7],6,$row[7],‘LR’);
$this->Cell($w[8],6,$row[8],‘LR’);
$this->Cell($w[9],6,$row[9],‘LR’);
$this->Cell($w[10],6,$row[10],‘LR’);
$this->Cell($w[11],6,$row[11],‘LR’);
$this->Cell($w[12],6,$row[12],‘LR’);
$this->Cell($w[13],6,$row[13],‘LR’);
$this->Cell($w[14],6,$row[14],‘LR’);
$this->Cell($w[15],6,$row[15],‘LR’);
$this->Ln();
}
// Closing line
$this->Cell(array_sum($w),0,’’,‘T’);
}

$pdf = new PDF();
$header = array(‘Box’, ‘Last6’, ‘Dog Name’, ‘Odds’,‘Best for Trk dist’,‘Total starts’,‘HD Rating’,‘Starts for Trk dist’,‘Trainer’,‘comment’);
$data = $pdf->LoadData(‘APK10825.csv’);
$pdf->ImprovedTable($header,$data);
$pdfdoc->AddPage();

$pdfdoc->SetFont(‘Courier’,‘I’,12);

//$pdfdoc->Cell(40,10,‘Test line’);

$pdfdoc->Output();
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service