zoukankan      html  css  js  c++  java
  • aspose ppt转图片

    如果直接转图片,会很模糊
    采用先将ppt转pdf,在通过pdf转图片,这样出来的结果就非常清晰

      var pptFileName = "公司网络及计算机使用与要求.pptx";
                Presentation ppt = new Presentation(pptFileName);
                Stream st=new MemoryStream();
                ppt.Save(st,SaveFormat.Pdf);
                Aspose.Pdf.Document document = new Aspose.Pdf.Document(st);
                var device = new Aspose.Pdf.Devices.JpegDevice();
                
                //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
                device = new Aspose.Pdf.Devices.JpegDevice(100);
                //遍历每一页转为jpg
                for (var i = 1; i <= document.Pages.Count; i++)
                {
                    string filePathOutPut = Path.Combine("images", string.Format("{0}.jpg", i));
                    FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
                    try
                    {
                        device.Process(document.Pages[i], fs);
                        fs.Close();
                    }
                    catch (Exception ex)
                    {
                        fs.Close();
                        //   File.Delete(filePathOutPut);
                    }
                }
    View Code

    注意,aspose新的版本加载ppt都是一样的代码:

    Presentation ppt = new Presentation(pptFileName);

    比较老的版本对于ppt的版本有区别,

    如果后缀名是ppt,那么使用:

    Presentation ppt = new Presentation(pptFileName);

    如果后缀名是pptx,那么使用:

    PresentationEx ppt = new PresentationEx(pptFileName);

    怎样区分aspose的版本是老的还是新的呢,有一个笨办法,查看有没有PresentationEx 这个类,如果有,那么是老版本,没有就是新版本。

  • 相关阅读:
    POJ 3635 Full Tank?
    ZOJ 2112 Dynamic Rankings
    POJ 3468 A Simple Problem with Integers (2)
    FJOI2007 轮状病毒
    HDU 3308 LCIS
    POJ 2449 Remmarguts' Date
    Adroid平台图表案例源码
    Android项目——实现时间线程源码
    关于Ubuntu上Eclipse不显示手机设备
    自定义ListView下拉弹起效果
  • 原文地址:https://www.cnblogs.com/sczmzx/p/9729544.html
Copyright © 2011-2022 走看看