ppt-->PDF

下载并安装SaveAsPDF.exe
需要安装Office 2007和Microsoft提供的“Microsoft Save as PDF or XPS Add-in for 2007 Microsoft Office programs”组件,可以从官网下载。 
以下是代码(我用的Chrome浏览器,无法添加程序块,面前看吧。代码是我正在用的,无错误,直接复制过来) 
//ppt转pdf 

using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.core;
    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的引用 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值