Hi Team,
I was trying to create a table inside a page in PDF(Aspose Java). table data is more that 100 rows due to this rows are moving to different page without adding new page due to this in footer page number is not working as expected.
can you please provide a solution for this so that it will add page dynamically while table rows are adding in next page. or any solution to identify that page content is full so that manually I can add new page.
Can you please share your complete code snippet for our reference that you are using to add the table along with sample PDF document? We will test the scenario in our environment and address it accordingly.
TEST.pdf (63.1 KB)
public void createPdf(){
Document document = new Document();
addTable(document);
addFooterInformation(document);
}
private void addTable(Document document) {
Page page = document.getPages().add();
Table table = new Table();
page.getParagraphs().add(table);
table.setColumnWidths("175 100 100");
MarginInfo margin = new MarginInfo();
margin.setTop(3f);
margin.setBottom(4f);
margin.setLeft(10f);
table.setDefaultCellPadding(margin);
table.setDefaultCellBorder(new BorderInfo(BorderSide.All, 0.1F, Color.getBlack()));
for (int row_count = 1; row_count < 500; row_count++) {
// add row to table
Row row = table.getRows().add();
// add table cells
row.getCells().add("Column (" + row_count + ", 1)");
row.getCells().add("Column (" + row_count + ", 2)");
row.getCells().add("Column (" + row_count + ", 3)");
}
page.getParagraphs().add(new TextFragment());
}
private void addFooterInformation(Document document) {
PageNumberStamp pageNumberStamp = new PageNumberStamp();
pageNumberStamp.setFormat("Page #");
pageNumberStamp.setBottomMargin(10);
pageNumberStamp.setRightMargin(50);
pageNumberStamp.setHorizontalAlignment(HorizontalAlignment.Right);
pageNumberStamp.setVerticalAlignment(VerticalAlignment.Bottom);
pageNumberStamp.setStartingNumber(1);
pageNumberStamp.getTextState().setFont(FontRepository.findFont(FONT_TIMES_NEW_ROMAN));
pageNumberStamp.getTextState().setFontSize(10.0F);
pageNumberStamp.getTextState().setForegroundColor(Color.getGray());
for (Page page : document.getPages()) {
page.addStamp(pageNumberStamp);
}
}
in attached pdf page number is added in 1st page out of 13 pages
I want footer information to be added in all 13 pages
Please try to add document.processParagraphs();
line before adding the footer information like below:
addTable(document);
document.processParagraphs();
addFooterInformation(document);
table.pdf (118.6 KB)
Great!
it works perfectly. thanks for the support