Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Mar 28, 2019 1:45 am

See attached file. Searching for "epinephrine", all hits show CharacterFormat.UnderlineStyle = none, even though one is underlined.

owurman
 
Posts: 20
Joined: Tue Apr 04, 2017 8:43 pm

Thu Mar 28, 2019 2:58 am

It seems that another search is destroying the underline. That is, I have a search for "IV epinephrine". It finds the partially underlined example:

IV epinephrine

but in doing so, destroys the underline. Is this possible?

I tested removing the search for "IV epinephrine" and now everything works fine.

I tested other cases in other files, and indeed, it seems that FindAllString(), when it finds a TextRange that doesn't start with an underline, destroys any later underline. Similarly, if it starts with an underline but then stops, it seems to make the whole TextRange underlined.

I understand why this happens, because you only have one CharacterFormat for a TextRange. It seems that a List of CharacterFormats would be more appropriate to avoid this destructive quality of the search!

owurman
 
Posts: 20
Joined: Tue Apr 04, 2017 8:43 pm

Thu Mar 28, 2019 7:22 am

Hello,

Thanks for your post.
When searching for "IV epinephrine", GetAsOneRange() function will merge original two TextRanges into one TextRange, please add the parameter “bool IsCopyFormat” in the overloaded methods of TextSelection.GetAsOneRange() which is designed practically for keeping the format. Then, the result is correct. If there is any question, just feel free to write back.
Code: Select all
......
TextRange tr = ts.GetAsOneRange(true);
......

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Thu Mar 28, 2019 3:04 pm

There is no documentation about what this does:

https://www.e-iceblue.com/Tutorials/API ... ments.html

Documentation would help, please!

It seems that this has the opposite problem--it adds the underline to the word "IV". I need to preserve existing formatting.

I think the solution is to not use GetAsOneRange(), so I will try with GetRanges().

owurman
 
Posts: 20
Joined: Tue Apr 04, 2017 8:43 pm

Fri Mar 29, 2019 2:50 am

Hello,

Thanks for your feedback.
Sorry for the inconvenience caused, we will add the corresponding documentations of GetAsOneRange() and GetRanges() into TextSelection Class. Besides, yes, please use GetRanges() to preserve existing formatting. If there is any other question, just feel free to write back.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc