boxable icon indicating copy to clipboard operation
boxable copied to clipboard

StackOverflowError when drawing a table over multiple pages

Open AndresManuel1 opened this issue 8 years ago • 4 comments

I am creating my table like this:

BaseTable table = new BaseTable(y, 0, 30, 30, 100, 30, doc, page, true, true);

Add a simple header row then add some more content rows. I think I found the issue in your code already. Check out your Table#drawRow method

if (isEndOfPage(row)) {
    endTable();
    pageBreak();
    // redraw all headers on each currentPage
    if (!header.isEmpty()) {
        for (Row<T> headerRow : header) {
            drawRow(headerRow); // <-- THIS RECURSIVE CALL
        }
	removeTopBorders = true;
    } else {
	removeTopBorders = false;
    }
}

On a new page you want to draw your header again, the problem is you are never resetting your variable 'startingY'. The methods endTable() and pageBreak() just create a new page & stream and close the old stream. The result of isEndOfPage(row) is ALWAYS true once you reach the bottom of your first page.

AndresManuel1 avatar Oct 10 '17 18:10 AndresManuel1

hello? can you help with this?

AndresManuel1 avatar Dec 10 '17 14:12 AndresManuel1

If you don't want the headers to be repeated, try creating a normal row and format it as a header on the first page only.

http://quodlibet.be

On Sun, Dec 10, 2017 at 3:29 PM, AndresManuel1 [email protected] wrote:

hello? can you help with this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dhorions/boxable/issues/124#issuecomment-350552102, or mute the thread https://github.com/notifications/unsubscribe-auth/ABmqVKtqdfMNqhx6ci6E_9AQUJcBt9siks5s--rEgaJpZM4P0XUQ .

dhorions avatar Dec 10 '17 14:12 dhorions

I do want the headers repeated, there is just an error in the code...

AndresManuel1 avatar Feb 01 '18 14:02 AndresManuel1

I just ran unit test SampleTest4 and that produces the expected output. Sample attached. BoxableSample4.pdf

So I'm not able to reproduce the issue based on the information you have given. Please provide a complete code sample and example output.

dhorions avatar Feb 01 '18 15:02 dhorions