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

Free Support Forum - aspose.com

Shape foreground fill is not shown

If I create a simple rectangle shape and fill it with a solid color, this is not reflected if I save the file to PNG with Aspose.Diagram.

If I open the .vdx with Visio, the shape is not filled either. If I examine the shape format in Visio it shows the fill correctly, but only when I change something interactively (e.g. the transparency from 0 to 0.1 and back), the shape is actually filled.
See attachments.

Hi Chris,

Thank you for contacting support. We have tested your sample code and Visio template against the latest build of Aspose.Diagram 5.5.0 and managed to replicate the problem of not showing the foreground fill color in the output VDX and PNG formats. We’ve logged these issues as follows:

DIAGRAMNET-50522 - Shape foreground fill is not visible in the resultant VDX
DIAGRAMNET-50523 - Shape foreground fill is not visible in the resultant PNG

Your post has also been linked to these issues. We’ll keep you informed regarding any available updates. We’re sorry for the inconvenience caused.

Hi Chris,

Thank you for being patient. For shape’s fill color, you may also need to set the fill pattern property. Please modify your source code as follows:

[.NET, C#]
shape.Line.LineColor.Value = green;
shape.Fill.FillForegnd.Value = green;

//add this line to set fillpattern
shape.Fill.FillPattern.Value = 1;

shape.Name = name;
shape.XForm.PinX = new DoubleValue(posX, MeasureConst.MM);
shape.XForm.PinY = new DoubleValue(2, MeasureConst.MM);
shape.XForm.Height = new DoubleValue(0.5, MeasureConst.MM);
shape.XForm.Width = new DoubleValue(0.5, MeasureConst.MM);

shape.Text.Value.Add(new Pp(0));
shape.Text.Value.Add(new Txt(name));

//add these line to set children shape’s fill
long s = diagram.AddShape(shape, “Rechteck”, 0);

Shape sp = diagram.Pages[0].Shapes.GetShape(s);

if (sp.Type == TypeValue.Group)
foreach (Shape ss in sp.Shapes)
ss.Fill.FillForegnd.Value = green;
ss.Fill.FillPattern.Value = 1;
ss.Line.LineColor.Value = green;

return sp;

We hope, this helps. Please let us know in case of any confusion or questions.

Note: we have closed both linked issue ids DIAGRAMNET-50522 and DIAGRAMNET-50523.

Thank you! Setting the fill on the sub shapes did the trick.

I guess I got confused because Visio seems to inherit the fill to the sub shapes automatically when you set or change it, and in Diagram you need to do that manually.

Hi Chris,

Thank you for the confirmation. It’s nice to hear from you that it works. You are right because you also need to iterate through the sub shapes to fill the color. Please let us know, in case you have any other query regarding the Aspose APIs. We’ll be happy to help you.