In one of my documents this method throws the exeption :
Test method TrossenUtskickTestProject.FileConverterTest.DocToOutputFormatTest threw exception: System.InvalidCastException: Unable to cast object of type ‘Aspose.Words.SpecialChar’ to type ‘Aspose.Words.Run’.
I have narrowed the problem down to the word “tillämpning” on page 8, line 1. If I remove that word the code runs ok.
Edit: I now see that an alternative to the regular soft hyphen is used. The two syllables “till” and “lämpning” put together would result i three L´s and that´s not allowed in the Swedish language. This special charachter removes one L in the cases the two syllabels are put together on the same line.
It´s hard to express these things in English, but I´m doing my best.
I have just reproduced your issue and observed that exception happens due to hyphen in the word pointed by you. As workaround I would recommend you use the following code:
That almost solved the problem. Although it leaves a space where the soft hyphen used to be. The resulting word becomes "til lämpning" instead of "tillämpning".
For some reason my old code that i supposed to remove the 'regular' soft hyphens, can be used to remove the space left by your code example.