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

Free Support Forum - aspose.com

Text box shape and Run highlight color

Inside of a text box shape I am unable to set the Font
highlight to Transparent or to any background color, it always shows up
as White. See pages 6, 15, 18, 21, etc. In Word, if I manually set the
Shape’s highlight to ‘No Color’ it displays the way I intend. Is there
any way to do this in Aspose? When i insert the run i’ve tried the
following code and it doesn’t work:

run.Font.HighlightColor = Color.Transparent;
run.Font.Shading.BackgroundPatternColor = Color.Transparent;

For relevant attachments please see my post in this issue: https://forum.aspose.com/t/word-shapes-not-appearing-in-pdf/124986

We are freezing all development later this week so your prompt response is greatly appreciated!

Thanks!

Hi
Thanks for your inquiry. You should use Color.FromArgb(0, 0, 0, 0) instead Color.Transparent. Please try using the following code:

//Open document
Document doc = new Document(@"Test172\index.doc");
//Get collection of shapes
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in shapes)
{
    //Get collection of runs
    NodeCollection runs = shape.GetChildNodes(NodeType.Run, true);
    foreach (Run run in runs)
    {
        run.Font.HighlightColor = Color.FromArgb(0, 0, 0, 0);
        run.Font.Shading.BackgroundPatternColor = Color.FromArgb(0, 0, 0, 0);
    }
}
//Save document
doc.Save(@"Test172\out.doc");

Hope this helps.
Best regards.

Worked perfectly. Thanks!!!