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
KeepDifferentStyles of the
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:
- Style “Heading 1” from source document was not imported with appropriate suffix.
KeepSourceFormatting_missing_style.PNG (7.2 KB)
- 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.
test-app-and-files.zip (22.0 KB)
output-files.zip (34.1 KB)