Hello!
I use this code:
private void AppendDocument(Document dstDoc, Document srcDoc)
{
foreach (Section srcSection in srcDoc)
{
Node dstSection = dstDoc.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
dstDoc.AppendChild(dstSection);
}
}
public Document Execute()
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Some text.");
string DocPath = "...";
Document doc1 = new Document(System.IO.Path.Combine(DocPath, "Template.doc"));
string[] fieldNames = { ...};
object[] fieldValues = { ...};
doc1.MailMerge.Execute(fieldNames, fieldValues);
doc1.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
AppendDocument(doc, doc1);
builder.MoveToDocumentEnd();
builder.Writeln("Some text.");
AppendDocument(doc, doc1);
return doc;
}
As a result I receive such document on structure:
Some text.
Some text.
Contents of the document doc1.
Why there is the page break after the first “Some text.”? Though after second “Some text.” is not present…
Thanks!