Hi,
I am unable to read default shape background colour from PPT file.
If I make any new PPT and add just one shape say rectangle into it and don’t update any background colour, then I am getting NOT DEFINED as fill type.
But as soon as update the background colour,I’ll get the correct fill type.
Following is the code which we are using for reading background :-
public BackgroundStyle ReadBackground(AutoShape shape)
{
var fillType = BackgroundFillType.Solid;
try
{
fillType = (BackgroundFillType)Enum.Parse(typeof (BackgroundFillType), shape.FillFormat.FillType.ToString());
}
catch (Exception ex)
{
fillType = BackgroundFillType.NotDefined;
}
if (fillType == BackgroundFillType.Solid)
{
return GetSolidBackgroundStyle(shape.CreateFillFormatEffective());
}
if (fillType == BackgroundFillType.Gradient)
{
return GetGradientBackgroundStyle(shape.CreateFillFormatEffective());
}
if (fillType == BackgroundFillType.Picture)
{
return GetImageBackgroundStyle(shape.CreateFillFormatEffective());
}
if (fillType == BackgroundFillType.Pattern)
{
return GetPatternBackgroundStyle(shape.CreateFillFormatEffective());
}
return new SolidBackgroundStyle
{
Color = new Color
{
Value = Color.FromColor(System.Drawing.Color.Transparent).Value
},
FillType = BackgroundFillType.Solid
};
}
I am also attaching a sample file so that you can also check it.
Regards
Ankit Grover