- Your input Word documents StyleIssueSourceDocument01.docx and StyleIssueSourceDocument02.docx
- Please attach your expected document showing the desired output here for our reference. You can create expected document using Microsoft Word.
- Aspose.Words generated output document showing the undesired behavior.
Files are added.
I am using Words V18.1 and still see this behaviour. Has the issue WORDSNET-14397 been fixed? and if so which version?
Unfortunately, your issue is not resolved yet. We are currently reviewing the fix of this issue. We will inform you via this thread as soon as this issue is resolved or any estimates are available. We apologize for any inconvenience.
Regarding WORDSNET-14397, it is to update you that we have added a new ImportFormatOptions class with a public property SmartStyleBehavior.
This option starts working when styles clashes upon importing.
When this option is enabled, a source style will be expanded into a direct attributes inside a destination document, if KeepSourceFormatting importing mode is used.
When this option is disabled, a source style will be expanded only if it is numbered. Existing destination attributes will not be overridden, including lists.
This option can be used with a new public method of a DocumentBuilder class:
public Node InsertDocument(Document srcDoc, ImportFormatMode importFormatMode, ImportFormatOptions options)
Simple use-case is as follows:
Document srcDoc = new Document("source.docx"); Document dstDoc = new Document("destination.docx"); DocumentBuilder builder = new DocumentBuilder(dstDoc); builder.MoveToDocumentEnd(); builder.InsertBreak(BreakType.PageBreak); ImportFormatOptions options = new ImportFormatOptions(); options.SmartStyleBehavior = true; builder.InsertDocument(srcDoc, ImportFormatMode.UseDestinationStyles, options);
Hope, this helps.