Use the code for inserting the code:
static void Main(string[] args)
{
Telerik.Windows.Documents.Flow.Model.RadFlowDocument templateDocument = GetDocument("Template.rtf");
Telerik.Windows.Documents.Flow.Model.RadFlowDocument contentDocument = GetDocument("Content.rtf");
InsertDocumentOptions options = new InsertDocumentOptions();
options.ConflictingStylesResolutionMode = ConflictingStylesResolutionMode.RenameSourceStyle;
options.InsertLastParagraphMarker = true;
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(templateDocument);
editor.InsertDocument(contentDocument, options);
string mergedDocumentFilePath ="MergeDocumentsWithWordsProcessing.rtf";
File.Delete(mergedDocumentFilePath);
WriteDocToFile(templateDocument, mergedDocumentFilePath);
}
private static Telerik.Windows.Documents.Flow.Model.RadFlowDocument GetDocument(string rtfFilePath)
{
Telerik.Windows.Documents.Flow.Model.RadFlowDocument document = null;
var rtfImporter = new Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider();
using (Stream stream = File.OpenRead(rtfFilePath))
{
document = rtfImporter.Import(stream);
}
return document;
}
private static void WriteDocToFile(Telerik.Windows.Documents.Flow.Model.RadFlowDocument doc, string filename)
{
var rtfExporter = new Telerik.Windows.Documents.Flow.FormatProviders.Rtf.RtfFormatProvider();
string rtfText = rtfExporter.Export(doc);
File.WriteAllText(filename, rtfText);
Process.Start(filename);
}
Observed result: The After spacing is reset
Expected result: keep the style settings from the original documents.