OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

Blank Page after PTable added into Document

Open chaco89 opened this issue 5 years ago • 5 comments

I added the Ptable into document class. I realize if the element is Element.PTABLE it will create a new line through newLine method which create a blank page on my pdf even it's fit on one page. it will create the newPage if this condition fulfilled. "currentHeight + line.height() + leading > indentTop() - indentBottom()" For example : my current height is 534, It should be fitted in one page. I don't want to create a new page. 534.0 + 16.0 + 16.0 > 580.8268 - 44.0 i get a new page because the condition is true (line.height() + leading) Is it possible to set the line.height or leading for PTable ? or how to remove a new line ?

case Element.PTABLE: {
                    PdfPTable ptable = (PdfPTable)element;
                    if (ptable.size() <= ptable.getHeaderRows())
                        break; //nothing to do

                    // before every table, we add a new line and flush all lines
                    ensureNewLine();
                    flushLines();

                    addPTable(ptable);
                    pageEmpty = false;
                    newLine();  // This line create a new line after p table added
                    break;
                }

I think newLine() method should be removed, i didn't see Table or SimpleTable call newLine() method after call addPTable method

chaco89 avatar Jul 10 '19 07:07 chaco89

I second this. As a result of this, a blank page is added after a table which has ExtendLastRow set to true and thus if the table is the last element of the document a trailing blank page remains.

renber avatar Jun 22 '20 10:06 renber

Can anybody confirm, if this is still an issue? Or already solved? If not, pull requests are still welcome.

asturio avatar Mar 08 '24 19:03 asturio