This section contains the detail about the Table in PDF.
Table in PDF
In this tutorial you will learn how to generate Table in PDF in a PHP web application. In this tutorial first we have included the fpdf library in our file and again create SimpleTable class that extends FPDF class and override Header(), Footer() function . Inside of SimpleTable class create generateTable() function that create one table and set data . The code of 'table.php' given below :
<?php require('fpdf16/fpdf.php'); class SimpleTable extends FPDF { function Header() { $this->SetFont('Times','B',16); $this->Cell(0,10,'Header',1,0,'C'); $this->Ln(20); } function Footer() { $this->SetFont('Times','B',16); $this->SetY(-190); $this->Cell(0,10,'Footer',1,0,'C'); $this->Ln(20); } function generateTable($no) { for($i=1;$i<=10;$i++) { $this->cell(10,5,$no,1,0,"C"); $this->cell(10,5," * ".$i,1,0,"C"); $this->cell(10,5," = ".$i*$no,1,1,"C"); } } } $pdf=new SimpleTable(); $pdf->AddPage(); $pdf->SetFont('Arial','B',10); $pdf->Cell(0,10,'Generate Table'); $pdf->Ln(); $pdf->generateTable(5); $pdf->Output(); ?>
Output :
[ 0 ] Comments