We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Differenence in Word and PDF output when using Aspose 15.6

Hi Team,
I am seeing a difference in the PDF and Word output of a table, when using the Aspose library, version -15.6 . Automatic cell span happens in the pdf output but not in the Word. Are there any known issue around this or is there any new setting that needs to be done??
Please see the standalone code and output generated.

private static void buildTable(DocumentBuilder docBuilder) throws Exception
{
docBuilder.startTable();

Cell mainCell1 = docBuilder.insertCell();
mainCell1.getCellFormat().setPreferredWidth(PreferredWidth.fromPoints(80));
// first inner table
docBuilder.startTable();

Cell it1_cell1 = docBuilder.insertCell();

it1_cell1.getCellFormat().setWidth(65.0);
mainCell1.getCellFormat().setPreferredWidth(PreferredWidth.fromPoints(65.0));

docBuilder.write(“Text”);

Table innerTable1 = docBuilder.endTable();
innerTable1.setPreferredWidth(PreferredWidth.AUTO);
innerTable1.setAllowAutoFit(true);

Cell mainCell2 = docBuilder.insertCell();
mainCell2.getCellFormat().setPreferredWidth(PreferredWidth.fromPoints(350));
// second inner table

docBuilder.startTable();
docBuilder.getParagraphFormat().clearFormatting();

Cell it2_r1_cell1 = docBuilder.insertCell();
docBuilder.write(“Cell A1”);

Cell it2_r1_cell2 = docBuilder.insertCell();
docBuilder.write(“Cell B1”);

Cell it2_r1_cell3 = docBuilder.insertCell();
docBuilder.write(“Cell C1”);

docBuilder.endRow();

Cell it2_r2_cell1 = docBuilder.insertCell();
docBuilder.write(“A2”);

Cell it2_r2_cell2 = docBuilder.insertCell();
docBuilder.write(“B2”);

Cell it2_r2_cell3 = docBuilder.insertCell();
docBuilder.write(“C2”);

Cell it2_r2_cell4 = docBuilder.insertCell();
docBuilder.write(“D2”);
docBuilder.endRow();

Table inner_table2 = docBuilder.endTable();
inner_table2.setPreferredWidth(PreferredWidth.fromPercent(100));
inner_table2.setAllowAutoFit(false);



Cell mainCell3 = docBuilder.insertCell();
docBuilder.write(“Development Data”);

Table mainTable = docBuilder.endTable();

mainTable.setPreferredWidth(PreferredWidth.fromPercent(100));

mainTable.setAllowAutoFit(true);
}

Hi Akash,


Thanks for your inquiry. Please try using the following code with Aspose.Words for Java 16.3.0:

Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);

docBuilder.startTable();

Cell mainCell1 = docBuilder.insertCell();
mainCell1.getCellFormat().setPreferredWidth(PreferredWidth.
fromPoints(80));
// first inner table
docBuilder.startTable();

Cell it1_cell1 = docBuilder.insertCell();

it1_cell1.getCellFormat().setWidth(
65.0);
mainCell1.getCellFormat().setPreferredWidth(PreferredWidth.
fromPoints(65.0));

docBuilder.write(
“Text”);

Table innerTable1 = docBuilder.endTable();
innerTable1.setPreferredWidth(PreferredWidth.
AUTO);
innerTable1.setAllowAutoFit(
true);

Cell mainCell2 = docBuilder.insertCell();
mainCell2.getCellFormat().setPreferredWidth(PreferredWidth.
fromPoints(350));
// second inner table

docBuilder.startTable();
docBuilder.getParagraphFormat().clearFormatting();

Cell it2_r1_cell1 = docBuilder.insertCell();
docBuilder.write(
“Cell A1”);

Cell it2_r1_cell2 = docBuilder.insertCell();
docBuilder.write(
“Cell B1”);

Cell it2_r1_cell3 = docBuilder.insertCell();
docBuilder.write(
“Cell C1”);

docBuilder.endRow();

Cell it2_r2_cell1 = docBuilder.insertCell();
docBuilder.write(
“A2”);

Cell it2_r2_cell2 = docBuilder.insertCell();
docBuilder.write(
“B2”);

Cell it2_r2_cell3 = docBuilder.insertCell();
docBuilder.write(
“C2”);

Cell it2_r2_cell4 = docBuilder.insertCell();
docBuilder.write(
“D2”);
docBuilder.endRow();

Table inner_table2 = docBuilder.endTable();
inner_table2.setPreferredWidth(PreferredWidth.
fromPercent(100));
inner_table2.setAllowAutoFit(
false);
inner_table2.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);

Cell mainCell3 = docBuilder.insertCell();
docBuilder.write(
“Development Data”);

Table mainTable = docBuilder.endTable();

mainTable.setPreferredWidth(PreferredWidth.
fromPercent(100));

mainTable.setAllowAutoFit(
true);

doc.save(
getMyDir() + “awjava-16.3.0.docx”);
doc.save(
getMyDir() + “awjava-16.3.0.pdf”);

Best regards,