2017-08-15 51 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並添加一些換行符。

相關問題