B Kirby
B Kirby

Reputation: 283

TCPDF Justification Issue with Last Line of Paragraph

I am using the PHP Library TCPDF. I am running into a small issue when using the MultiCell method and justification option. The last line of the paragraph justifies (I suppose does what it is supposed to) but only with a few words leaving large spaces in between. These are dynamic forms I am creating so MultiCell (instead of text or write) is needed.

Does anyone know if there is a way to prevent this from happening but still be able to use the MultiCell method? I have ran into weird issues in the past using writeHTML for things and want to avoid if possible.

Here is a sample of code producing the result:

$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

Thank you very much for your time.

Upvotes: 3

Views: 3485

Answers (1)

B Kirby
B Kirby

Reputation: 283

I don't think that there is a 'setting' to handle this; however, if you simply put a new line ("\n") at the end of your string it does exactly what I was looking for.

So if anyone is having a similar problem, the answer (in my case) is to simply add a new line.

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

Upvotes: 6

Related Questions