I am having an error when i try using the getOverflowRows() method for tables. I first check if the table can fit on the current page, if it cant then I use the overflow. the PDF is generated and looks awesome when the table fits on the page, but when it has to overflow the PDF is not generated and the logcat shows these errors showing up when the Report.write method is run.
08-20 13:47:03.791: W/System.err(3602): java.lang.NullPointerException
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.pageelements.Group.draw(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.Page.drawAppend(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.Page.drawEntries(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.Page.draw(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.io.n.h(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.io.n.draw(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.Document.draw(Unknown Source)
08-20 13:47:03.801: W/System.err(3602): at com.cete.dynamicpdf.Document.draw(Unknown Source)
here is the section of the code I think I'm having the problem with. ptables is an arraylist of tables, and pages is an arraylist of the pages, and vPos is the Y coordinate that the next element should be placed at, the rest should be easy to figure out.
// set height of first table to whats remaining on the page and then add it to the page
ptables.get(ptables.size() - 1).setHeight(pageHeight - vPos);
pages.get(currentPage).getElements().add(ptables.get(ptables.size() - 1));
// start new page
vPos = 0;
report.getPages().add(pages.get(currentPage));
pages.add(new Page(PageSize.LETTER, PageOrientation.PORTRAIT, 54.0f));
currentPage++;
// calculate height needed for the overflow table then create and add it
overflowHeight = (int) (ptables.get(ptables.size() - 1).getRequiredHeight() - ptables.get(ptables.size() - 1).getHeight() + 50);
Table2 overflow = ptables.get(ptables.size() - 1).getOverflowRows(0, vPos, 500, overflowHeight);
vPos += overflowHeight + 5;
pages.get(currentPage).getElements().add(overflow);
I had a similar error before because I had forgotten to set the column size of the tables, but the sample code didn't show setting the columns for overflow tables so I'm lost as to what I'm doing wrong. thanks in advance for any help.