【问题标题】:Finding a given word in MS Powerpoint by AsposeAspose 在 MS Powerpoint 中查找给定单词
【发布时间】:2018-08-11 09:10:42
【问题描述】:

我正在尝试通过 Aspose 检查 MS Powerpoint 是否包含给定的单词,但它不起作用。

这是我的班级,负责检查ppt文件:

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));
    }
}

我调用它来检查给定的单词:

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

虽然我的 ppt 文件包含一个文本框,内容为:“这是演示文稿”,但 isContain 始终为 false。我已经调试过了,类可以打开ppt文件,但是文本框的值不正确。

【问题讨论】:

    标签: c# .net aspose


    【解决方案1】:

    @Nhan Phan,

    我已经观察到您共享的要求,并且代码示例看起来也不错。但是,为了进一步调查我们的问题,我要求您分享源演示文稿以及所需的文本以查找。还请分享幻灯片索引,我可以在 PowerPoint 中找到所需的文本。您可能也有不同大小写的文本。请分享所要求的信息,以便我最终验证这一点。

    我在 Aspose 担任开发人员宣传员。

    【讨论】:

      【解决方案2】:

      可能是因为“由于评估版本限制而被截断。”。当您没有许可证时,它将仅限于 Aspose 的几乎功能。您可以申请试用版以进行全面测试。

      【讨论】:

        【解决方案3】:

        我已经解决了。问题来自“由于评估版本限制,文本已被截断。”。这意味着我没有使用有效的许可证,并且所有文本框中的所有文本值都被截断了。

        解决方案:我已申请试用许可证,将其添加到我的项目中:

        Aspose.Slides.License license = new Aspose.Slides.License();
        license.SetLicense("my license file");
        

        【讨论】:

          【解决方案4】:

          @Nhan Phan,

          当您在未经许可的情况下使用 API 时,它会对所有文本提取施加限制。当您使用许可时,API 不会限制您使用任何功能。

          【讨论】:

            猜你喜欢
            • 2018-02-28
            • 1970-01-01
            • 2015-08-15
            • 2012-09-10
            • 1970-01-01
            • 2012-10-01
            • 2015-05-06
            • 1970-01-01
            • 2023-03-29
            相关资源
            最近更新 更多