Free Spire.Presentation for .NET(免费版)
Visual Studio
获取方法1:通过E-iceblue官网下载包。下载后,解压文件,安装程序。安装后,将安装路径下Bin文件夹下的Spire.Presentation.dll文件添加引用至vs项目程序。如下所示:
获取方法2:可通过Nuget下载。
using Spire.Presentation; namespace RemoveImg{ class Program { static void Main(string[] args) { //加载文档 Presentation ppt = new Presentation(); ppt.LoadFromFile('test.pptx'); //获取第2张幻灯片 ISlide slide = ppt.Slides[1]; //遍历幻灯片中的所有形状 for (int i = 0; i < slide.Shapes.Count;i++ ) { IShape shape = slide.Shapes[i]; //删除图片形状 if (shape is SlidePicture) { SlidePicture pic = shape as SlidePicture; slide.Shapes.Remove(pic); } } //保存文档 ppt.SaveToFile('removeimg.pptx',FileFormat.Pptx2010); System.Diagnostics.Process.Start('removeimg.pptx'); } }}
图片删除前后效果: