.net将word文档格式转换为pdf文件格式
来源:互联网 发布:必读的书 知乎 编辑:程序博客网 时间:2024/05/16 08:23
public static bool WordToPdf(string sourcePath, string targetPath) { bool result = false; WdExportFormat wdExportFormatPDF = WdExportFormat.wdExportFormatPDF;//转换格式1.wdExportFormatPDF转换成pdf格式 2.wdExportFormatXPS转换成xps格式 object missing = Type.Missing; ApplicationClass applicationClass = null; Document document = null; try { applicationClass = new ApplicationClass(); object inputfileName = sourcePath;//需要转格式的文件路径 string outputFileName = targetPath;//转换完成后PDF或XPS文件的路径和文件名名称 WdExportFormat exportFormat = wdExportFormatPDF;//导出文件所使用的格式 bool openAfterExport = false;//转换完成后是否打开 WdExportOptimizeFor wdExportOptimizeForPrint = WdExportOptimizeFor.wdExportOptimizeForPrint;//导出方式1.wdExportOptimizeForPrint针对打印进行导出,质量较高,生成的文件大小较大。2.wdExportOptimizeForOnScreen 针对屏幕显示进行导出,质量较差,生成的文件大小较小。 WdExportRange wdExportAllDocument = WdExportRange.wdExportAllDocument;//导出全部内容(枚举) int from = 0;//起始页码 int to = 0;//结束页码 WdExportItem wdExportDocumentContent = WdExportItem.wdExportDocumentContent;//指定导出过程中是否只包含文本或包含文本的标记.1.wdExportDocumentContent:导出文件没有标记,2.导出文件有标记 bool includeDocProps = true;//指定是否包含新导出的文件在文档属性 bool keepIRM = true;// WdExportCreateBookmarks wdExportCreateWordBookmarks = WdExportCreateBookmarks.wdExportCreateWordBookmarks;//1.wdExportCreateNoBookmarks:不要在导出文件中创建书签,2.wdExportCreateHeadingBookmarks:标题和文本框导出的文件中创建一个书签,3.wdExportCreateWordBookmarks每个字的书签,其中包括除包含页眉和页脚中的所有书签导出的文件中创建一个书签。 bool docStructureTags = true; bool bitmapMissingFonts = true; bool UseISO19005_1 = false;//生成的文档是否符合 ISO 19005-1 (PDF/A) 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); if (document != null) { document.ExportAsFixedFormat(outputFileName, exportFormat, openAfterExport, wdExportOptimizeForPrint, wdExportAllDocument, from, to, wdExportDocumentContent, includeDocProps, keepIRM, wdExportCreateWordBookmarks, docStructureTags, bitmapMissingFonts, UseISO19005_1, ref missing); } result = true; } catch { result = false; } finally { if (document != null) { document.Close(ref missing, ref missing, ref missing); document = null; } if (applicationClass != null) { applicationClass.Quit(ref missing, ref missing, ref missing); applicationClass = null; } } return result; }
0 0
- .net将word文档格式转换为pdf文件格式
- 用ASP.Net实现将Word文档转换为PDF格式
- 如何将PDF格式转换为WORD文档
- 如何将PDF格式转换为WORD文档
- 用ASP_Net实现将Word文档转换为PDF格式
- 如何实现将Word文档转换为PDF格式
- 如何实现将Word文档转换为PDF格式
- 将PDF文件转换为word文档格式
- 用C#.NET实现生成PDF文档和将WORD转换为PDF
- 用C#.NET实现生成PDF文档和将WORD转换为PDF
- 在.net下将word文档转换为加有水印pdf文档
- 怎么将PDF格式的资料转换为word格式
- 利用wxPython将word 文档转换为pdf文档
- java将word文档转换为pdf文档
- Windows下将Word文档转换为PDF文档
- 将Word转换成PDF格式文档的方法
- 如何将word转换成pdf格式的文档
- 如何将pdf转换成word文档格式
- 顺时针打印矩阵
- caffe卷积层代码阅读笔记
- algrothm_判断回文数
- iOS开发数据库篇—SQLite简单介绍
- Web攻防系列教程之 Cookie注入攻防实战
- .net将word文档格式转换为pdf文件格式
- 史上最详细的Android Studio系列教程二--基本设置与运行
- Injection Plugin for Xcode成吨的提高开发效率!
- c#中两个问号(??)是什么意思
- mac下mysql terminal设置以及常规用法
- linux awk命令
- oracle查询语句
- 迪杰斯特拉算法-最短路径
- linux下的 fork vfork和clone函数