Line break removes color of text

Hi, I’m currently working on a document export and I want to color the text. The coloring works but when I insert a line break and convert it to a word document the color goes away. The HTML that the text is based of works perfectly fine and colors the whole text. Does anyone know what’s the problem and how to fix it?

Example
The HTML looks like this

HTML:

<span style="color: #00B050;"><br><i>Correction note: Correction note: Lorem ipsum dolor sit amet, consetetur 
sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit 
</i></span>

The whole text is green and that’s how it should be but after converting it to Word it looks like this:

I hope it’s somewhat clear what I mean and already thanks for any help.

@Yachti Unfortunately, it is not quite clear how to reproduce the problem . I have used the following code for testing:

string html = "<span style=\"color: #00B050;\"><br><i>Correction note: Correction note: Lorem ipsum dolor sit amet, consetetur \r\nsadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit \r\n</i></span>";

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(html);
doc.Save(@"C:\Temp\out.docx");

Here is the produced output: out.docx (7.2 KB)

The whole text is green, just like expected.

Huh okay, then I keep trying to fix. But thanks for testing it :slight_smile:

1 Like