Search code examples
c#.netaspose

Finding a given word in MS Powerpoint by Aspose


I am trying to check a MS Powerpoint is contain a given word or not by Aspose, but it does not work.

This is my class which is responsible to check the ppt file:

public class FindContentOfPpt
{
    private static bool IsParagraphContain(IParagraph paragraph, string content)
    {
        return paragraph.Portions.Any(port => port.Text.Contains(content));
    }

    private static bool IsTextBoxContain(ITextFrame textBox, string content)
    {
        return textBox.Paragraphs.Any(para => IsParagraphContain(para, content));
    }

    private static bool IsSlideContain(ISlide slide, string content)
    {
        var allTextBoxes = SlideUtil.GetAllTextBoxes(slide);
        return allTextBoxes.Any(textBox => IsTextBoxContain(textBox, content));
    }

    public bool IsContain(string filePath, string content)
    {
        var pres = new Presentation(filePath);

        return pres.Slides.Any(slide => IsSlideContain(slide, content));
    }
}

And I call it to check a given word:

var isContain = new FindContentOfPpt().IsContain("Find and Replace.pptx", "Presentation");

The isContain is always false although my ppt file contain a text box with content:"This is Presentation". I already debugged, and the class can open the ppt file, but the textbox value is not correct.


Solution

  • Maybe it because of 'truncated due to evaluation version limitation.". When you don't have license, it will limited to almost features of Aspose. You can request a trial version for full testing.