问题
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