tags:

views:

14

answers:

1

Hi I have generated a pdf using fpdf library. The datas are exported to pdf document i want to set the width of the indivijual column cells how to do that i know some thing has to be done here in this function to increase the width function CalcWidths($width,$align) { //Compute the widths of the columns $TableWidth=0; foreach($this->aCols as $i=>$col) { $w=$col['w']; if($w==-1) $w=$width/count($this->aCols); elseif(substr($w,-1)=='%') $w=$w/100*$width; $this->aCols[$i]['w']=$w; $TableWidth+=$w; } if($align=='C') $this->TableX=max(($this->w-$TableWidth)/2,0); elseif($align=='R') $this->TableX=max($this->w-$this->rMargin-$TableWidth,0); else $this->TableX=$this->lMargin; } what has to be changed

+2  A: 

Width can be assigned the fpdf like this,

 $options = array('cols' =>
                        array('Detail1' => array('width'=>100, 'justification' => 'left'),
                              'Detail2' => array('width'=>400, 'justification' => 'left')
                             )
                       );

But the field values extends then width also increases. Then use like this

$table[] = array(
                array("Detail1" => "D1", "Detail2" => wordwrap($x1, 200, "\n", 1)),
                array("Detail1" => "D2", "Detail2" => wordwrap($x2, 200, "\n", 1)),
                array("Detail1" => "D3", "Detail2" => wordwrap($x3, 200, "\n", 1))
);
Karthik