Hi
Thanks for
your request. I modified the InsertDocument Method. See the following
code.
public void InsertDocument_102684(Node insertAfterNode, Document
srcDoc)
{
// We need to make sure that the specified node is either
pargraph or table.
if (!((insertAfterNode.NodeType == NodeType.Paragraph) || (insertAfterNode.NodeType
== NodeType.Table)))
throw new ArgumentException("The
destination node should be either paragraph or table.");
// We will be inserting into the parent of the destination
paragraph.
CompositeNode dstStory =
insertAfterNode.ParentNode;
// This object will be translating styles and lists during
the import.
NodeImporter importer = new
NodeImporter(srcDoc,
insertAfterNode.Document, ImportFormatMode.KeepSourceFormatting);
Document
dstDoc = dstStory.Document;
Section
dstSection = (dstStory as Body).ParentSection;
DocumentBuilder
builder = new DocumentBuilder(dstDoc);
int index =
dstDoc.Sections.IndexOf((dstStory as Body).ParentSection);
if
(srcDoc.Sections.Count > 1)
{
builder.MoveToSection(index);
builder.MoveToParagraph(dstSection.Body.Paragraphs.IndexOf(insertAfterNode),
-1);
builder.InsertBreak(BreakType.SectionBreakContinuous);
}
// Loop through all sections in the source document.
foreach (Section
srcSection in srcDoc.Sections)
{
int i = 0;
if
(srcSection.Equals(srcDoc.FirstSection))
{
// Loop through all block level nodes (paragraphs and
tables) in the body of the section.
foreach (Node
srcNode in srcSection.Body)
{
i++;
// Do not insert node if it is a last empty paragarph in
the section.
Paragraph para = srcNode as
Paragraph;
if ((para != null)
&& para.IsEndOfSection && !para.HasChildNodes)
break;
// This creates a clone of the node, suitable for insertion
into the destination document.
Node newNode = importer.ImportNode(srcNode, true);
// Insert new node after the reference node.
dstStory.InsertAfter(newNode,
insertAfterNode);
insertAfterNode = newNode;
}
}
else
{
Node
newNode = importer.ImportNode(srcSection, true);
dstDoc.Sections.Insert(index+1, newNode);
}
}
}
I hope that
this code will help you.
Best regards.