Free Support Forum - aspose.com

Use page generated by table's setBroken and row's setInNewPage

Hi,


I am rendering table, which will span on multiple pages. I am using <span style=“font-family: “Courier New”; background-color: rgb(228, 228, 255);”>asposeRow<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>.setInNewPage(<span style=“font-family: “Courier New”; color: rgb(0, 0, 128); font-weight: bold;”>true<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>); and <span style=“font-family: “Courier New”; background-color: rgb(228, 228, 255);”>asposeTable<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>.setBroken(<span style=“font-family: “Courier New”; color: rgb(0, 0, 128); font-weight: bold;”>true<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>);
and the table continues on the next page, which is what I want.
However, I would like to use the remaining space in the last page (where table is rendered) for adding some additional form fields. How can I do that? How can I obtain reference to the last page of the table (which seems to be added during rendering of the document), so I can pass it to the new form field I need to add?

Could you provide some example?

Thanks.


Hi There,


Thanks for contacting support.

In order to get reference of the last page, you can save document into outputstream, so that last page of the PDF document can be determined. Please check following code snippet where I have determined the last page object from the document.

Document
doc = new Document();<o:p></o:p>

doc.getPages().add();

Table table = new Table();

for(int i =0; i< 150; i++){

Row row = table.getRows().add();

Cell cell = row.getCells().add();

cell.getParagraphs().add(new TextFragment("This is cell " + i));

}

doc.getPages().get_Item(1).getParagraphs().add(table);

try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {

doc.save(output);

Page lastPage = doc.getPages().get_Item(doc.getPages().size());

System.out.println("Last Page Number : " + lastPage.getNumber());

}catch(Exception e){

}



In case of any further assistance, please feel free to contact us.


Best Regards,