Saving Word 2007 Documents to PDF and XPS Formats
来源:互联网 发布:js判断变量是否未定义 编辑:程序博客网 时间:2024/06/09 14:13
public static void wordConvertPdf(string wordPath, string pdfPath) { oWord.Application wordApplication =new Microsoft.Office.Interop.Word.Application (); oWord.Document wordDocument = null; object paramSourceDocPath = wordPath;//eg.@"C:\Temp\Test.docx"; object paramMissing = Type.Missing; string paramExportFilePath =pdfPath;//eg.@"C:\Temp\Test.xps"; oWord.WdExportFormat paramExportFormat = oWord.WdExportFormat.wdExportFormatPDF; bool paramOpenAfterExport = false; oWord.WdExportOptimizeFor paramExportOptimizeFor = oWord.WdExportOptimizeFor.wdExportOptimizeForPrint; oWord.WdExportRange paramExportRange = oWord.WdExportRange.wdExportAllDocument; int paramStartPage = 0; int paramEndPage = 0; oWord.WdExportItem paramExportItem = oWord.WdExportItem.wdExportDocumentContent; bool paramIncludeDocProps = true; bool paramKeepIRM = true; oWord.WdExportCreateBookmarks paramCreateBookmarks =oWord.WdExportCreateBookmarks.wdExportCreateWordBookmarks; bool paramDocStructureTags = true; bool paramBitmapMissingFonts = true; bool paramUseISO19005_1 = false; try { // Open the source document. wordDocument = wordApplication.Documents.Open( ref paramSourceDocPath, 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); // Export it in the specified format. if (wordDocument != null) wordDocument.ExportAsFixedFormat(paramExportFilePath, paramExportFormat, paramOpenAfterExport, paramExportOptimizeFor, paramExportRange, paramStartPage, paramEndPage, paramExportItem, paramIncludeDocProps, paramKeepIRM, paramCreateBookmarks, paramDocStructureTags, paramBitmapMissingFonts, paramUseISO19005_1, ref paramMissing); } catch (Exception ex) {} finally { // Close and release the Document object. if (wordDocument != null) { wordDocument.Close(ref paramMissing, ref paramMissing, ref paramMissing); wordDocument = null; } // Quit Word and release the ApplicationClass object. if (wordApplication != null) { wordApplication.Quit(ref paramMissing, ref paramMissing, ref paramMissing); wordApplication = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } }
原帖地址:http://msdn.microsoft.com/en-us/library/bb412305.aspx
- Saving Word 2007 Documents to PDF and XPS Formats
- Export GridView with Images from database to Word Excel and PDF Formats
- Building Word 2007 Documents Using Office Open XML Formats
- word 转为pdf,xps;excel转为pdf,xps
- Printing documents to Microsoft XPS Document Writer without user interaction
- Create and manipulate PDF documents - 100% .NET
- Exporting from Crystal Reports to PDF, Word, Excel and HTML
- word to pdf
- Automating the Creation of Data-Rich Business Documents with Word 2007 and Visual Basic 2005
- Automating the Creation of Data-Rich Business Documents with Word 2007 and ASP.NET
- WORD转XPS格式
- how to extract and convert audio file formats
- How to Track Changes in Word 2016 Documents
- 使用Jacob批量转换word为txt、pdf、xps、html、xml等文档
- 使用Jacob批量转换word为txt、pdf、xps、html、xml等文档
- flash 中.Swf 格式的文字 转化为 word 或pdf 或 xps
- 使用Jacob批量转换word为txt、pdf、xps、html、xml等文档
- 使用Jacob批量转换word为txt、pdf、xps、html、xml等文档
- 善用GridView控件的HyperLinkField数据行
- Android NDK入门
- 另类思路解决textbox不支持(半)透明背景颜色的问题
- ADB commands
- js页面跳转代码
- Saving Word 2007 Documents to PDF and XPS Formats
- 阿里巴巴离职DBA职业生涯总结
- Android ApiDemos示例解析(81):Graphics->Text Align
- 常见DB2命令
- 反射详解-通过Class实例化具体类的对象(无参数构造)
- fopen 打开方式
- Android linux adb安装操作命令图解
- Python 中的strip lstrip rstrip使用方法 .
- 求解:struts2 模型驱动问题