Unable to Cast Object of Type Aspose.Slides.PictureFrame to Type Aspose.Slides.AutoShape

Hi, I am getting this error when I try to convert a powerpoint presentation(.ppt) to html file using aspose.slides.net version 22.8.0. I am also highlighting certain words in the presentation before converting to html…
The code I have been using is:

using (MemoryStream stream = new MemoryStream(filedata))
{
    Presentation presentation = new Presentation(stream);

    pageCount = presentation.Slides.Count;
    var scaleValue = 0.5f;
    var slideSize = presentation.SlideSize.Size;
    var newSize = new SizeF(slideSize.Width * scaleValue, slideSize.Height * scaleValue);

    if (words[0] != string.Empty)
    {
        foreach (var item in presentation.Slides)
        {
            ((AutoShape)item.Shapes[0]).TextFrame.HighlightText(words[0], Color.Yellow);
        }
    }
    for (int i = 0; i < pageCount; i++)
    {
        using (MemoryStream pageStream = new MemoryStream())
        {
            // Save each page as a separate document.
            using (var extractedPage = new Presentation())
            {
                extractedPage.SlideSize.SetSize(newSize.Width, newSize.Height, SlideSizeScaleType.EnsureFit);
                extractedPage.Slides.InsertClone(0, presentation.Slides[i]);
                ResponsiveHtmlController controller = new ResponsiveHtmlController();

                HtmlOptions htmlOpt = new HtmlOptions { HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller) };
                htmlOpt.PicturesCompression = PicturesCompression.Dpi72;
                htmlOpt.SvgResponsiveLayout = false;
                htmlOpt.JpegQuality = 50;
                extractedPage.Save(pageStream, SaveFormat.Html, htmlOpt);
            }
        }
    }
}

But for this file :
PPT file.zip (809.1 KB)

I am getting this error

Unable to cast object of type ‘Aspose.Slides.PictureFrame’ to type ‘Aspose.Slides.AutoShape’."

@pooja.jayan,
Thank you for contacting support.

Please take a look at the following code line in you example:

((AutoShape)item.Shapes[0]).TextFrame.HighlightText(words[0], Color.Yellow);

In PowerPoint documents, many content elements are not AutoShape objects. Your code example encountered a PictureFrame object that is not an AutoShape. First you should check if the object class implements the IAutoShape interface. Please use the following code snippet instead:

if (item.Shapes[0] is IAutoShape autoShape)
{
    autoShape.TextFrame.HighlightText(words[0], Color.Yellow);
}