I have a node importer that looks like this
Dim nodeImporter As New Aspose.Words.NodeImporter(_wordDocument, documentComponentDocument, Aspose.Words.ImportFormatMode.UseDestinationStyles)
I use it to copy a childnode from one document to another. My child node is a list of tokens.
documentComponentSection.Body.AppendChild(nodeImporter.ImportNode(childNode, True))
But my problem is that some properties of the child, such as ListLabel ie numbering is not copied
According to your answer, I tried to follow. But it does not work when I create a new document for each node.
Aspose.Words.Document srcDoc = new Aspose.Words.Document(Mydir + "input.docx"); Aspose.Words.Document dstDoc = new Aspose.Words.Document(); var ctr = 0; int listid = 0; Aspose.Words.Lists.List dstList = null; foreach (Aspose.Words.Paragraph paragraph in srcDoc.GetChildNodes(Aspose.Words.NodeType.Paragraph, true)) { Aspose.Words.NodeImporter imp = new Aspose.Words.NodeImporter(srcDoc, dstDoc, Aspose.Words.ImportFormatMode.KeepSourceFormatting); Aspose.Words.Node impNode = imp.ImportNode(paragraph, true); if (((Aspose.Words.Paragraph)impNode).IsListItem) { ((Aspose.Words.Paragraph)impNode).ListFormat.ListLevel.StartAt = paragraph.ListFormat.List.ListId; if (listid != paragraph.ListFormat.List.ListId) { listid = paragraph.ListFormat.List.ListId; dstList = dstDoc.Lists.AddCopy(paragraph.ListFormat.List); } ((Aspose.Words.Paragraph)impNode).ListFormat.List = dstList; } dstDoc.FirstSection.Body.RemoveAllChildren(); dstDoc.FirstSection.Body.AppendChild(impNode); var index = ctr++; dstDoc.Save(MyDir + index.ToString() + ".docx"); }
Each output contains a list index of 1.
source share