var appendObject1 = RtfStringToDocument(File.ReadAllText(MyDir + "in.rtf"));
var appendObject2 = RtfStringToDocument(File.ReadAllText(MyDir + "in2.rtf"));
var appendObject3 = RtfStringToDocument(File.ReadAllText(MyDir + "in3.rtf"));
var documentObject = new Document();
InsertDocument(documentObject.LastSection.Body.LastParagraph, appendObject1);
InsertDocument(documentObject.LastSection.Body.LastParagraph, appendObject2);
InsertDocument(documentObject.LastSection.Body.LastParagraph, appendObject3);
var options = new RtfSaveOptions
{
SaveFormat = SaveFormat.Rtf
};
documentObject.Save(MyDir + "Out.rtf", options);
private static Document RtfStringToDocument(string rtf)
{
Document doc = null;
// Convert RTF string to byte array.
byte[] rtfBytes = Encoding.UTF8.GetBytes(rtf);
// Create stream.
using(MemoryStream rtfStream = new MemoryStream(rtfBytes))
{
// Open document from stream.
doc = new Document(rtfStream);
}
return doc;
}
If the problem still remains, Please manually create your expected output document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.