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.