Hey support,
we are on Aspose 11.3 and we cannot cell merges to work reliably in the PDF documents generated by Aspose.Words.
Using the example from https://docs.aspose.com/words/java/working-with-merged-cells/ we get the attached test1.pdf.
Doing a doc save first ( test2.pdf) the PDF works. This is an ugly workaround but it seems to work.
Now, if I add a TOC and a heading 1 paragraph ( so that the TOC is not empty) the PDF no longer works. See test3.pdf. What seems to be breaking the document is the call to builder.getDocument().updateFields();
The JUnit and the generated PDFs are attached. Please note that upgrade is not an option for us at this time so please recommend a solution for 11.3
Regards,
Dragos
Hi Dragos,
Thanks for your inquiry.
I have tested the scenario and have not found the shared issue while using latest version of Aspose.Words. I would suggest you please upgrade to the latest version (v13.3.0) from here:
https://releases.aspose.com/words/java
I have attached the output Pdf files with this post for your kind reference. Please let us know if you have any more queries.
Hi,
as mentionned in my intial post upgrading is not an option. Do you have any solution we can apply for 11.3?
Regards,
Dragos
Hi Dragos,
Thanks for your inquiry. Please note that every new release of Aspose.Words comes up with some new features, enhancements in the existing features and bug fixes. We always encourage our customers to use the latest version of Aspose.Words as it contains newly introduced features, enhancements and fixes to the issues that are reported earlier. I would suggest you please upgrade to the latest version (v13.3.0) from here:
https://releases.aspose.com/words/java
Moreover, please note that a table in MS Word is a set of independent rows. Each row has a set of cells independent on cells of other rows. So there is no logical “column” in a MS Word’s table. “The 1st column” is something like “a set of the 1st cells of each row in a table”.
For example, it’s possible to have a table where the 1st row consists of two cells: 2cm and 1cm and the 2nd row consists of different two cells: 1cm and 2cm of width.
In your case, I suggest you please set the size of each cell instead of merging columns as shown in following code snippet. Hope this helps you.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u");
builder.writeln();
builder.getParagraphFormat().setStyleIdentifier(1);
builder.writeln("Heading 1");
builder.getParagraphFormat().clearFormatting();
// Build table
Table table = builder.startTable();
builder.insertCell();
table.setPreferredWidth(PreferredWidth.fromPoints(400));
table.setAlignment(TableAlignment.CENTER);
builder.write("first column");
// specify width of cell
builder.getCellFormat().setWidth(400);
builder.endRow();
// note that in the next row you should also specify width of each cell
// Build table
builder.insertCell();
builder.write("Text in first row.");
// specify width of cell
builder.getCellFormat().setWidth(200);
builder.insertCell();
builder.write("Text in another cell.");
builder.getCellFormat().setWidth(200);
builder.endRow();
builder.endTable();
doc.updateFields();
doc.save(MyDir + "out.pdf");
Hey Tahir,
thanks for the suggestion but this is not really a solution as you don’t always have cell widths specified and assigning arbitrary cell widths will change the layout of the table in a way that can contradict the user’s intentions and the table data.
Regards,
Dragos
Hi Dragos,
Thanks for your inquiry. Unfortunately, we don’t provide support for older released versions of Aspose.Words. The issue you are facing exists in old versions of Aspose.Words. This issue has been fixed in latest version of Aspose.Words. I would suggest you please upgrade to the latest version (v13.3.0) from here:
https://releases.aspose.com/words/java
Please let us know if you have any more queries.