AJAX HTML Javascript jQuery PHP Example MORE
Need a Website Or Web Application Or Any Help.Contact Us: +91 9437911966 (Whatsapp) Note: Paid Service

FPDF Basic Table


basic-table.php

<?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(';',trim($line));
		return $data;
	}
	/* Simple table */
	function BasicTable($header, $data)
	{
		/* Header */
		foreach($header as $col)
			$this->Cell(38,7,$col,1);
		$this->Ln();
		/* Data */
		foreach($data as $row)
		{
			foreach($row as $col)
				$this->Cell(38,6,$col,1);
			$this->Ln();
		}
	} 
}
$pdf = new PDF();
/* Column headings */
$header = array('Sl No','Name', 'Roll No', 'Class', 'City');
/* Data loading */
$data = $pdf->LoadData('data.txt');
$pdf->SetFont('Arial','',12);
$pdf->AddPage();
$pdf->BasicTable($header,$data);
$pdf->Output();
?>
        

Run it yourself