I'm using FPDF and I want to generate tables using MultiCell()
since I need the word wrap property of it. Tried Cell()
but it can't read the word wrap. If I used MultiCell()
property then table all rows shows vertically.
If I used multicell()
so my pdf data shows vertically. Please suggest me how to do vertical to horizontal.
I tried code:
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, $pdf)
{
// Header
foreach($header as $col)
$this->Cell(40, 20, $col, 1, 0, 'C', false);
$this->Ln();
// Data
foreach($data as $row)
{
foreach($row as $col)
//$word = str_word_count($col);
//$this->MultiCell(30, 10,$col, 0, 'J', 0, 1, '', '', true, null, true);
//$this->word_wrap($pdf,$col);
//$this->cell(40,6,$col,1);
$this->MultiCell(40,6,$col,1);
$this->Ln();
}
}
}
$pdf = new PDF('P','mm',array(600,600));
// Column headings
$header = array('Waybill', 'Order@No', 'Consignee Name', 'Consignee Pincode', 'Consignee City', 'Weight', 'COD Amount', 'Product', 'Shipping Client', 'Seller Name', 'Seller Pincode', 'Seller City');
// Data loading
$data = $pdf->LoadData('countries.txt');
$pdf->SetFont('Arial','',14);
$pdf->AddPage();
$pdf->BasicTable($header,$data, $pdf);
$pdf->Output();
Or please suggest me how to word wrap the text