2010-07-08 65 views
1

我使用fpdf庫生成pdf。的的數據都是導出爲PDF文件我想設置indivijual列單元格的寬度,如何做到這一點 我知道有些事情必須要在這裏完成這一功能,以增加寬度 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; } 什麼改變我們可以在哪裏指定在pdf中生成的列的寬度?

回答

2

寬度可以像這樣指定爲fpdf,

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

但是字段值擴展後寬度也增加。然後像這樣使用

$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)) 
); 
相關問題