麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

word ppt excel文檔轉(zhuǎn)換成pdf

2019-11-15 02:26:11
字體:
供稿:網(wǎng)友

Word PPT Excel文檔轉(zhuǎn)換成pdf

1.把word文檔轉(zhuǎn)換成pdf

(1).添加引用

1 using Microsoft.Office.Interop.Word;
添加引用

(2).轉(zhuǎn)換方法

 1 /// <summary> 2     /// 把Word文件轉(zhuǎn)換成pdf文件 3     /// </summary> 4     /// <param name="sourcePath">需要轉(zhuǎn)換的文件路徑和文件名稱</param> 5     /// <param name="targetPath">轉(zhuǎn)換完成后的文件的路徑和文件名名稱</param> 6     /// <returns>成功返回true,失敗返回false</returns> 7     public static bool WordToPdf(string sourcePath, string targetPath) 8     { 9         bool result = false;10         WdExportFormat wdExportFormatPDF = WdExportFormat.wdExportFormatPDF;//轉(zhuǎn)換格式1.wdExportFormatPDF轉(zhuǎn)換成pdf格式 2.wdExportFormatXPS轉(zhuǎn)換成xps格式11         object missing = Type.Missing;12         Microsoft.Office.Interop.Word.applicationClass applicationClass = null;13         Document document = null;14         try15         {16             applicationClass = new Microsoft.Office.Interop.Word.ApplicationClass();17             object inputfileName = sourcePath;//需要轉(zhuǎn)格式的文件路徑18             string outputFileName = targetPath;//轉(zhuǎn)換完成后PDF或XPS文件的路徑和文件名名稱19             WdExportFormat exportFormat = wdExportFormatPDF;//導(dǎo)出文件所使用的格式20             bool openAfterExport = false;//轉(zhuǎn)換完成后是否打開21             WdExportOptimizeFor wdExportOptimizeForPRint = WdExportOptimizeFor.wdExportOptimizeForPrint;//導(dǎo)出方式1.wdExportOptimizeForPrint針對打印進(jìn)行導(dǎo)出,質(zhì)量較高,生成的文件大小較大。2.wdExportOptimizeForOnScreen 針對屏幕顯示進(jìn)行導(dǎo)出,質(zhì)量較差,生成的文件大小較小。22             WdExportRange wdExportAllDocument = WdExportRange.wdExportAllDocument;//導(dǎo)出全部內(nèi)容(枚舉)23             int from = 0;//起始頁碼24             int to = 0;//結(jié)束頁碼25             WdExportItem wdExportDocumentContent = WdExportItem.wdExportDocumentContent;//指定導(dǎo)出過程中是否只包含文本或包含文本的標(biāo)記.1.wdExportDocumentContent:導(dǎo)出文件沒有標(biāo)記,2.導(dǎo)出文件有標(biāo)記26             bool includeDocProps = true;//指定是否包含新導(dǎo)出的文件在文檔屬性27             bool keepIRM = true;//28             WdExportCreateBookmarks wdExportCreateWordBookmarks = WdExportCreateBookmarks.wdExportCreateWordBookmarks;//1.wdExportCreateNoBookmarks:不要在導(dǎo)出文件中創(chuàng)建書簽,2.wdExportCreateHeadingBookmarks:標(biāo)題和文本框?qū)С龅奈募袆?chuàng)建一個書簽,3.wdExportCreateWordBookmarks每個字的書簽,其中包括除包含頁眉和頁腳中的所有書簽導(dǎo)出的文件中創(chuàng)建一個書簽。29             bool docStructureTags = true;30             bool bitmapMissingFonts = true;31             bool UseISO19005_1 = false;//生成的文檔是否符合 ISO 19005-1 (PDF/A)32             document = applicationClass.Documents.Open(ref inputfileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);33             if (document != null)34             {35                 document.ExportAsFixedFormat(outputFileName, exportFormat, openAfterExport, wdExportOptimizeForPrint, wdExportAllDocument, from, to, wdExportDocumentContent, includeDocProps, keepIRM, wdExportCreateWordBookmarks, docStructureTags, bitmapMissingFonts, UseISO19005_1, ref missing);36             }37             result = true;38         }39         catch40         {41             result = false;42         }43         finally44         {45             if (document != null)46             {47                 document.Close(ref missing, ref missing, ref missing);48                 document = null;49             }50             if (applicationClass != null)51             {52                 applicationClass.Quit(ref missing, ref missing, ref missing);53                 applicationClass = null;54             }55         }56         return result;57     }
