We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

InsertHTML with 'style'

Hello, I’m evaluating your product. Why the following code does not generate the word ‘question’ in red?

builder.InsertHtml("Sample <span style=\"color: rgba(230, 76, 76, 1)\">question</span>?");

Note: I cannot edit the HTML code because it’s generated by CKEditor 5 and I need to print it.
Thanks!

@VisualPa Aspose.Words’ document model doesn’t support colors that are not fully opaque and sets alpha value of all colors to 1. As a result, we cannot fully support rgba() and hsla() CSS functions.
By the way, MS Word also does not support rgba() CSS function.
As a workaround, you can replace rgba() with rgb() CSS function. For example see the following simple code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

string html = "Sample <span style=\"color: rgba(230, 76, 76, 1)\">question</span>?";
html = Regex.Replace(html, @"rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d+)\)", "rgb($1,$2,$3)");
builder.InsertHtml(html);

doc.Save(@"C:\Temp\out.docx")