国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net實現將ppt文檔轉換成pdf的方法

2024-07-10 13:28:27
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了asp.net實現將ppt文檔轉換成pdf的方法,通過自定義函數實現將pptx格式的文件轉換成pdf格式文件的功能,是非常實用的技巧,需要的朋友可以參考下
 
 

本文實例講述了asp.net實現將ppt文檔轉換成pdf的方法。分享給大家供大家參考。具體實現方法如下:

一、添加引用

復制代碼代碼如下:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;

 

二、轉換方法

 

復制代碼代碼如下:
///<summary>        
/// 把PowerPoint文件轉換成PDF格式文件       
///</summary>        
///<param name="sourcePath">源文件路徑</param>     
///<param name="targetPath">目標文件路徑</param> 
///<returns>成功返回true,失敗返回false</returns> 
public static bool PPTConvertToPDF(string sourcePath, string targetPath)
{
        bool result;
        PpSaveAsFileType ppSaveAsFileType = PpSaveAsFileType.ppSaveAsPDF;//轉換成pdf
        object missing = Type.Missing;
        Microsoft.Office.Interop.PowerPoint.ApplicationClass application = null;
        Presentation persentation = null;
        try
        {
            application = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
            persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
            if (persentation!=null)
            {
                persentation.SaveAs(targetPath, ppSaveAsFileType, MsoTriState.msoTrue);
            }
            result = true;
        }
        catch
        {
            result = false;
        }
        finally
        {
            if (persentation != null)
            {
                persentation.Close();
                persentation = null;
            }
            if (application != null)
            {
                application.Quit();
                application = null;
            }
        }
        return result;
}

 

三、調用

復制代碼代碼如下:
OfficeToPdf.PPTToPDF("d://12345.pptx", "d://12345.pdf");

 

希望本文所述對大家的asp.net程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 尼勒克县| 甘孜县| 青海省| 彝良县| 安龙县| 温宿县| 濉溪县| 甘肃省| 兴国县| 金川县| 宾阳县| 贵阳市| 伊宁县| 金平| 策勒县| 巩义市| 建德市| 林周县| 简阳市| 焦作市| 长岭县| 永宁县| 张家界市| 万州区| 廊坊市| 安义县| 当涂县| 萍乡市| 兴隆县| 巴东县| 晋中市| 秀山| 榆中县| 泌阳县| 永丰县| 城固县| 磐安县| 湄潭县| 比如县| 攀枝花市| 岫岩|