Wrong font color

Hi,


In the attached presentation, I have just one slide with letter “V” on it. The color of the letter is white.

However, when I get the color of that letter via code, I get black.

Here’s the code I used:

String filePath = “LeCDMT.ppt”;

InputStream stream = new FileInputStream(filePath);
Presentation pres = new Presentation(stream);
Slide slide = pres.getSlides().get_Item(0);
Shape shape = slide.getShapes().get_Item(0);
TextFrame textFrame = shape.getTextFrame();
Paragraph paragraph = textFrame.getParagraphs().get_Item(0);
Portion portion = paragraph.getPortions().get_Item(0);

Color color = portion.getFontColor();
System.out.println(color);

Here’s the output:
java.awt.Color[r=0,g=0,b=0]

Can you check this?

Thanks,
Zeljko

Hi Zeljko,


Thank you for posting.

I have observed your comments and the file shared by you. It looks like you are using some old version of Aspose.Slides for Java on your end. I have made necessary changes in the code and now it is working as expected. I request you to please try usingAspose.Slides for Java 15.9.0 on your end and then share your kind feedback with us.

String filePath = “D:\LeCDMT.ppt”;
InputStream stream = new FileInputStream(filePath);
Presentation pres = new Presentation(stream);
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape shape = (AutoShape) slide.getShapes().get_Item(0);
ITextFrame textFrame = shape.getTextFrame();
IParagraph paragraph = textFrame.getParagraphs().get_Item(0);
IPortion portion = paragraph.getPortions().get_Item(0);
Color color = portion.createPortionFormatEffective().getFillFormat().getSolidFillColor();
System.out.println(color);

This gives the output, java.awt.Color[r=0,g=128,b=128] which changes if we change the color of text in source file.

Please let us know if the issue persists. We will be happy to assist you further.

Best Regards,

Hi Muhammad,


It looks like the code you wrote prints slide background color which is RGB: 0, 128, 128.

Text color of the letter “V” in the presentation is white (RGB: 255, 255, 255), but with the code below, I get it black (RGB: 0, 0, 0).

Color textColor = portion.getPortionFormat().getFillFormat().getSolidFillColor().getColor();
System.out.println(textColor);

Please see the screenshot I attached.

Thanks,
Zeljko

Hi Zeljko,


I have observed your comments and have made necessary changes in the code. Please try using following sample code on your end to serve the purpose and then share your kind feedback with us.

String filePath = “D:\LeCDMT.ppt”;
InputStream stream = new FileInputStream(filePath);
Presentation pres = new Presentation(stream);
ISlide slide = pres.getSlides().get_Item(0);
IAutoShape shape = (AutoShape) slide.getShapes().get_Item(0);
ITextFrame textFrame = shape.getTextFrame();
IParagraph paragraph = textFrame.getParagraphs().get_Item(0);
IPortion portion = paragraph.getPortions().get_Item(0);
Color color = portion.getPortionFormat().getFillFormat().getSolidFillColor().getColor();
System.out.println(color);

Please let us know if the issue persists. We will be happy to assist you further.

Best Regards,

Hi Muhammad,


With the code you provided, I still get the color of the “V” letter as (RGB: 0, 0, 0) which is incorrect. The color I see when I open the original presentation in Powerpoint is white (RGB: 255, 255, 255) as you can see in the screenshot I attached in my previous post.

Can you check this again?

Thank you,
Zeljko

Hi Zeljko,


I have observed your comments and like to share with you that the code shared by me is working perfect, as expected (see AllGood.JPG) . The only difference between the presentation shared by you (LeCDMT.ppt) and the one shared by me (LeCDMTmodified.ppt), is that I have chosen a specific color for the text. Let me explain this further for your better understanding,

1) In the first case (LeCDMT.ppt), you are making your choice among theme colors. White is default text color for the theme so PowerPoint does not save any specific color for the portion.
Portion.PortionFormat.FillFormat.FillType == FillType.NotDefined

2) In the second case (LeCDMTmodified.ppt), I am choosing specific color for the portion which is white.
Portion.PortionFormat.FillFormat.FillType == FillType.Solid

I hope this will clarify the concept. Please share if I may help you further in this regard.

Best Regards,