We have recently upgraded to last versions of Aspose Words for Java.
After the upgrade we are receiving many reports of problems while copying the content of an ODT document into a bookmark of a target ODT document. The problems arise when the source document contains numbered lists.
In the final document the numbering of the numbered lists is lost or changed.
The formatting and indentation of the lists in the target document is also altered.
This is the numbered list in the source document:
and this in the final document:
(in red numbered list problems, in blue other formatting issues with bulleted list items)
Here’s a sample code to reproduce the problem (in attach example files)
TEST_documents.zip (71.6 KB)
public static void main(String[] args) throws Exception
{
String path = "c:"; // documents path
testDocumentBookmarks(path+"TEST_testo.odt", path+"TEST_Verbale_modello.odt", "TESTO", path+"TEST_Verbale_compilato.odt");
}
private static void testDocumentBookmarks(String sourceFilename, String templateFilename, String bookmarkName, String outputFilename) throws Exception
{
// Carica il documento di origine (ODT)
Document sourceDoc = new Document(sourceFilename);
// Carica il documento di destinazione (ODT)
Document destDoc = new Document(templateFilename);
boolean ret = importDocumentOri(sourceDoc, destDoc, bookmarkName);
if (!ret) return;
// Salva il documento di destinazione aggiornato (in formato ODT)
destDoc.save(outputFilename);
System.out.println("Output file written: "+outputFilename);
}
private static boolean importDocumentOri(Document sourceDoc, Document destDoc, String bookmarkName) throws Exception
{
// COPY
Document clipboard = sourceDoc.deepClone();
// SELECT A BOOKMARK
Bookmark bm = destDoc.getRange().getBookmarks().get(bookmarkName);
if (bm == null) {
System.out.println("E' stato richiesto di inserire un valore dentro il bookmark " + bookmarkName + ", ma questo non pare esistere nel documento.");
return false;
}
BookmarkStart start = bm.getBookmarkStart();
// PASTE
DocumentBuilder builder = new DocumentBuilder(destDoc);
builder.moveTo(start);
builder.insertDocument(clipboard, ImportFormatMode.KEEP_SOURCE_FORMATTING);
return true;
}
The expected behaviour is to have the numbered lists in the target document with same numering and formatting of the source document.
Please help us to resolve this issue as we cannot downgrade to old vesions of the library.