vandeseer / easytable

Small table drawing library built upon Apache PDFBox
MIT License
239 stars 91 forks source link

Question: Treat A4 as split page and overflow narrow tables on same page #135

Closed ParvatiD closed 2 years ago

ParvatiD commented 2 years ago

I need to treat A4 page as 2 parts. The table width is never going to be 50% of the page in my requirement. I wanted the table to be overflown to remaining part of the same page. It is like treating A4 sheet as 2 pages split vertically. I am attaching a sample for reference. I wanted to know if this is possible?

SplitPageTable.pdf

vandeseer commented 2 years ago

Hi @ParvatiD

I think that should be possible. You would most probably need to create a custom TableDrawer for that though.

vandeseer commented 2 years ago

For instance it would work with this custom TableDrawer: https://gist.github.com/vandeseer/5c30e093a197efcf55b4ba22090a1c63

ParvatiD commented 2 years ago

Thanks @vandeseer. I will try this out.

ParvatiD commented 2 years ago

Apologies if this sounds like a beginner question. How to enforce extended TableDrawer's draw method? As my call is still invoking base TableDrawer's draw().

OverflowOnSamePageTableDrawer.builder().page(page).contentStream(contentStream).table(table) .startX(PADDING).startY(startY).endY(PADDING).build() .draw(() -> document, () -> new PDPage(PDRectangle.A4), PADDING);

I am getting this constructor error too. Not sure I am missing something.

ConstructorError
grasshopper7 commented 2 years ago

U can have a look at RepeatedHeaderTableDrawer - https://github.com/vandeseer/easytable/blob/409dd63edcdd6ca8e6df4828145480edaaac62ec/src/main/java/org/vandeseer/easytable/RepeatedHeaderTableDrawer.java#L14

vandeseer commented 2 years ago

Hi @ParvatiD, you need to install the Lombok plugin for Eclipse in order to get rid of the warnings/errors. That should do the trick.

vandeseer commented 2 years ago

@ParvatiD I just released a new version of easytable (0.8.5) that includes the OverflowOnSamePageTableDrawer. So if you just upgrade, it should work out of the box.

Let me know if it worked for you.

ParvatiD commented 2 years ago

Thanks @vandeseer. This worked perfectly for me. Appreciate your effort for considering this question as a requirement and getting it implemented.