Free Support Forum - aspose.com

Getting wrong color for Bullet (C# .NET)

Hi,
I have been using aspose.Slides for a while. I found incorrect color values for Bullet.
Code used to get bullet color is shown below

        var paraFormat = paragraph.ParagraphFormat.GetEffective();
        var bulletFormat = paraFormat.Bullet;
        var aColor = bullerFormat.Color;
        
        var r = aColor.R.ToString();
        var g = aColor.G.ToString();
        var b = aColor.B.ToString();
        var a = aColor.A.ToString();

In the attached pptx, the paragraph containing “second” text has bullet color of black, but i get rgba(153,153,204,255) a light blue color. i Have attached the minimal test pptx file Bullet.zip (13.5 KB)

@pravin254,

The issue lies in your following line of code where you are calling GetEffective() method. When you call following statement, you are in fact resetting the paragraph format and getting inherited settings from theme.

You simply need to call following line and then get the colors.

	public static void TestBulletColor()
	{
		String path = @"C:\Users\mudas\Downloads\Bullet\";
		Presentation pres = new Presentation(path + "Bullet.pptx");
		ISlide slide = pres.Slides[0];

		foreach(IShape shape in slide.Shapes)
		{
			if(shape is IAutoShape)
			{
				IAutoShape ashp = (IAutoShape)shape;

				if(ashp.TextFrame!=null && ashp.TextFrame.Text!=String.Empty)
				{
					ITextFrame text = ashp.TextFrame;

					for(int i=0;i<text.Paragraphs.Count;i++)
					{
						IParagraph para = text.Paragraphs[i];

						if(para.Text.Contains("Second"))
						{
							IParagraphFormat format = para.ParagraphFormat;

							//var format = para.ParagraphFormat.GetEffective();

							var color =format.Bullet.Color;
							
						}
					}

				}

			}
			
		}
	}

@mudassir.fayyaz
You are right. I am getting the inherited bullet color. But, the bullet color in the layout slides is black. So, i should get black color in the inherited shape right?. Please clarify if i am wrong

@pravin254,

You will only be accessing the inherited bullet color if the bullet color from Paragraph format is returned as Undefined. If there is a valid bullet color in Paragraph format then it means that color has be overrides the inherited bullet color. Therefore, the above sample code is fine and returning the valid bullet color that has been used in your presentation.

@mudassir.fayyaz
Thanks for the clarification. If I understood clearly, i have to check if bullet type is “NotDefined”, if so then i have to check layout slide or use the effectiveData. if bullet type is “symbol” then i can use that directly. One more thing, how to set bullet size[like font size]. Bullet.height i am getting 70 which is not correct. Thanks

@pravin254,

You can set the bullet height using following sample code.

							IParagraphFormat format = para.ParagraphFormat;
							format.Bullet.Height = 10f;

@mudassir.fayyaz
Thanks for your help

If I use this code I am getting NotDefined in both normal slides and layout slides. Master slides does not have any shape. I am using the attached sample pptx file.

@pravin254,

You need to use GetEffective() method to get inherited format for the portion.

		IPortionFormatEffectiveData dat = chartTitle.PortionFormat.GetEffective();

@mudassir.fayyaz I was refering to the bulletFormat. Earlier I used GetEffective() for paragraphFormat to get the inherited paragraph format. The issue with that code was getting wrong bullet colors. You mentioned to use without GetEffective(). But with that code my Bullet is undefined in both slides, layoutslides. I am trying to get the inherited bullet color that is visible in sample pptx. Thanks

@pravin254

Please provide the source presentation, used sample code obtained result and desired output that you ought to obtain using Aspose.Slides.

@mudassir.fayyaz
I have added the source presentation along with the aspose code (.cs file) in the provided “bulletissues.zip” file. Please find the attachmentBulletIssue.zip (26.5 KB)

@pravin254,

Can you please verify the image shared and confirm if this is the wrong bullet color that you are referring to.Please share the information so that I may add that in our issue tracking system.

image.png (10.9 KB)

@mudassir.fayyaz
Yes. The highlighted text is the wrong bullet color, expected to have (0,0,0,255). Please find the attached image for output color i am getting.bulletIssue.png (17.0 KB)

@pravin254,

A ticket with ID SLIDESNET-42072 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.