在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1、首先安装 Microsoft Office 2007加载项:Microsoft Save as PDF-简体中文版:下载地址: http://download.microsoft.com/download/3/8/8/388812b2-0d3f-474e-a7ef-b095d3d0d3cd/SaveAsPDF.exe public int ConvertWordToPdfByPlugin(string sourceFilePath, string destFilePath) { int result = 0; object paramMissing = Type.Missing; Word.ApplicationClass wordApplication = new Word.ApplicationClass(); Word.Document wordDocument = null; try { object paramSourceFilePath = sourceFilePath; Word.WdExportFormat paramExportFormat = Word.WdExportFormat.wdExportFormatPDF; wordDocument = wordApplication.Documents.Open( ref paramSourceFilePath, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing, ref paramMissing); if (wordDocument != null) { Word.WdExportOptimizeFor paramExportOptimizeFor = Word.WdExportOptimizeFor.wdExportOptimizeForPrint; Word.WdExportRange paramExportRange = Word.WdExportRange.wdExportAllDocument; Word.WdExportItem paramExportItem = Word.WdExportItem.wdExportDocumentContent; Word.WdExportCreateBookmarks paramCreateBookmarks = Word.WdExportCreateBookmarks.wdExportCreateWordBookmarks; wordDocument.ExportAsFixedFormat(destFilePath, paramExportFormat, false, paramExportOptimizeFor, paramExportRange, 0, 0, paramExportItem, true, true, paramCreateBookmarks, true, true, false, ref paramMissing); } else { ScriptUtil.Alert("读取源word文件出错!"); } } catch (Exception ex) { LogUtil.WriteLog(ex); result = 1; } finally { if (wordDocument != null) { wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing); wordDocument = null; } if (wordApplication != null) { wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing); wordApplication = null; } } return result; }
|
请发表评论