phax / ph-pdf-layout

Java library for creating fluid page layouts with Apache PDFBox. Supporting multi-page tables, different page layouts etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PLText rendering problem when horizontal alignment is set to JUSTIFY

istvangaal opened this issue · comments

There is a problem with rendering PLText when its horizontal alignment is set to "JUSTIFY" like this:

PLText.setHorzAlign(EHorzAlignment.JUSTIFY)

It seems that the space between the characters are stretched, not between the words. You can see it when there is line break (e.g. after "Hello Alex") and at the page break:

image

Could you please fix it or is there any workaround for this issue?

Regards,
Istvan

I have found a topic related to this problem, this may help:
https://stackoverflow.com/questions/20680430/is-it-possible-to-justify-text-in-pdfbox

Regards,
Istvan

From my Word user perspective I would say that is the difference between "justify" (as the image above) and "block" mode, like justify but with an exemption for the last line. Let me see what I can do....

Not only for the last line: for the last line of EACH PARAGRAPH (at line breaks)

And at the automatic PAGE BREAK there should be justified, currently it is not, see above image (the text continues on the next page, I forgot to copy here that page, sorry)

@phax: how do you see: is this a big issue or can be implemented soon?

Regards,
István

Shouldn't be too hard to do, but you caught me in the middle of the conference and vacation phase. Please stay patient :)
The solution will most likely be a new enum entry BLOCK or so to deal with that.

@istvangaal I created the updated version with the new EHorzAlignment.BLOCK enum entry and this outcome:
horz-alignment.pdf

I assume that suits your needs, right? If so, I will buid a release version asap

Wow, thank you, that looks good! Please notify me when the new release is available!

Release 7.3.3 is out, and will be on Maven Central soon.

@phax Thank you for the quick release, I tried it and works almost perfectly! The only problem is at the PAGE BREAKs, because the last line at the end of a page is not justified. Here is an example:
End of a page:
image
Next page:
image

This problem occures at least in BLOCK and JUSTIFY horizontal alignments (PLText)

Could you do something with this?

Regards,
Istvan

Ah yes - that makes sense. Let me check

Build 7.3.4 now

It works, thank you!