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

Free Support Forum - aspose.com

Set Background Color for Images

Hello Support,

We have a word document with images & other items in it. We want to change the background color of the images in that document using aspose words & want to generate a output document based on that.
We want to know what are the options available in aspose words to achieve this. Please let me know.

Also I want to attach here the source document as well. But not getting any option. Please help me with this as well.

Thanks,
Somnath

@somnathdas

Thanks for your inquiry. Please share your input file and expected output file as ZIP file here. You can create your expected output file using MS Word. We will look into your requirement and will guide you accordingly.

Hello Support,

Please check attached zip file where you will find screenshots & source document. Using ASPOSE Words we want to change color of any image exists in the document & want to generate a new one. Currently we are using the following set of code for changing fill colors of shapes:

foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
shape.FillColor = System.Drawing.Color.Red;
}

Please let me know further.18-10-2017.zip (221.9 KB)

Thanks,
Somnath

@somnathdas

Thanks for your inquiry. Please note images in your source document are filled with Gradient Fill option. I am afraid currently Aspose.Words does not support Gradient Fill. We have logged an enhancement ticket WORDSNET-16032 in our issue tracking system for the purpose. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Hello Support,

Thanks for the reply. I want to make sure if there is any option in aspose.words at all that can be used to change background color of image. If yes then please provide me a sample document with image & code as well. I want to make sure it works or not with a image which does not have any gradient.

Please let me know further on this.

Thanks,
Somnath

Hello Support,

For your information we are now using ASPOSE Total suite. So please let us know what we can do with color of images considering this point.

Thanks,
Somnath

@somnathdas

Please find attached documents. We have changed the Fill option of the image in first page header to Solid Fill using MS Word and left other images to Gradient fill. When we change fill color of the image as following with Aspose.Words for .NET. It is working as expected, image background color of first page header is changed to Yellow.
Source_Document_11.zip (153.0 KB)

Document doc = new Document("Source_Document_11.docx");
foreach (HeaderFooter hf in doc.GetChildNodes(NodeType.HeaderFooter, true))
{
    foreach (Shape shape in hf.GetChildNodes(NodeType.Shape, true))
    {
        if(shape.Filled)
        shape.FillColor = Color.Yellow;

    }
}
doc.Save(@"Source_Document_aw1710.docx");

For Gradient fill issue, we have recently logged a ticket and we will notify you as soon as it is resolved.

The issues you have found earlier (filed as WORDSNET-16032) have been fixed in this Aspose.Words for .NET 21.10 update also available on NuGet.