RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
C#实现PPT每一页转成图片过程解析

要实现PPT转图片,首先需要引用两个DLL。

江达网站建设公司创新互联,江达网站设计制作,有大型网站制作公司丰富经验。已为江达成百上千提供企业网站建设服务。企业网站搭建\外贸网站建设要多少钱,请找那个售后服务好的江达做网站的公司定做!

我这里用的这个这个版本

  • Microsoft.Office.Interop.PowerPoint 12.0
  • Microsoft Office 12.0 object Library

如下图:

C# 实现PPT 每一页转成图片过程解析

C# 实现PPT 每一页转成图片过程解析

代码如下:

private void pptToImg(string pptPath, string imgPath)
    {
      var app = new Microsoft.Office.Interop.PowerPoint.Application();

      var ppt = app.Presentations.Open(pptPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);

      var index = 0;

      var fileName = Path.GetFileNameWithoutExtension(pptPath);

      foreach (Microsoft.Office.Interop.PowerPoint.Slide slid in ppt.Slides) 
      {
        ++index;
        //设置图片大小
        slid.Export(imgPath+string.Format("page{0}.png",index.ToString()), "png", 1024, 768);
        //根据屏幕尺寸。设置图片大小
        //slid.Export(imgPath+string.Format("page{0}.jpg",index.ToString()), "jpg", Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
      }

      //释放资源
      ppt.Close();
      app.Quit();
      GC.Collect();
    }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。


标题名称:C#实现PPT每一页转成图片过程解析
新闻来源:http://sczitong.cn/article/jhigsi.html