Hi @alexey.noskov, thank you for the support. Let me try to clarify why we need this method. So like the sample project also has, we currently have a template document, with the basic Word styles and theme. Inside this document there is some logic to identify other generated documents that will be merged into this template document. These generated documents have their own custom style and theme. These styles and them are pretty much the same.
Initially I only used the KeepSourceFormatting
, which should just copy the style of the elements/nodes into the destination file, which has always worked fine for our documents, but with our latest document this suddenly had some issues. I noticed that not all elements/nodes kept their source formatting, but received the destination style, while these elements/nodes should also have been imported with the KeepSourceFormatting
option.
So for example some paragraphs of the document have the source style “Normal”, font Calibri, while others reverted to the destination style “Normal”, font Verdana.
I’m not quite sure why certain paragraphs receive the destination style. So what I needed was to overwrite the styles in the destination file, to match the source styles. Therefor I needed CopyStylesFromTemplate
. At this moment there is only one TOC style, while there are two TOC’s in the document, so that is not an issue.
We are working with Aspose.Words for a long time now (since 2005 maybe?), so I’m not exactly sure why we needed our own InjectDocument, instead of InsertDocument. Perhaps to have some more control on inserting documents into another document.
I will try UpdateFields
and will review if this creates a different issue in our case. Perhaps I can also create a sample project which illustrates the behaviour source/destination style issue of my document.