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)