Issues with output formatting when using KeepSourceFormatting and KeepDifferentStyles of ImportFormatMode enum



Recently we’ve implemented a feature which allows our users to import selected documents into the main document. During testing we noticed some strange behavior when users are importing documents with KeepSourceFormatting or KeepDifferentStyles of the ImportFormatMode enum.

According the documentation, KeepSourceFormatting should ensure that imported styling is kept. When there are matching styles in source and target documents, imported style should be added with suffix. In my example is see two issues:

  1. Style “Heading 1” from source document was not imported with appropriate suffix.
    KeepSourceFormatting_missing_style.PNG (7.2 KB)
  2. Styling of the first sentence of the modified paragraph of the target document is changed to “Normal”.
    KeepSourceFormatting_lost_formatting.PNG (5.3 KB)

KeepDifferentStyles is very similar to KeepSourceFormatting but it should import styles to the target document only when they differ from existing ones. This time “Heading 1” style was imported with unique name. Unfortunately styling of the first sentence of the modified paragraph was changed according to the imported style. I would expect that first sentence of the paragraph should remain with the original styling. KeepDifferentStyles_formatting.PNG (6.6 KB)

For issue analysis I’m attaching a simple console application which tests importing documents using various format modes. It loads main.docx, then searches for “REPLACE” phase and replaces it by inserting the insert.docx document. Operation is repeated for each value of the ImportFormatMode. I’m also attaching source and output documents that I used during evaluation. (22.0 KB) (34.1 KB)

Best regards,
Igor Paszewski



Please accept my apologies for late response. We are investigating this issue and will get back to you soon.



We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19532. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.