I am using aspose-words 23.5 version.
I have created 2 Tables at x,y position. We have a scenario where data/table needs to be shown at particular x,y position.
The word file gets created successfully with proper x,y positions.
Facing below issues when user edits the created word file.
Are there any settings which can be done from code to adjust below issues?
-
If extra data is added in first table then second table does not overflow or adjust its x, y positions
If user edits the first table and adds 7-8 new lines to existing cell, second table shifts below till a certain point and then again gets back to original x,y positions.
The table should keep on moving below and not adjust again to its x,y positions as new data is added in first table.
Observation : If second table has less rows and data is getting added in first table, second table doesn’t overflow to new page and adjusts the x,y positions. -
If user adds multi line text above tables created at absolute positions, table doesn’t shift
If extra data is been added above table, ideally table should shift below as user has pressed enter and added multi line text above it.
Document document = new Document();
Table table = document.getFirstSection().getBody().getTables().get(0);
if( table == null ) {
table = new Table(document);
}
Row row = new Row(document);
table.appendChild(row);
Cell cell = new Cell(document);
row.appendChild(cell);
Paragraph para = new Paragraph(document);
Run r = new Run(document, "This is sample text ");
para.appendChild(r);
cell.appendChild(para);
BorderCollection borderCollection = cell.getCellFormat().getBorders();
borderCollection.setLineStyle(LineStyle.NONE);
table.setTextWrapping(TextWrapping.AROUND);
table.setAbsoluteHorizontalDistance(10.0);
table.setAbsoluteVerticalDistance(100f);
document.getFirstSection().getBody().appendChild(table);
Table table2 = new Table(document);
for(int i=0; i<25; i++) {
Row wordRow = new Row(document);
table2.appendChild(wordRow);
for(int j=0; j<3; j++) {
Cell wordCell = new Cell(document);
wordRow.appendChild(wordCell);
Paragraph paragraph = new Paragraph(document);
Run run = new Run(document, "Row "+i+" Cell "+j);
paragraph.appendChild(run);
wordCell.appendChild(paragraph);
wordCell.getCellFormat().setWidth(100);
}
}
table2.setTextWrapping(TextWrapping.AROUND);
table2.setAbsoluteHorizontalDistance(50.0);
table2.setAbsoluteVerticalDistance(200f);
document.getFirstSection().getBody().appendChild(table2);
document.save("D:\\TableAbsolutePosition.docx");