c# 实现PPT自动转换成PDF格式的文件

来源:互联网  时间:2016/6/25 1:17:14

关于网友提出的“ c# 实现PPT自动转换成PDF格式的文件”问题疑问,本网通过在网上对“ c# 实现PPT自动转换成PDF格式的文件”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: c# 实现PPT自动转换成PDF格式的文件
描述:

请问前辈们 有类似的开发经验吗? 有的话希望提供点资料或者代码!感激不尽


解决方案1:

需要安装Office 2007和Microsoft提供的“Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs”组件,可以从官网下载。 以下是代码(我用的Chrome浏览器,无法添加程序块,面前看吧。代码是我正在用的,无错误,直接复制过来) //ppt转pdf     protected void PPTToPDF(string fileNameDateTime, string fileNameDateTimeWithoutExtension)     {         string paramSource = Server.MapPath("~/materials/internalPDF/") + fileNameDateTime;         string paramTarget = Server.MapPath("~/materials/internalPDF/") + fileNameDateTimeWithoutExtension + ".pdf";         Microsoft.Office.Interop.PowerPoint.ApplicationClass application = null;         Microsoft.Office.Interop.PowerPoint.Presentation presentation = null;         try         {
            application = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();             presentation = application.Presentations.Open(paramSource, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);             presentation.SaveAs(paramTarget, PpSaveAsFileType.ppSaveAsPDF, MsoTriState.msoTrue);         }         catch (Exception ex)
        {             throw new Exception(ex.Message);         }         finally         {<>             if (presentation != null)             {
                presentation.Close();                 presentation = null;
            }
/>             if (application != null)
            {                 application.Quit();                 application = null;             }             GC.Collect();             GC.WaitForPendingFinalizers();             GC.Collect();             GC.WaitForPendingFinalizers();         }
    } 注意添加对Microsoft.Office.Interop.PowerPoint的引用 以上方法中,两个参数分别是源文件名和转换后的PDF文件名,你自己再改。 有问题发站内信

上一篇请指教,支付宝相关的问题!!!
下一篇RadioButtonList只读
明星图片
相关文章
《 c# 实现PPT自动转换成PDF格式的文件》由码蚁之家搜集整理于网络,
联系邮箱:mxgf168#qq.com(#改为@)