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
61 stars 11 forks source link

How do you right justify a short piece of text? #7

Closed groliffe closed 5 years ago

groliffe commented 5 years ago

I can see from testTextHorzAlignment test in the PLTextTest class how you should right justify a piece of text, but this only seems to work if the text wraps over multiple lines. If I just have a short piece of text, i.e. "Hello world", then that text never seems to be pushed to the right hand page margin. In fact, setting the alignment to LEFT, CENTER or RIGHT makes no difference.

Is there a way to achieve this?

Cheers

Lance

phax commented 5 years ago

Hi Lance, yes there is :) See the test file test-pltext-horz-alignment.pdf. Basically it depends on the element surrounding the text (like a PLBox). I extended the example you mentioned and it creates this: grafik hth, Philip

groliffe commented 5 years ago

Thanks Philip,

That worked a treat.

Lance