Merge of documents


#1

I have another question about Aspose.Word! I need to make merge of documents: in particular, I have one document with a MergeField <> that I must replace with another word document, I.E.:

destination: ?tag1?
source doc: doc2.doc
<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>


I see that it’s possibile append another document at the end of the destination doc using this code:

Document doc2 = new Document(System.IO.Path.Combine(“doc_path”, “doc_name”));

builder.MoveToMergeField(tag_view_key[x - 1]); //my tag

while (doc2.Sections.Count > 0)

{

Section sec = doc2.Sections[0];

doc2.Sections.RemoveAt(0);

doc.Sections.Add(sec);

}


What I would like to do is different, and is not at the end or begin of destination document, but inside. Besides, I need to import not only text, but also images and tables of source document.
How can I make?
Thanks again,

Marco


#2

I found this way:


Section sec = doc2.Sections[0]; //read section

doc.Sections[0].AppendContent(sec); //append section in my position


Is it correct? There’s a better way?


#3

I don’t think this is the best way because it still does not insert a section exactly at a merge field. But there’s no any method to resolve it at the moment. We will implement this feature asap, probably this month.

Thank you.