FindAndReplaceText

SlideUtil.FindAndReplaceText 方法

根据给定格式在演示文稿中查找和替换文本

public static void FindAndReplaceText(IPresentation presentation, bool withMasters, string find, 
    string replace, PortionFormat format = null)
参数类型描述
presentationIPresentation被扫描的演示文稿。
withMastersBoolean确定是否应扫描母版幻灯片。
findString要查找的字符串值。
replaceString要替换的字符串值。
formatPortionFormat替换文本部分的格式。如果为null,则使用找到字符串的第一个字符的格式

示例

[C#]
using (Presentation pres = new Presentation("pres.pptx"))
{
    PortionFormat format = new PortionFormat
    {
        FontHeight = 24f,
        FontItalic = NullableBool.True,
        FillFormat =
        {
            FillType = FillType.Solid,
            SolidFillColor =
            {
                Color = Color.Red
            }
        }
    };
    Aspose.Slides.Util.SlideUtil.FindAndReplaceText(pres, true, "[this block] ", "my text ", format);
    pres.Save("replaced", SaveFormat.Pptx);
}

另请参阅