1、首先安装 Microsoft Office 2007加载项:Microsoft Save as PDF-简体中文版:下载地址:

http://download.microsoft.com/download/3/8/8/388812b2-0d3f-474e-a7ef-b095d3d0d3cd/SaveAsPDF.exe

2,代码如下

/// <summary>
/// 转换word为pdf
/// </summary>
/// <param name="filename">doc文件路径</param>
/// <param name="savefilename">pdf保存路径</param>
void ConvertWordPDF1(object filename, object savefilename)
{
Object Nothing = System.Reflection.Missing.Value;
//创建一个名为WordApp的组件对象
wordApp = new ApplicationClass();
//创建一个名为WordDoc的文档对象并打开
Document doc = wordApp.Documents.Open(ref filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//设置保存的格式
object filefarmat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
//保存为PDF
doc.SaveAs(ref savefilename, ref filefarmat, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//关闭文档对象
doc.Close(ref Nothing, ref Nothing, ref Nothing);
//推出组建
wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
doc = null;
wordApp = null;
}

//下面是各种转换格式

object filefarmat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;//设置保存的格式,还可以为以下格式:

Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML  //保存为HTML

Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatRTF     //保存为RTF

Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatText    //保存为文本

Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXML    //保存为XML

Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXPS    //保存为XPS

ASP.NET Word转为PDF的更多相关文章

  1. Java 将Word转为PDF、PNG、SVG、RTF、XPS、TXT、XML

    同一文档在不同的编译或阅读环境中,需要使用特定的文档格式来打开,通常需要通过转换文档格式的方式来实现.下面将介绍在Java程序中如何来转换Word文档为其他几种常见文档格式,如PDF.图片png.sv ...

  2. C# 将Word转为PDF、XPS、Epub、RTF(基于Spire.Cloud.Word.SDK)

    本文介绍通过调用Spire.Cloud.Word.SDK提供的ConvertApi接口将Word转换为PDF.XPS.Epub.RTF以及将Docx转为Doc格式等.调用接口方法及步骤参考以下步骤: ...

  3. 自动化将 word 转为 pdf,再将pdf转为图片!

    参考: https://blog.csdn.net/ynyn2013/article/details/49120731 https://www.jianshu.com/p/f57cc64b9f5e 一 ...

  4. Java 将word转为pdf jacob方式

    package com.doctopdf; import java.io.File; import com.jacob.activeX.ActiveXComponent; import com.jac ...

  5. java 将word转为PDF (100%与word软件转换一样)

    jdk环境:jdk_8.0.1310.11_64    (64位) 1.引入pom文件 <!-- word转pdf(依赖windows本地的wps) --> <dependency& ...

  6. freemarker动态生成word并将生成的word转为PDF,openoffice转换word乱码

    之前项目有个需求,需要先动态生成word内容,然后再预览生成word的内容(不能修改).整理一下,方便以后使用. 网上参考了好多大神的博客.具体也忘了参考谁的了,如有侵权,请告知修改. 思路一: 将目 ...

  7. OpenOfice将offic转为pdf并且在web显示

    1.将office首先要安装OpenOfice,傻瓜式安装就好了,之后可以使用下列代码将word转为pdf.这个需要导入jodconverter-2.2.2里的 ja r包 import java.i ...

  8. Word转PDF非常好用的软件——pdfFactory Pro

    pfdFactory Pro把word转为pdf的操作步骤: 1.打开将要转换的word的文档: 2.文件--->打印: 弹出如下对话框: 单击确定后弹出:

  9. C# Word转PDF/HTML/XML/XPS/SVG/EMF/EPUB/TIFF

    一款有着强大的文档转换功能的工具,无论何时何地都会是现代办公环境极为需要的.在本篇文章中,将介绍关于Word文档的转换功能(Word转XPS/SVG/EMF/EPUB/TIFF).希望方法中的代码能为 ...

随机推荐

  1. C++中的常量定义

    本篇笔记总结自一次代码检视. 一般来说,使用C语言编程时我们都习惯在代码当中使用C当中的宏定义来定义一个数值常量: #define MY_CONST 7 在C++开发项目时,也会经常存在沿袭C当中常量 ...

  2. 手把手教你学node之搭建node.js开发环境

    搭建node.js开发环境 本文只针对在Linux或者Mac下面.至于使用 Windows 并坚持玩新技术的同学,我坚信他们一定有着过人的.甚至是不可告人的兼容性 bug 处理能力,所以这部分同学麻烦 ...

  3. VS2010/MFC编程入门之二十八(常用控件:列表视图控件List Control 上)

    前面一节中,鸡啄米讲了图片控件Picture Control,本节为大家详解列表视图控件List Control的使用.      列表视图控件简介 列表视图控件List Control同样比较常见, ...

  4. 4gcc编译器

    gcc编译器(GNU C Compiler) 现在我们所说的 gcc 是 GUN Compiler Collection的缩写,可以支持多种语言编译,比如 C,C++,Java, pascal 等 g ...

  5. python 封装时间常用操作方法-time,datetime

    封装脚本: #encoding=utf-8import timefrom datetime import timedelta,date def date_time_chinese():    prin ...

  6. table--边框样式设置

    Table的一些设置(自适应以及溢出)   table的两个属性 单行溢出点点显示 表格的宽度设置 双栏自适应连续连续英文符换行 1.table重置的两个属性: ①border-collapse: c ...

  7. 【运维技术】Nginx安装教程(yum安装,源码编译)

    安装方式 yum直接更新源安装 源码直接编译之后安装 使用yum进行直接安装 Installing a Prebuilt CentOS/RHEL Package from an OS Reposito ...

  8. c++第二十六天

    p131~p135: 1.除非必要否则不使用后缀加加(减减),会有额外的性能开销. 2.混用解引用和递增运算符.*pointer++,后缀运算符优先于解引用运算符. 3.运算对象可按任意顺序求值,即使 ...

  9. MySQL "tinyInt1isBit or tinyint(1)" 相关问题解析

    问题描述 tinyInt 的数据类型,在JAVA数据类型 和 MySQL的数据类型转换,要注意存储长度为 1 的情况.查询时,该字段对应的Java类型为Boolean 源数据: 读取后数据: 问题分析 ...

  10. HttpContext.Current and Web Api

    Using HttpContext.Current in WebApi is dangerous because of async HttpContext.Current gets the curre ...