我有一个像这样的节点导入器
Dim nodeImporter As New Aspose.Words.NodeImporter(_wordDocument, documentComponentDocument,
Aspose.Words.ImportFormatMode.UseDestinationStyles)
我正在使用它将子节点从一个文档复制到另一个文档。我的子节点是一个项目符号列表。
documentComponentSection.Body.AppendChild(nodeImporter.ImportNode(childNode, True))
但我的问题是子节点的某些属性,如 ListLabel 即项目符号列表编号没有被复制
根据您的回答,我尝试了以下操作。但是当我为每个节点创建新文档时它不起作用。
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");
}
每个输出文档都包含列表索引为 1。