vandeseer / easytable

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

row does not fit on page #87

Closed djcanard closed 4 years ago

djcanard commented 4 years ago

I want to generate a pdf based on a form filled in by the user. This text might be longer than one page.

Now I get an error org.vandeseer.easytable.RowIsTooHighException: There is a row that is too high to be drawn on a single page

I can't find any clues in the docs or tests. How can I handle this?

vandeseer commented 4 years ago

Hi @djcanard,

the exception itself conveys the message already: The height of the text (according to the specific settings like font, font size, line spacing etc.) is simply higher than what can be drawn on the page (again according to the settings like the starting point of the table etc.).

So how can you handle this? What you need to do is to check the text height beforehand and add another row should it be necessary. You can use methods from PdfUtil.java and check how it's done in the text cells.

Hope this helps, Stefan

djcanard commented 4 years ago

Thanks for your quick response! I looked into it but I find it quite hard to wrap my head around the non-intuitive building of the pdf content with PDFBox :)

pradhan-v commented 4 years ago

Hi @djcanard,

the exception itself conveys the message already: The height of the text (according to the specific settings like font, font size, line spacing etc.) is simply higher than what can be drawn on the page (again according to the settings like the starting point of the table etc.).

So how can you handle this? What you need to do is to check the text height beforehand and add another row should it be necessary. You can use methods from PdfUtil.java and check how it's done in the text cells.

Hope this helps, Stefan

@vandeseer, The cell height can be calculated and we can make a decision whether to split the row or not. This works fine for regular tables. Won't this cause issues with tables having multiple columns with rowSpan ? Please let us know how we can handle this.

Pandoors commented 3 years ago

How can I use the getTextHeight() from AbstractTextCell without getting nullpointer? I guess that this method is initialized during cell building process but I need to split the cell before that happens. Any clue? I'd be very thankful for tips