Aspose.Slides将ppt/pptx转成pdf

2021-05-03 02:26

阅读:496

标签:方法   去掉   ram   substring   strong   str   module   catch   row   

用Aspose.Slides将ppt/pptx转成pdf
/// 
        /// ppt转pdf
        /// 
        /// 文件地址
        /// 转换后的文件地址
        /// 
        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]
                {
                    "\u0003\u2003\u2009\u2004",
                    "\u0005\u2003\u2009\u2004",
                    "\u000F\u2003\u2001\u2003",
                    "\u0003\u2000",
                    "\u000F",
                    "\u0002\u2000",
                    "\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)
            {
                
            }
        }

 

Aspose.Slides将ppt/pptx转成pdf

标签:方法   去掉   ram   substring   strong   str   module   catch   row   

原文地址:https://www.cnblogs.com/jiangqw/p/12123956.html

上一篇:vs code settings.json

下一篇:ASP.NET:目录


评论


亲,登录后才可以留言!