zoukankan      html  css  js  c++  java
  • C# 实现PPT 每一页转成图片

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

    我这里用的这个这个版本

    Microsoft.Office.Interop.PowerPoint 12.0

    Microsoft Office 12.0 object Library

    如下图:

    代码如下:

     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();
            }
  • 相关阅读:
    Java字符串的常用方法
    鼠标移小图片大图片改变
    js获得ul li 下的img的src属性
    移动端左右滑动导航
    边框加阴影
    移动端网站根据设计稿动态设置rem
    使用git命令
    HTML返回顶部
    java对象头
    Flutter 实现酷炫的3D效果
  • 原文地址:https://www.cnblogs.com/ywtk/p/3295973.html
Copyright © 2011-2022 走看看