国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 西青区| 通许县| 公安县| 四子王旗| 精河县| 大名县| 双牌县| 西畴县| 忻城县| 班戈县| 张家口市| 昔阳县| 疏附县| 浪卡子县| 佳木斯市| 抚州市| 富蕴县| 凯里市| 祁阳县| 乌拉特中旗| 遂平县| 汽车| 临清市| 巧家县| 抚顺县| 开鲁县| 来凤县| 乐山市| 白河县| 唐海县| 张家川| 平山县| 堆龙德庆县| 阿坝| 扶风县| 陈巴尔虎旗| 融水| 寻乌县| 湘潭县| 石屏县| 广昌县|