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

Hello,

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.
test-app-and-files.zip (22.0 KB)
output-files.zip (34.1 KB)

Best regards,
Igor Paszewski

@igor.paszewski

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

@igor.paszewski

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.

The issues you have found earlier (filed as WORDSNET-19532) have been fixed in this Aspose.Words for .NET 19.12 update and this Aspose.Words for Java 19.12 update.

Thank you for your effort. I confirmed that problem with KeepDifferentStyles is fixed. Also second problem with losing formatting when using KeepSourceFormatting does not appear any more.

Unfortunately, the first issue still exists. Please, look at my attached document. There is still no “Heading 1_0” style which should by imported from the source document.
20191212_174652_KeepSourceFormatting.zip (11.8 KB)

Regards,
Igor Paszewski

@igor.paszewski

We have logged this problem in our issue tracking system as WORDSNET-19680 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@igor.paszewski

It is to inform you that we have closed the issue (WORDSNET-19680) with “Won’t Fix” resolution.

Aspose.Words mimics MS Word behavior in importing tasks with KeepSourceFormatting mode. MS Word does not import any styles by using prefixes like ‘_0’, ‘_1’ and so on. Instead, it expands style differences into direct attributes of importing node.

We have updated the KeepSourceFormatting detail in Aspose.Words for .NET - API Reference. Please check ImportFormatMode enumeration.