I have numerous files that I am trying to append to the final destination document. The following code is what is found in the wiki however it only seems to work the first time. When I try to append sections from the second file that needs to be copied over I get an "The reference node is not a child of this node" exception thrown from the last line (dstDoc.Sections[dstDoc.Sections.Count - 1].AppendContent(newSection);). Any ideas why?
Aspose.Words.Document srcDoc = new Aspose.Words.Document(filename);
Aspose.Words.Document dstDoc = docBuilder.Document;
Aspose.Words.Section newSection = (Aspose.Words.Section) dstDoc.ImportNode(section, true);
dstDoc.Sections[dstDoc.Sections.Count - 1].AppendContent(newSection);
Here is a tidbit from the stacktrace... StackTrace " at Aspose.Words.CompositeNode.(Node ۰, Node ۲, Boolean ി)\r\n at Aspose.Words.CompositeNode.InsertAfter(Node newChild, Node refChild)\r\n at Aspose.Words.CompositeNode.۳(Node Ԛ, Node ं, Node ര)\r\n at Aspose.Words.Section.ᓼ(Section ᓽ, Boolean ി)\r\n at Aspose.Words.Section.AppendContent(Section sourceSection)\r\n