// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C.git. static SharedPtr<Document> GenerateDocument(SharedPtr<Document> srcDoc, SharedPtr<System::Collections::Generic::List<SharedPtr<Node>>> nodes) { auto dstDoc = MakeObject<Document>(); // Remove the first paragraph from the empty document. dstDoc->get_FirstSection()->get_Body()->RemoveAllChildren(); // Import each node from the list into the new document. Keep the original formatting of the node. auto importer = MakeObject<NodeImporter>(srcDoc, dstDoc, ImportFormatMode::KeepSourceFormatting); for (const auto& node : nodes) { SharedPtr<Node> importNode = importer->ImportNode(node, true); dstDoc->get_FirstSection()->get_Body()->AppendChild(importNode); } return dstDoc; }