2017-08-15 52 views
0

我有一个包含±50个单词的文本。所以我想将它添加在同一小区内 这里是我的代码:如何在同一个单元格中添加多行 - PDF

//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); 

但问题是,文本不填充在细胞中,它打印为一条线,因为它是如下所示:

我怎样才能让文字从右上角开始,在仅此块来填充?

+0

您使用什么库来生成PDF文件? – Phylogenesis

+1

[使用FPDF在单元格中生成文本换行?]可能的副本(https://stackoverflow.com/questions/3477372/make-text-wrap-in-a-cell-with-fpdf) – Phylogenesis

+0

@Phylogenesis \t I也使用'multicell',但它给了我相同的结果。我只在我的php脚本中包含require('fpdf.php')' –

回答

0

认为你正在使用FPDF为PHP ..

看一看多节。你可以在这里\ n换行。

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

您必须自己完成换行。它不会自动添加。

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

相关问题