Font color lost when inserting HTML


#1

I am evaluating Aspose Word and have run into the following problem: When I use the InsertHtml method in DocumentBuilder, the font color is sometimes lost. The HTML was created from a Word document. I have attached the document file that the HTML is added to.

Thanks

Code:

public void InsertHTMLAtEnd(string fileName, string html, string outFileName)

{

FileStream inStream = File.OpenRead(fileName);

FileStream outStream = File.OpenWrite(outFileName);

try

{

Word word = new Word();

Document doc = word.Open(inStream);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToDocumentEnd();

builder.InsertHtml(html);

doc.Save(outStream, SaveFormat.FormatDocument);

}

finally

{

if(inStream != null)

{

inStream.Close();

}

if(outStream != null)

{

outStream.Close();

}

}

}

HTML:

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">







This is an HTML file with some formatting





This is an HTML file with some formatting.

 

<span
style='color:#99CC00'>This is italic and green.

 

<span
style='color:red'>This is bold and red
.

 

This is underlined and blue.

 

This is BIG
and yellow

 

 


#2

Hi,

Thank you for evaluating Aspose.Word.

Are you using the latest version of the component? I can't see any problems with font color when inserting your HTML. I've attached the resulting document.


#3

I downloaded the eval version a couple of weeks ago. Is there a newer version?

Never mind. I found where the problem is. I had no new lines in the html and this was causing problems. Thanks.