Read 714 times | Created 2013-02-15 01:05:03 | Updated 2013-02-15 01:06:17 | | |
<?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) { $y=0; $x=10; // Header foreach($header as $col) $this->Cell(40,7,$col,1); $this->Ln(); // Data foreach($data as $row) { $y+=25; $this->Image($row[0],$x,$y); $x+=40; $this->Image($row[1],$x,$y); $x+=40; $this->Image($row[2],$x,$y); $x=10; $this->Ln(); } } } $pdf = new PDF(); // Column headings $header = array('Fotocopy KTP', 'Fotocopy KK', 'Fotocopy Slip Gaji'); // Data loading $data = $pdf->LoadData('data.txt'); $pdf->SetFont('Arial','',14); $pdf->AddPage(); $pdf->BasicTable($header,$data); $pdf->Output(); /************************* file data.txt: logo.png;logo.png;logo.png; logo.png;logo.png;logo.png; **************************/ ?>