方法
 1     /// <summary> 2     /// 把Word文件轉(zhuǎn)換成pdf文件 3     /// </summary> 4     /// <param name="sourcePath">需要轉(zhuǎn)換的文件路徑和文件名稱</param> 5     /// <param name="targetPath">轉(zhuǎn)換完成后的文件的路徑和文件名名稱</param> 6     /// <returns>成功返回true,失敗返回false</returns> 7     public static bool WordToPdf(object sourcePath, string targetPath) 8     { 9         bool result = false;10         WdExportFormat wdExportFormatPDF = WdExportFormat.wdExportFormatPDF;11         object missing = Type.Missing;12         Microsoft.Office.Interop.Word.ApplicationClass applicationClass = null;13         Document document = null;14         try15         {16             applicationClass = new Microsoft.Office.Interop.Word.ApplicationClass();17             document = applicationClass.Documents.Open(ref sourcePath, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);18             if (document != null)19             {20                 document.ExportAsFixedFormat(targetPath, wdExportFormatPDF, false, WdExportOptimizeFor.wdExportOptimizeForPrint, WdExportRange.wdExportAllDocument, 0, 0, WdExportItem.wdExportDocumentContent, true, true, WdExportCreateBookmarks.wdExportCreateWordBookmarks, true, true, false, ref missing);21             }22             result = true;23         }24         catch25         {26             result = false;27         }28         finally29         {30             if (document != null)31             {32                 document.Close(ref missing, ref missing, ref missing);33                 document = null;34             }35             if (applicationClass != null)36             {37                 applicationClass.Quit(ref missing, ref missing, ref missing);38                 applicationClass = null;39             }40         }41         return result;42     }
簡潔方法

(3).調(diào)用

1 OfficeToPdf.WordToPdf("d://1234.doc", "d://1234.pdf");
調(diào)用

2.把Excel文檔轉(zhuǎn)換成pdf

(1).添加引用

1 using Microsoft.Office.Interop.Excel;
添加引用

(2).轉(zhuǎn)換方法

 1     /// <summary> 2     /// 把Excel文件轉(zhuǎn)換成pdf文件 3     /// </summary> 4     /// <param name="sourcePath">需要轉(zhuǎn)換的文件路徑和文件名稱<
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 黄色免费播放网站 | 最新黄色av | 成人毛片100部 | 精品一区二区亚洲 | 92看片淫黄大片欧美看国产片 | 午夜视 | 天堂福利电影 | 国产一级一区二区三区 | 亚洲亚色| 久久亚洲网 | 久在线播放 | 亚洲第一成人在线视频 | 中文字幕一区二区三区四区 | 黄网站在线免费 | 成人一级片毛片 | 国产精品久久久久一区二区 | 黑人一区二区三区四区五区 | 亚洲一区在线观看视频 | 欧美a级大胆视频 | 逼片视频 | 久久久久久久久久性 | 91在线视频播放 | 国产无区一区二区三麻豆 | 999久久久 | 91av在线影院 | 男女隐私免费视频 | 久久综合福利 | 久久精品国产一区二区电影 | 亚欧在线免费观看 | 久久午夜免费视频 | 中文字幕在线播放一区 | 免费看日产一区二区三区 | 97精品视频在线观看 | 国产永久免费观看 | 久久99久久98精品免观看软件 | 黄色特级视频 | 新久久久久久 | 二区视频| 亚洲综合网站 | 一本精品999爽爽久久久 | 精品国产一区二区三区久久久蜜月 |