Hello
Thanks for your request. You should just update styles of your lists (please see the attached screenshot). I little bit changed your documents for you and attached final document produced using the following code:
Document doc1 = new Document("C:\\Temp\\input1.doc");
Document doc2 = new Document("C:\\Temp\\input2.doc");
insertDocument(doc1.getFirstSection().getBody().getLastParagraph(), doc2);
doc1.save("C:\\Temp\\out.doc", SaveFormat.DOC);
private static void insertDocument(Node insertAfterNode, Document srcDoc) throws Exception
{
// Make sure that the node is either a pargraph or table.
if ((insertAfterNode.getNodeType() != NodeType.PARAGRAPH) &
(insertAfterNode.getNodeType() != NodeType.TABLE))
throw new Exception("The destination node should be either a paragraph or table.");
// We will be inserting into the parent of the destination paragraph.
CompositeNode dstStory = insertAfterNode.getParentNode();
// This object will be translating styles and lists during the import.
NodeImporter importer = new NodeImporter(srcDoc, insertAfterNode.getDocument(), ImportFormatMode.USE_DESTINATION_STYLES);
// Loop through all sections in the source document.
for (Section srcSection : srcDoc.getSections())
{
// Loop through all block level nodes (paragraphs and tables) in the body of the section.
for (Node srcNode : srcSection.getBody())
{
// Let's skip the node if it is a last empty paragarph in a section.
if (srcNode.getNodeType() == NodeType.PARAGRAPH)
{
Paragraph para = (Paragraph)srcNode;
if (para.isEndOfSection() && !para.hasChildNodes())
continue;
}
// This creates a clone of the node, suitable for insertion into the destination document.
Node newNode = importer.importNode(srcNode, true);
// Insert new node after the reference node.
dstStory.insertAfter(newNode, insertAfterNode);
insertAfterNode = newNode;
}
}
}
Hope this helps.
Best regards,
Andrey Noskov
Developer/Technical Support
Aspose Auckland Team