Table Cell with colspan attribute is not rendering correctly

Hi,

Colspan attribute of table cell is not working correctly with setAllowAutoFit(false). I have given colspan = “2” to first cell. so second cell will be merge. but if have given "table-layout:fixed " property to table then it is not merging the second cell.
For .docx and .pdf it is not rendering correctly, but for .doc it is working perfectly.

	Document doc = new Document();
	DocumentBuilder builder = new DocumentBuilder(doc);
	Table table = builder.startTable();		
	ParagraphFormat paragraphFormat = builder.getParagraphFormat();
	paragraphFormat.setAlignment(ParagraphAlignment.CENTER);
	
	builder.insertCell();
	builder.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
	builder.write("Text in merged cells.");

	builder.insertCell();
	// This cell is merged to the previous and should be empty.
	builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);
	builder.endRow();

	builder.insertCell();
	builder.getCellFormat().setHorizontalMerge(CellMerge.NONE);
	builder.write("Text in one cell.");

	builder.insertCell();
	builder.write("Text in another cell.");
	builder.endRow();
	table.setAllowAutoFit(false);   // Added "table-layout:fixed" by Table.AllowAutofit
	builder.endTable();

Please check the attached outout.png file.Output.PNG (5.8 KB)

@Prahalad

Thanks for your inquiry. We have tested the scenario with Aspose.Words for Java 17.8 and unable to notice the reported issue. Please download and try latest version of Aspose.Words for Java, it will resolve the issue.TestTable_false.zip (5.2 KB)

Hi @tilal.ahmad
I have downloaded Aspose 17.8 and checked with it. But I am facing the same issue. Could you please check again? Please try with the attached code and check the pdf result.TestTableRowCell.zip (997 Bytes)

@Prahalad

Thanks for your feedback. I have again tested your shared code using Aspose.Words for Java 17.8 with JRE 1.8.0_60, but unable to notice the reported issue. TestTable_false.pdf (18.5 KB)

We will appreciate it if you please share your environment details along with your output documents here as well.

@tilal.ahmad Here is the env details we used.

OS architecture: amd64
Java VM name: IBM J9 VM
Java version: 1.7.0
Max Memory:1024

@Prahalad Verify with IBM JRE 8 and Oracle JRE 8. I would be surprised to see if the output differs based on the JRE.

@Prahalad, @kumaraswamy.m

Thanks for your patience. We have further investigated the issue. Please use updatePageLayout() method before saving the document. It will resolve the issue.

//doc.updateFields();
doc.updatePageLayout();
doc.save("AW_178.doc");
doc.save("AW_178.docx");
doc.save("AW_178.pdf");

Thanks @tilal.ahmad,
I checked with doc.updatePageLayout . it resolves the issue. Does doc.updatePageLayout() internally calls doc.updateFields() method?

@Prahalad

Thanks for your feedback. It is good to know that you have managed to resolve the issue.

Furthermore in reference to updateFields() related query. Please note updatePageLayout() method does not call updateFields() method. It rebuilds the page layout of the document. Whereas updateFields() does not update fields that are related to the page layout algorithms (e.g. PAGE, PAGES, PAGEREF).

@tilal.ahmad
Is there any order to call updateFields and updatePageLayout API?
Similarly, is there order to call updateTableLayout API as well?

@kumaraswamy.m

Thanks for your inquiry. There is no specific order to call these methods. However, if you face any issue in this regard then please let us know.