使用Aspose.words 把一个文档中的Section完整拷贝到另一个文档,包括页眉和页脚
使用Aspose.words 把一个文档中的Section完整拷贝到另一个文档,包括页眉和页脚?
string strFile = @"C:\Xp\aaaaaa.doc";
Document originalDoc = new Document(strFile);
string strCurrentPath = System.IO.Directory.GetCurrentDirectory() + "\\";
//
int sectCount = originalDoc.Sections.Count;
for (int sectIndex = 0; sectIndex < sectCount; sectIndex++)
{
Document mainDoc = new Document();
mainDoc.FirstSection.Body.RemoveAllChildren();
//NodeImporter importer = new NodeImporter(originalDoc, mainDoc, ImportFormatMode.KeepSourceFormatting);
Aspose.Words.Section srcSection = originalDoc.Sections[sectIndex];
//Node dstSection = originalDoc.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
//mainDoc.AppendChild(dstSection);
int nodeCount = srcSection.Body.ChildNodes.Count;
NodeImporter importer = new NodeImporter(originalDoc, mainDoc, ImportFormatMode.KeepSourceFormatting);
for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++)
{
Node srcNode = srcSection.Body.ChildNodes[nodeIndex];
Node newNode = importer.ImportNode(srcNode, true);
mainDoc.FirstSection.Body.AppendChild(newNode);
}
mainDoc.Save(strCurrentPath + (sectIndex + 1).ToString() + ".doc", Aspose.Words.SaveFormat.Doc);
}
MessageBox.Show("处理完成");
上面的代码现在内容可以复制过去了,但是页面和页脚都没有复制过去,请问有没有什么办法可以处理。