phax / ph-pdf-layout

Java library for creating fluid page layouts with Apache PDFBox. Supporting multi-page tables, different page layouts etc.
Apache License 2.0
64 stars 11 forks source link

Still justify the last line of multiline text #8

Closed RangerMak closed 4 years ago

RangerMak commented 4 years ago

I'm using ph-pdf-layout4 v5.0.9.

Next code still justify the last line of text:

String lorem = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
          + "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
          + "aliquyam erat, sed diam voluptua. At vero eos et accusam et justo "
          + "duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata "
          + "sanctus est Lorem ipsum dolor sit amet.\n\n";

pagesSet.addElement(new PLText(lorem, regularFont12).setHorzAlign(EHorzAlignment.JUSTIFY));

Screen fragment: https://ibb.co/GtKNw4g

Is something wrong in my code? Or it's bug/feature?

phax commented 4 years ago

Hi @RangerMak the problem is the trailing "\n\n". If you remove them (or .trim()) than the last line should be fine.

RangerMak commented 4 years ago

Thanks. It works.

It's pity there is no internal newLine element. It can be helpful for creating new paragraph.

phax commented 4 years ago

Thanks for confirming this. Well there is the PLSpacerY element to add a vertical space.... hth