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

Free Support Forum - aspose.com

ParagraphFormat.setLinesToDrop() can cause invalid ODT output

In specific cases, calling ParagraphFormat.setLinesToDrop() will result in invalid ODT output.

To demonstrate I’ve constructed the following sample code fragment:

Document document = new Document();
DocumentBuilder builder = new DocumentBuilder(document);
Paragraph current;
Paragraph p;
Run r;
current = builder.getCurrentParagraph();
p = new Paragraph(document);
r = new Run(document, “hello world”);
p.appendChild®;
document.getSections().get(0).getBody().insertAfter(p, current);
builder.moveTo§;
p.getParagraphFormat().setLinesToDrop(1);
builder.startTable();
Cell cell = builder.insertCell();
cell.remove();
cell = builder.insertCell();
p = cell.getFirstParagraph();
p.appendChild(new Run(document, “sdfdsfe wf ef ew fs”));
builder.endRow();
builder.endTable();
document.save(“out\test.odt”);

When you run this with the latest version of Aspose.Words for Java and open it in LibreOffice writer you will notice that the table is not there. When you try to open it in MS Word it will state that the document is invalid.
Now comment out the following line:
p.getParagraphFormat().setLinesToDrop(1);

and run the sample again. You will notice that the table now appears as it should. While examining the ODT output it became clear that when the setLinesToDrop call is performed, the table ends up inside a paragraph element, which is illegal odt. LibreOffice writer probably just ignores the illegal fragment while MS Word is less forgiving and displays an error that the document is invalid.

If someone from the Aspose team could verify this problem and report back it would be much appreciated.

Thanks.
Hi Toon,

Thanks for your inquiry. I have tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem as WORDSNET-7529 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-7529) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.