Numbered list copy from source document to target document. Sequence number is not maintained in output

I am using Aspose Words Java API to move content from one document to another. The source document contains numbered-list items. When the list items are copied to the target document, the sequence no for all items in the list are changed to 1 instead of (1, 2, 3, 4…).


For reference, I am attaching the sample input document: “aspose_number_list_input.docx” and output document.

Here is the code sample:

Document targetDocument = new Document(“output.docx”);
Document sourceDoc = new Document(“aspose_number_list_input.docx”);

// Used Aspose examples code as reference
Node targetStartNode = paragraphsByTitleName(targetDocument, targetNodeStyle, targetNodeHeading);
Node startNode = paragraphsByTitleName(sourceDoc, sourceDocNodeStyle1, sourceDocNodeText);
Node endNode = paragraphsByTitleName(sourceDoc, sourceDocNodeStyle1, sourceDocNodeText);

List tempnodes = extractContent(startNode, endNode, ); // Extract list of paragraphs between 2 nodes in source document

// Importing paragraph nodes and inserting into target document
for (Node newNode : tempnodes) {
Node updNode = targetDocument.importNode(newNode, true);
targetStartNode.getParentNode().insertAfter(updNode,targetStartNode);
targetStartNode = updNode;
}

targetDocument.save(“output.docx”);


Hi Akshay,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.