C# 将PPT幻灯片转为高质量图片

2025-11-19 15:44:12

1、在VisualStudio 中打开【解决方案资源管理器】,鼠标右键点击【引用】,选择【管理NuGet包】:

C# 将PPT幻灯片转为高质量图片

2、选择【浏览】-在搜索框中输入-选中搜索结果-点击【安装】:

C# 将PPT幻灯片转为高质量图片

3、点击【OK】:

C# 将PPT幻灯片转为高质量图片

4、点击【我接受】,等待程序安装完成:

C# 将PPT幻灯片转为高质量图片

1、using Spire.Presentation;

using System.Drawing;

using System.Drawing.Imaging;

namespace PPTtoImg_PPT

{

    class Program

    {

        static void Main(string[] args)

        {

            //创建Presentation类实例,并加载文件

            Presentation presentation = new Presentation();

            presentation.LoadFromFile("test.pptx");

            //设置图片质量

            presentation.HighQualityImage = true;

            //遍历所有幻灯片,保存为指定格式的图片

            for (int i = 0; i < presentation.Slides.Count; i++)

            {                

                Image image = presentation.Slides[i].SaveAsImage();

                image.Save(string.Format("result-img-{0}.png", i), ImageFormat.Png);                

            }

        }

    }

}

2、执行程序,将幻灯片保存为图片到指定路径。这里的图片路径可以自定义。

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