ac1985482
            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中的幻灯片转换为图片的方法

分类:

技术点:

相关文章:

  • 2021-12-14
  • 2021-06-14
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-14
  • 2021-10-18
  • 2021-09-05
  • 2021-08-02
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案