How to print two parallel tables side by side in iText7, rendering them on one page at at a time and then adding new page

风格不统一 提交于 2020-05-17 03:00:55

问题


I want to add two parallel tables (tables contain content more than one page) side by side in iText7. Rendering should be done as:

Render two tables on page 1, then add new page. Then render remaining part of tables on second page. If they still overflows add another page. Add remaining part of table on page 3 and so on.

Here is the approach that is used in iText5 for this scenario. Main code:

ColumnText[] columns = new ColumnText[2];
columns[0]=column1;
columns[1]=column3;
while (addColumns(columns)) {
    addNewPage(true, pageId, document, writer);
    columns[0].setSimpleColumn(10 * dpiRatio, pageStart * dpiRatio,(10+434) * dpiRatio,pageFooter * dpiRatio);
    columns[1].setSimpleColumn(400 * dpiRatio, pageStart * dpiRatio,800 * dpiRatio,pageFooter * dpiRatio);
}

Helper methods:

public boolean addColumns(ColumnText[] columns) throws DocumentException {
    int status = ColumnText.NO_MORE_TEXT;

    for (ColumnText column : columns) {
        if (ColumnText.hasMoreText(column.go()))
            status = ColumnText.NO_MORE_COLUMN;
    }
    return ColumnText.hasMoreText(status);
}


public void addNewPage(boolean applyHeaderFooter, int pageId,Document document, PdfWriter writer) {
    document.newPage();
    writer.setPageEmpty(false);
}

Kindly suggest the approach like this in iText7.

来源:https://stackoverflow.com/questions/61676551/how-to-print-two-parallel-tables-side-by-side-in-itext7-rendering-them-on-one-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!