【问题标题】:How can I add multiple rows in the same cell - PDF如何在同一个单元格中添加多行 - PDF
【发布时间】:2018-01-23 02:36:12
【问题描述】:

我有一个包含 ±50 个字的文本。所以我想将它添加到同一个单元格中 这是我的代码:

//header
$this->SetX(30);
$this->Cell(270, 20, "Suggested Improvement ",0, 0, 'C', true);

$this->SetX(300);
$this->Cell(270, 20, "Current Situation ",0, 0, 'C', true);


//data retrieved from DB
$this->Ln(20);
$this->SetTextColor(0); 
$this->SetFillColor(19, 68, 160);
$this->SetLineWidth(0.25);

$this->SetX(30.5);
$this->Cell(269, 100,$row1['Suggested Improvement'], 1, 0, 'C', false);

$this->SetX(300);
$this->Cell(269.5, 100,$row1['Current Situation'], 1, 0, 'L', false);

但问题是文本没有填充到单元格中,它打印为一行,如下所示:

如何使文本从右上角开始并仅填充在此块中?

【问题讨论】:

  • 您使用什么库来生成 PDF 文件?
  • @Phylogenesis 我也使用了multicell,但它给了我相同的结果。我只在我的 php 脚本中包含了require('fpdf.php')

标签: php pdf fpdf


【解决方案1】:

认为您正在使用 fpdf for php..

看看 MultiCell。在那里你可以使用 \n 换行。

$this->MultiCell(100,8,"Line 1\n Line2");

您必须自己进行换行。它不是自动添加的。

在这里您可以使用 GetStringWidth 检查 witdh 并添加一些换行符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    • 2012-02-25
    • 2023-03-21
    • 1970-01-01
    • 2011-05-21
    • 2015-04-02
    相关资源
    最近更新 更多