vandeseer / easytable

Small table drawing library built upon Apache PDFBox
MIT License
246 stars 94 forks source link

Image not centered if row height modified by text #32

Closed hooperbill closed 5 years ago

hooperbill commented 5 years ago

I have a row of cells and in one cell the text wraps causing the row height to increase. One of the cells contains an image and when this row height increase occurs the image is aligned to the bottom of its cell. Setting the vertical alignment to MIDDLE does not affect the image placement.

outputA.pdf outputB.pdf ImageCellSpan.java.txt

vandeseer commented 5 years ago

Thanks for reporting @hooperbill! I will have a look as soon as a find a bit of time. Also I am always open for pull requests ... ;)

Best, Stefan

vandeseer commented 5 years ago

I created a fix that is now merged to the develop branch. Turned out that alignment was only implemented for text cells so far (I didn't really use this feature myself).

So you could build the develop branch and use it already. For a release I want to add some more tests and refactor/tidy up the code a bit which I will do in the next days or rather weeks – depending on my spare time.

hooperbill commented 5 years ago

Many thanks! Will look for time to try out the develop branch.

vandeseer commented 5 years ago

Just released version 0.4.1 which should remedy this issue. Please let me know if it does not. And if you have some nice looking tables to share, please let me know! :smiley:

hooperbill commented 5 years ago

I was able to test version 0.4.1 and the image is correctly centered vertically. But the horizontal centering appears to now be broken. It appears that the image is centered on the image's left edge. This may be simply a math error that does not take the image width into account when calculating the cent. I may have time this week to find a solution. output.pdf

vandeseer commented 5 years ago

A classic: The issue was that the image height was used where the image width should have been used. I didn't see it in the tests though, because I used a quadratic image ... :smile:

vandeseer commented 5 years ago

This is fixed with version 0.4.2 now.