We have an application that modifies Word documents using a template system. In our Word template, we use placeholders like #NOTES#
to mark where dynamic content should be inserted.
In our app, we define the content for #NOTES#
using a RichTextBox
, which allows formatting such as bold, italic, and underline. When we replace the placeholder using:
editor.ReplaceText("#NOTES#", importedSections);
…the basic formatting is preserved correctly in the final Word document.
However, when we apply a style like Heading1
to the text in the RichTextBox
, that style is not carried over to the final Word output. We are using the following code to handle the import:
var importer = new DocumentElementImporter(document, flowDocument, ConflictingStylesResolutionMode.UseTargetStyle);
Despite this, the style (e.g., Heading1
) is not applied in the resulting document. Is there something we’re missing to ensure that styles like Heading1
are preserved during the import?
Any help or guidance would be greatly appreciated!
Thanks in advance.