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

发布于 2024-09-08 18:21:27 字数 582 浏览 1 评论 0原文

我已经使用 fpdf 库生成了 pdf。数据导出到 pdf 文档我想设置各个列单元格的宽度如何做到这一点 我知道在这个函数中必须做一些事情来增加宽度 函数 CalcWidths($width,$align) { //计算列的宽度 $表格宽度=0; foreach($this->aCols as $i=>$col) { $w=$col['w']; 如果($w==-1) $w=$width/count($this->aCols); elseif(substr($w,-1)=='%') $w=$w/100*$宽度; $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); 别的 $this->TableX=$this->lMargin; } 必须改变什么

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅沫记忆 2024-09-15 18:21:27

宽度可以像这样分配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))
);

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))
);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文