2015-02-10 29 views
1

我正在使用PHP庫TCPDF。使用MultiCell方法和對齊選項時,我遇到了一個小問題。該段的最後一行證明了(我認爲它應該做到這一點),但只有幾句話留下了很大的空間。這些是我創建的動態表單,因此需要MultiCell(而不是文本或寫入)。段落最後一行的TCPDF調整問題

有誰知道是否有辦法防止這種情況發生,但仍然能夠使用MultiCell方法?過去我使用writeHTML來處理奇怪的問題,並希望儘可能避免。

這裏的代碼產生結果的樣本:

$text = 'This is an example paragraph with no other meaning than to show what is currently happening with this justification issue. I really hope there is a way to keep the '; 
$text .= 'justification, yet keep the last sentence from doing so and looking silly. Thank you all for your help and time, it is much appreciated.'; 
$this->_pdf->MultiCell(0, 0, $text, 0, 'J', false, 1); 

result

非常感謝您的寶貴時間。

回答

3

我不認爲有一個'設置'來處理這個;但是,如果您只是在字符串的末尾添加一個新行(「\ n」),它完全符合我的要求。

所以,如果任何人有類似的問題,答案(在我的情況)是簡單地添加一個新行。

$text = "...last line of the paragraph.\n";