Aspose.Slides font size missing

Hi, I’m using Aspose.Slides API for C# (.NET) and I’m trying to get font size of each shape but I can’t find that property. I need that so I can find biggest font and make it title of the current slide if title isn’t set. Please tell me is it some way to do that or can you add this property in the next version of the API?

Thank you previously!

@nikolamanov,

I have observed your requirements and like to share that the font height or size property resides in Portion of a text belonging to paragraph of a text frame. Every text frame has collection of paragraphs and every paragraph has a collection of portion inside it. You need to traverse through paragraph collection and for every paragraph traverse through each portion in portion collection for that paragraph. For every portion we have Portion.PortionFormat class that holds FontHeight property for setting and getting font height for the text. I hope the shared information will be helpful.

Thank you for this information, @mudassir.fayyaz . I find this property before create the topic but it is always set to float.NaN and can’t figure it out how to to get different value.

@nikolamanov,

I have observed the information shared by you. Actually, when you get NaN for font height, it means that font height is inherited from theme. I suggest you to please try using following sample code on your end to serve the purpose.

public static void TestFormat()
{
    String path = "C:\\Aspose Data\\69399-2\\";
    Presentation srcPres = new Presentation(path + "src.pptx");
    IShapeCollection srcShapes = srcPres.Slides[0].Shapes;
    foreach (IShape sp in srcShapes)
    {
        if (sp.GetType() is IAutoShape)
        {
            IAutoShape ashp = (IAutoShape)sp;
            if (ashp.TextFrame != null)
            {
                foreach (IParagraph para in ashp.TextFrame.Paragraphs)
                {

                    foreach (IPortion portion in para.Portions)
                    {
                        if (float.IsNaN(portion.PortionFormat.FontHeight))
                        {
                            IPortionFormatEffectiveData formateffect = portion.CreatePortionFormatEffective();
                            float height = formateffect.FontHeight;
                            
                        }
                        else
                        {
                            float height = portion.PortionFormat.FontHeight ;
                        }
                    }
                }
            }
        }
    }

}

@mudassir.fayyaz thank you very much. This works perfect :slight_smile: