Copying content issue

Hi,
So here’s the issue, I’m iterating thru a collection of paragraphs in a source document and when I locate certain verbage I note the starting Node. I then continue on searching for other verbage and note the ending Node. At this point I copy everything in between the two nodes to a destination document. Then I continue on searching the source document, and so on.
When I write the content found btwn the first Start / End node the destination looks fine, however performing this action again causes the second Start / End node to be placed almost on top of the first Start / End node.
Couple of things:

  1. I read in my Source like this:
Document srcDoc = new Aspose.Words.Document(....
  1. I create my destination like this:
Document dstDoc = srcDoc.Clone();
dstDoc.RemoveAllChildren();
dstDoc.EnsureMinimum();
dstDoc.FirstSection.Body.RemoveAllChildren();
  1. Here’s my importer and nodes to search:
NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.UseDestinationStyles);
NodeCollection MyNodes = srcDoc.GetChildNodes(NodeType.Paragraph, true);
  1. I grab the content as outlined here: https://forum.aspose.com/t/70413
    I’ve even tried the following code to add some sort of buffer in btwn content inserts but it just gives lots of empty sections of large unwanted pages:
Section section = new Section(dstDoc);
dstDoc.AppendChild(section);
Body body = new Body(dstDoc);
section.AppendChild(body);
Paragraph p1 = new Paragraph(dstDoc);
dstDoc.LastSection.Body.AppendChild(p1);
body.AppendChild(p1);

Anyone have some thoughts?

Thanks - Dave

Hello
Thanks for your request. I think in this case you can try using the same approach as suggested here:
https://docs.aspose.com/words/net/how-to-extract-selected-content-between-nodes-in-a-document/
Best regards,

Andrey,
Thanks for the reply. That article is a good example of getting the content between two nodes, repeatedly. I’m using it now. However the issue still remains, during the second attempt to write out a content chunk to the destination, it will place that content chuck just about ON TOP of the first content chunk that was written.
To help prevent this, in between the various writes of the content chunks I place this code below -
Which fixes the first problem BUT adds excessive spacing and pages.

Section section = new Section(dstDoc);
dstDoc.AppendChild(section);
Body body = new Body(dstDoc);
section.AppendChild(body);
// section.PageSetup.SectionStart = SectionStart.Continuous;
Paragraph p1 = new Paragraph(dstDoc);
dstDoc.LastSection.Body.AppendChild(p1);
body.AppendChild(p1);

Hi there,

Thanks for this additional information.

Could you please attach your source document as well as which nodes you are extracting? We will gladly take a closer look into this for you.

Thanks,