I have a simple PowerPoint document consisting of a single slide with a single textbox in it. I am trying to use the AddFromHtml method in Aspose.Slides 24.11.0 to replace the existing placeholder text in the textbox with some formatted text read from an HTML file. The HTML file looks like this:
<p style="font-size:22pt">Font Color Test</p>
<p><span style='color: #0055FF'>This text is blue.</span></p>
<p><span style='background-color: #FFFF00'>This text is highlighted in yellow.</span></p>
Here is the exact code I am using:
string filename = "Presentation1.pptx";
using (var presentation = new Presentation(filename))
{
var slide = presentation.Slides.FirstOrDefault();
var shape = slide?.FindShapeByAltText("Target text box") as IAutoShape;
if (shape != null)
{
var html = File.ReadAllText("FormattedText.html");
Console.WriteLine(html);
var textFrame = shape.TextFrame;
textFrame.Paragraphs.Clear();
textFrame.Paragraphs.AddFromHtml(html);
presentation.Save(filename, SaveFormat.Pptx);
}
}
When I run the above code, the output looks like this (notice the third line is missing the yellow highlighting):
Actual output.png (2.7 KB)
Whereas I was expecting it to look like this:
Expected output.png (2.9 KB)
Is this a bug or known issue, or am I doing something wrong here? Is there a workaround? Please advise.
For reference, I’ve attached a complete sample project with all the code and files to reproduce the issue. AsposeSlidesTextBackgroundColorIssue.zip (26.2 KB)
Thanks,
Brian