zoukankan      html  css  js  c++  java
  • Aspose.Slides将ppt/pptx转成pdf

    用Aspose.Slides将ppt/pptx转成pdf
    /// <summary>
            /// ppt转pdf
            /// </summary>
            /// <param name="path">文件地址</param>
            /// <param name="newFilePath">转换后的文件地址</param>
            /// <returns></returns>
            public static void PptToPdf(string path, string newFilePath)
            {
                var dir = newFilePath.Substring(0, newFilePath.LastIndexOf("/") + 1);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                Crack();//生成之前先调用破解方法,去掉水印。
                Aspose.Slides.Presentation ppt = new Aspose.Slides.Presentation(path);
                ppt.Save(newFilePath, Aspose.Slides.Export.SaveFormat.Pdf);
            }
            
            //去掉水印
            public static void Crack()//使用前调用一次即可
            {
                try
                {
                    ////调用Crack方法实现软破解
                    //HOTPathchAsposeSlides解密
                    string[] stModule = new string[8]
                    {
                        "u0003u2003u2009u2004",
                        "u0005u2003u2009u2004",
                        "u000Fu2003u2001u2003",
                        "u0003u2000",
                        "u000F",
                        "u0002u2000",
                        "u0003",
                        "u0002"
                    };
                    Assembly assembly = Assembly.GetAssembly(typeof(License));
                    Type typeLic = null, typeIsTrial = null, typeHelper = null;
                    foreach (Type type in assembly.GetTypes())
                    {
                        if ((typeLic == null) && (type.Name == stModule[0]))
                        {
                            typeLic = type;
                        }
                        else if ((typeIsTrial == null) && (type.Name == stModule[1]))
                        {
                            typeIsTrial = type;
                        }
                        else if ((typeHelper == null) && (type.Name == stModule[2]))
                        {
                            typeHelper = type;
                        }
                    }
                    if (typeLic == null || typeIsTrial == null || typeHelper == null)
                    {
                        throw new Exception();
                    }
                    object lic = Activator.CreateInstance(typeLic);
                    int findCount = 0;
                    foreach (FieldInfo field in typeLic.GetFields(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
                    {
                        if (field.FieldType == typeLic && field.Name == stModule[3])
                        {
                            field.SetValue(null, lic);
                            ++findCount;
                        }
                        else if (field.FieldType == typeof(DateTime) && field.Name == stModule[4])
                        {
                            field.SetValue(lic, DateTime.MaxValue);
                            ++findCount;
                        }
                        else if (field.FieldType == typeIsTrial && field.Name == stModule[5])
                        {
                            field.SetValue(lic, 1);
                            ++findCount;
                        }
    
                    }
                    foreach (FieldInfo field in typeHelper.GetFields(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance))
                    {
                        if (field.FieldType == typeof(bool) && field.Name == stModule[6])
                        {
                            field.SetValue(null, false);
                            ++findCount;
                        }
                        if (field.FieldType == typeof(int) && field.Name == stModule[7])
                        {
                            field.SetValue(null, 128);
                            ++findCount;
                        }
                    }
                    if (findCount < 5)
                    {
                        throw new NotSupportedException("无效的版本");
                    }
                }
                catch (Exception e)
                {
                    
                }
            }

  • 相关阅读:
    Linux入门(四)linux运行环境mysql详细操作及安装phpmyadmin
    Linux入门(五)linux服务器文件远程管理
    Linux入门(六)ubuntu下vim编辑器安装与使用
    windows下9款一键快速搭建PHP本地运行环境的好工具(含php7.0环境)
    Linux入门(三)搭建服务器linux运行环境LAMP/LNMP
    Linux入门(二)Linux基本命令及基本操作
    discuz使用总结
    ThinkPHP3.1快速入门(3)查询语言
    LeetCode 611. 有效三角形的个数(Valid Triangle Number)
    LeetCode 566. 重塑矩阵(Reshape the Matrix)
  • 原文地址:https://www.cnblogs.com/jiangqw/p/12123956.html
Copyright © 2011-2022 走看看