我们在哪里可以指定以pdf格式生成的列的宽度?

时间:2010-07-08 05:42:58

标签: php fpdf

我使用fpdf库生成了pdf。数据导出到pdf文档我想设置单个列单元格的宽度如何做到这一点 我知道在这个函数中必须要做一些事情才能增加宽度 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; } 什么必须改变

1 个答案:

答案 0 :(得分: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))
);