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.

Fri Nov 05, 2021 3:49 pm

I have a problem with rich text in Spire.Doc, I am trying to add rich text in a paragraph using AppendHTML, but I get the following exception: "The input string was not in the correct format". I don't know why this problem arises as I am passing a string to the AppendHTML.

cotoql
 
Posts: 14
Joined: Tue Oct 28, 2014 9:41 pm

Mon Nov 08, 2021 7:44 am

Hello,

Thank you for your inquiry.
According to your description, could you please confirm whether your rich text is in HTML or RTF format? If it is in RTF format, you need to use AppendRTF(string rtfCode) method. If it is in HTML format, I suggest you try again with our latest Spire.Doc Pack(hot fix) Version:9.10.9. If the issue still exists after trying, please share us with your rich text as well as your complete test code for our reference. You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Mar 08, 2022 5:01 pm

Yes, the text is html and yes, the problem persists even with the latest version, I think the problem is with the width tag, if the width tag has decimals, the SPIRE fails.

I attach a raw example.

cotoql
 
Posts: 14
Joined: Tue Oct 28, 2014 9:41 pm

Wed Mar 09, 2022 2:11 am

Hello,

Thanks for your sharing.
After investigation, I found that the issue you mentioned is caused by not standard HTML code. I directly changed the suffix of your file to .html, and opened it with Google Chrome and found that the standard HTML code was displayed. Copy the HTML code to a new file and open it again with Google Chrome to display the correct content. I tested the standard HTML code with Spire.Doc and the result is completely correct. I have attached my test project for your reference.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Mon Apr 11, 2022 8:29 am

Hello,

Hope you are doing well!
How is your issue going? Did the project we provided work for you? Any feedback will be greatly appreciated.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Doc