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

padding in nested tables #21

Closed martin19 closed 2 years ago

martin19 commented 3 years ago

Hi @phax,

I might have found a bug with nested tables.

The outer table has two columns and n rows. The table spans multiple pages (this might not be relevant though) Each row is set up like this:

It seems the first cells paddings are not respected in the second columns cell height computation - the cells in each row do not align vertically, the first column is higher in total (I assume by 2*padding). When I remove the first cell's padding the cells are aligned vertically.

I'll provide a test case if that is required.

image

phax commented 3 years ago

@martin19 thanks for pointing that out. I added a small example snippet that should outline the issue. When I run this, it creates the following output: issue21.pdf

If you are referring to the issue, that the cell border is "broken", than I would say, that works as designed, because the next row starts again evenly. The height of the row is the maximum height of the contained cells. But the border is pained around each cell, and not around each row.

The only error that I could discover is the bottom padding of the inner table - depicted with a black block in the below image: grafik

So please clarify what exactly your expectations are. If you dislike the border than I recommend to change new PLTableCell (new PLText (...)).setPadding to new PLTableCell (new PLBox (new PLText (...)).setPadding ()) - so to wrap the text in a "PLBox" and put the padding on the box instead, See this PDF for comparison: issue21a.pdf Looking like this: grafik

hth

martin19 commented 3 years ago

hi @phax I've found the solution you mention by putting the padding on the inner element of the cell, thanks for pointing that out. I think I expected all cells in a row to have equal height always (including borders like html tables). You can call this a feature to have this kind of staircase table - I don't wanna bargain on that. The reason I'm doing all this is to "emulate" rowspan/colspan: the inner table has no outer border so it beautifully blends with the cell borders of the outer table - Is there a better way to do this?

I've only had some minor issues (yet) that might interest you:

Thanks you for your work.

phax commented 3 years ago

Thanks for your feedback. What you may want to emulate is "padding" on the row of the outer table I guess. This can be done by calling setPadding which will effectively set it on all contained cells...

martin19 commented 3 years ago

Hi @phax, thank you for the setDebugRender tip. That will probably make it lots easier to see what is going on. With full size header I actually meant full-width.

There is a problem I've been thinking about. Is it possible to determine the actual position of the currently rendered object in the page? I'd like to implement a policy for inserting page breaks depending on the amount of content that is on the current page. If yes - great - if no what would be the effort to implement such thing.

Thank you!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.