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

首頁(yè) > 編程 > .NET > 正文

asp.net實(shí)現(xiàn)將ppt文檔轉(zhuǎn)換成pdf的方法

2024-07-10 12:48:20
字體:
供稿:網(wǎng)友

本文實(shí)例講述了asp.net實(shí)現(xiàn)將ppt文檔轉(zhuǎn)換成pdf的方法。。具體實(shí)現(xiàn)方法如下:

一、添加引用
代碼如下:using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;

二、轉(zhuǎn)換方法

代碼如下:///<summary>       
/// 把PowerPoint文件轉(zhuǎn)換成PDF格式文件      
///</summary>       
///<param name="sourcePath">源文件路徑</param>    
///<param name="targetPath">目標(biāo)文件路徑</param>
///<returns>成功返回true,失敗返回false</returns>
public static bool PPTConvertToPDF(string sourcePath, string targetPath)
{
        bool result;
        PpSaveAsFileType ppSaveAsFileType = PpSaveAsFileType.ppSaveAsPDF;//轉(zhuǎn)換成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;

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宝清县| 富川| 滦南县| 赤城县| 寻甸| 石河子市| 枝江市| 克东县| 八宿县| 民勤县| 房山区| 花莲县| 洞头县| 天气| 麻城市| 云龙县| 锦屏县| 台北县| 建宁县| 岑巩县| 乌兰县| 阜宁县| 丽水市| 南阳市| 砚山县| 镇平县| 当阳市| 枣强县| 宝坻区| 凯里市| 长兴县| 习水县| 洛南县| 阜阳市| 盐池县| 金秀| 黔江区| 进贤县| 新乐市| 子长县| 岳普湖县|