Hi,
That is indeed the style property we want to find in the style object from aspose.
Example documents are attached.
Basically we have multiple documents we have to merge together.
When merging Aspose gives us the choice to either: merge the styles, take the styles from the to be imported document or take the styles from the destination document.
What we want to do is merge the styles.
So if destination document has a style that the to be imported document doesn’t know it will copy it over to the destination document and vice versa.
That way if we have a 2 documents that use different styles the styles will be kept intact.
HOWEVER… when using this solution aspose will always copy the style over from the to be imported document to the destination.
Even if the destination document has the exact same style with the same name, same font, same size, same everything.
Aspose will create the style again in the new document and give it a number for example _1.
This is fine when merging a few documents but when merging a ton it will crash because word has a limit to how much styles it can have.
So our solution is use loop over the nodes of the to be imported document, check if the style is known in the destination document
If the style is known and the styles are 100% identical (we do this by checking almost every property available in the style) we won’t do anything.
If the style is different we will import the style into the destination document and give it “_1” or increase the number. Then we set the names of the style equal to each other so that in the to be imported document it will also be called “_1”
If the style is not known in the destination document we create the style in the destination document.
After all the styles have been set in the destination document we import the to be imported document with the option “Aspose.Words.ImportFormatMode.UseDestinationStyles” because we just made sure all the styles in the to be imported document are known and equal to the styles in the destination document.
That way our documents get merged without hitting the max amount of styles in word in case all the styles are exactly the same and some aren’t.
BUT…. Now we have a problem where the styles are different but our code can’t see it.
It checks for everything, font type, size, spacing everything.
But we didn’t check for the Asian property because I can’t see it anywhere in code.
This is a problem. Because it will not see the difference. And in the end when we merge the documents using the destination styles it will not be able to set the correct style because that style will not be the same and it will just give up and lose its formatting.
This solution has always worked for us until now. Because its pretty rare for us to get Asian styles in our documents.
Kind regards,
KrisG