zoukankan      html  css  js  c++  java
  • 将powerpoint文件保存为图片

                string filePath = Server.MapPath("/imageCache/" + fileName + ".ppt");//上传文件路径
                string filePathCreate = Server.MapPath("/imageCache/X" + fileName + ".jpg");//单文件临时路径
                string filePathCreateImg = Server.MapPath("/imageCache/I" + fileName + ".jpg");//生成文件路径
                file.SaveAs(filePath);
    
                if (file != null)
                {
                    PPT.Application pptApplication = new PPT.Application();
    
                    PPT.Presentation ppt = pptApplication.Presentations.Open(filePath,
                        Microsoft.Office.Core.MsoTriState.msoCTrue,
                          Microsoft.Office.Core.MsoTriState.msoTriStateMixed,
                            Microsoft.Office.Core.MsoTriState.msoFalse);
    
                    int count = ppt.Slides.Count;
                    //(720*540);
                    int pageWidth = 720;
                    int pageHight = 540;
                    Bitmap bitmap = new Bitmap(pageWidth, pageHight * count);
    
                    int h = 0;
                    foreach (PPT.Slide slide in ppt.Slides)
                    {
                        slide.Export(filePathCreate, "JPG");
                        Image img = Image.FromFile(filePathCreate);
                        Graphics g = Graphics.FromImage(bitmap);
                        Rectangle rect = new Rectangle(0, h, 720, 540);
                        g.DrawImage(img, rect);
                        img.Dispose();
                        h += pageHight;
                    }
    
                    bitmap.Save(filePathCreateImg, System.Drawing.Imaging.ImageFormat.Jpeg);
    
                    ViewBag.image = "I" + fileName + ".jpg";
    
                    return View();
                }
                return null;

    问题:依赖于office com,需要在服务器上安装office,不知道谁有不使用officeCom组件将ppt中的幻灯片转换为图片的方法

  • 相关阅读:
    用pyenv 和 virtualenv 搭建单机多版本python 虚拟开发环境
    如何快速地编写和运行一个属于自己的 MapReduce 例子程序
    Hive如何加载和导入HBase的数据
    kettle中的karaf设置
    sqoop学习
    windows 本地配置hadoop客户端
    python 随机分类
    python 皮尔森相关系数
    kettle配置命名参数
    idea配置scala和spark
  • 原文地址:https://www.cnblogs.com/ac1985482/p/2920244.html
Copyright © 2011-2022 走看看