Free Support Forum - aspose.com

Exception raised by InsertHTML: Input string was not in a correct format

We received the following error info after inserting some HTML:

The error description is as follows : Input string was not in a correct format.
Method: Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo)
Client Browser: IE 6.0
Client Url: https://www.scoreandreport.com/rptpreviewdl.aspx
Client IP: 172.129.218.34
Stack: at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info)
at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider)
at ?.?.?(String ?)
at ?.?.set_?(String ?)
at ?.?.set_?(String ?)
at ?.?.?(String ?, ParagraphFormat ?)
at ?.?.?(? ?)
at ?.?.?(? ?, Boolean ?)
at ?.?.?(? ?, Boolean ?)
at ?.?.?(? ?, Boolean ?)
at ?.?.ProcessNode(? node)
at ?.?.ProcessNode(? node)
at ?.?.?(? ?)
at Aspose.Word.DocumentBuilder.InsertHtml(String html)

The HTML that caused the error:

Caiden A. is a 15 month old, male child who lives with his biological mother and father.

Caiden’s father, Mr. A, is 33 years old and employed as a training manager for a chiropractic company.  His mother, Mrs. A, is a registered nurse who is employed by a Legal firm which deals in medical malpractice. 

                                    

Caiden’s father has a son from a previous marriage, Julian, who is 16 years old.  Julian is currently living at a boarding school in <?xml:namespace prefix = st1 ns = \"urn:schemas-microsoft-com:office:smarttags\" /?><st1:state xmlns:st1=\"Oregonhttp://unknownprefix/st1\">Oregon</st1:state> and only comes home during holidays, at which time he stays part-time with his biological father and part-time with his biological mother who lives nearby.  This is Caiden’s only sibling.

<?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" /?><o:p xmlns:o=\" 

http://unknownprefix/o\"> <p class=\"MsoNormal\" style=\"MARGIN: 0in 0in 0pt\">According to Mrs. A, this was a planned pregnancy and was her first.  There were no complications during the pregnancy with the exception of the development of gestational diabetes, which was controlled by diet and exercise. Mrs. A reports she was taking thyroid medication for a hypothyroid condition during the pregnancy as instructed by her physician.  The only complication related to the birth was a failure to dilate which required Pitocin, a medication which aids in dilation and contraction.  The medication failed to work and the baby was then physically extracted by a midwife.  Labor was 36 hours.

 

At the time of this observation Caiden weighed 23lbs and was 29 inches long.<o:p xmlns:o=\"

http://unknownprefix/o\"><p class=\"MsoNormal\" style=\"MARGIN: 0in 0in 0pt\">No physical abnormalities were observed and his mother reports that he has met all developmental milestones so far.<o:p xmlns:o=\"http://unknownprefix/o\"><p class=\"MsoNormal\" style=\"MARGIN: 0in 0in 0pt\"><o:p xmlns:o=\" http://unknownprefix/o\"> </p>

However, this similar HTML worked fine:

Caiden A. is a 15 month old, male child who lives with his biological mother and father.

Caiden’s father, Mr. A, is 33 years old and employed as a training manager for a chiropractic company.  His mother, Mrs. A, is a registered nurse who is employed by a Legal firm which deals in medical malpractice. 

Caiden’s father has a son from a previous marriage, Julian, who is 16 years old.  Julian is currently living at a boarding school in <?xml:namespace prefix = st1 ns = \"urn:schemas-microsoft-com:office:smarttags\" /?><st1:state class=\"\" st1=\"http://unknownprefix/st1\" xmlns:st1=\"http://unknownprefix/st1\"><st1:place class=\"\">Oregon and only comes home during holidays, at which time he stays part-time with his biological father and part-time with his biological mother who lives nearby.  This is Caiden’s only sibling.

<?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" /?><o:p class=\"\" o=\"http://unknownprefix/o\" xmlns:o=\" According'>http://unknownprefix/o\"> According to Mrs. A, this was a planned pregnancy and was her first.  There were no complications during the pregnancy with the exception of the development of gestational diabetes, which was controlled by diet and exercise. Mrs. A reports she was taking thyroid medication for a hypothyroid condition during the pregnancy as instructed by her physician.  The only complication related to the birth was a failure to dilate which required Pitocin, a medication which aids in dilation and contraction.  The medication failed to work and the baby was then physically extracted by a midwife.  Labor was 36 hours.

At the time of this observation Caiden weighed 23lbs and was 29 inches long.<o:p class=\"\" o=\"http://unknownprefix/o\" xmlns:o=\"

http://unknownprefix/o\"><p class=\"\">No physical abnormalities were observed and his mother reports that he has met all developmental milestones so far.<o:p class=\"\" o=\"http://unknownprefix/o\" xmlns:o=\" http://unknownprefix/o\"> </p>

I think it has to do with the style margins?

Hi,

Thank you for your interest in Aspose.Word.

Yes, it seems like you are right because style element isn’t supported at all. Please see here for more information:

http://www.aspose.com/Wiki/default.aspx/Aspose.Word/ConvertersInformation.html

Instead of raising an exception, can Aspose.Word ignore unsupported elements? Or should the server strip out unsupported tags?

We have logged your request, thank you. We will surely notify you as soon as fix this.

Can you please attach the above HTML fragment as a file instead of posting. I think it got garbled after posting (slashes were inserted, maybe something else).

Our CSS parsing is limited at the moment, but I should be able to make sure it does not throw if I have the file you are having problem with.

Just got back from vacation… that would be great if exceptions weren’t thrown if something was not supported like paragraph styles. I’ve attached the html.

Try using the latest version of Aspose.Word as it does not throw an exception for me. Attached is the document I was able to import.

I am currently using 2.3. Also, we don't insert HTML via files, we are pulling the HTML out of the database and something must have changed when I pasted into a file to attach.

Ok, the attached file throws an exception when InsertHTML is used. BTW, I use the InsertHTML method that accept an HTML string, not a filename.

Yes, this actually causes an exception. Thank you, we’ll look into it.

I noticed v2.4 came out and hasn’t resolved this issue. Any ETA on the fix?

Sorry, no comments for any estimated time.

Hey I noticed a new version came out today. I need to know if this bug is scheduled to be fixed so I can plan my product accordingly.

Sorry, no progress for this issue yet.

Has this issue been resolved yet?

Sorry, but these are not defects that we will be fixing immediately. Please understand it is the current set of features supported by HTML import and export in Aspose.Word.

We will be extending HTML import functionality in the future. In the meantime to see what is supported or not please see http://www.aspose.com/Wiki/default.aspx/Aspose.Word/ConvertersInformation.html

Pay attention to the following message "...inline CSS styles are supported, but support is limited to consuming Aspose.Word generated HTML files".

We use an HTML editor to allow users to add formatted paragraphs to a word document. Using InsertHTML raises exceptions for unsupported tags and elements such as paragraph styles. This exception handling policy with Aspose.Word forces us to strip out all formatting and simply append the text.

Couldn't Aspose.Word take a more friendly approach to HTML similar to how current internet browsers deal with HTML? In other words, can Aspose.Word simply ignore unsupported HTML formatting and insert the HTML it does understand? This would help our users tremendously.

We will do exactly that. Sorry still didn’t have time to do this work on HTML import yet. Although we are significantly improving how HTML tables are imported right now.

Great news! I’ve been waiting for this one for about 8 months now. Thank you Roman!

I downloaded v3.3.2.0 and it looks like InsertHTML is working and any unsupported HTML tags/attributes are ignored. However, the exception is still raised, which is fine as long as that’s the expected behavior. Can you verify that this is the expected behavior?