ASP.NET Word转为PDF
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的更多相关文章
- Java 将Word转为PDF、PNG、SVG、RTF、XPS、TXT、XML
同一文档在不同的编译或阅读环境中,需要使用特定的文档格式来打开,通常需要通过转换文档格式的方式来实现.下面将介绍在Java程序中如何来转换Word文档为其他几种常见文档格式,如PDF.图片png.sv ...
- C# 将Word转为PDF、XPS、Epub、RTF(基于Spire.Cloud.Word.SDK)
本文介绍通过调用Spire.Cloud.Word.SDK提供的ConvertApi接口将Word转换为PDF.XPS.Epub.RTF以及将Docx转为Doc格式等.调用接口方法及步骤参考以下步骤: ...
- 自动化将 word 转为 pdf,再将pdf转为图片!
参考: https://blog.csdn.net/ynyn2013/article/details/49120731 https://www.jianshu.com/p/f57cc64b9f5e 一 ...
- Java 将word转为pdf jacob方式
package com.doctopdf; import java.io.File; import com.jacob.activeX.ActiveXComponent; import com.jac ...
- java 将word转为PDF (100%与word软件转换一样)
jdk环境:jdk_8.0.1310.11_64 (64位) 1.引入pom文件 <!-- word转pdf(依赖windows本地的wps) --> <dependency& ...
- freemarker动态生成word并将生成的word转为PDF,openoffice转换word乱码
之前项目有个需求,需要先动态生成word内容,然后再预览生成word的内容(不能修改).整理一下,方便以后使用. 网上参考了好多大神的博客.具体也忘了参考谁的了,如有侵权,请告知修改. 思路一: 将目 ...
- OpenOfice将offic转为pdf并且在web显示
1.将office首先要安装OpenOfice,傻瓜式安装就好了,之后可以使用下列代码将word转为pdf.这个需要导入jodconverter-2.2.2里的 ja r包 import java.i ...
- Word转PDF非常好用的软件——pdfFactory Pro
pfdFactory Pro把word转为pdf的操作步骤: 1.打开将要转换的word的文档: 2.文件--->打印: 弹出如下对话框: 单击确定后弹出:
- C# Word转PDF/HTML/XML/XPS/SVG/EMF/EPUB/TIFF
一款有着强大的文档转换功能的工具,无论何时何地都会是现代办公环境极为需要的.在本篇文章中,将介绍关于Word文档的转换功能(Word转XPS/SVG/EMF/EPUB/TIFF).希望方法中的代码能为 ...
随机推荐
- 120. Triangle(动态规划 三角形最小路径 难 想)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- Linux基础入门第三节(修改)
第三节 作业部分 添加一个用户loutest,使用sudo创建文件/opt/forloutest,设置成用户loutest可以读写.截图并把操作过程写入实验报告. 找到了解决的办法,在touch命令前 ...
- ZOJ 2747 Paint the Wall(离散化+暴力)题解
题意:给你一个面,然后涂颜色,问你最后剩多少颜色,每种颜色面积. 思路:第一反应是二维线段树,代码又臭又长,可以做.但是这题暴力+离散化就可以过.可以看到他给的n只有100,也就是说最坏情况下会涂10 ...
- ZOJ 2587 Unique Attack(最小割唯一性判断)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2587 题意:判断最小割是否唯一. 思路: 最小割唯一性的判断是先跑一遍最大 ...
- Android -- service 利用广播调用服务的方法
1. 实现原理,在Service里面注册一个广播接收者, 想要调用的时候app发送出广播, 后台的service里面的广播接收者接收到广播,并调用service里面的方法. 2. 示例代码 MainA ...
- Linux 用户和组的 添加/删除
1.建用户:adduser phpq //新建phpq用户passwd phpq //给phpq用户设置密码 2.建工作组groupadd test //新建test工作组 3.新建用户同时增加工作组 ...
- 双击不能运行可执行的jar文件
1.首先在命令行下运行jar包看文件是否报错(java -jar jar文件名称.jar) 如果程序中有System.out.println()语句,不想让其输出到控制台而保存到文件 ...
- Ubuntu终端常用的快捷键,光标移动到开始位置
光标操作,实用 Ctrl+a 光标移动到开始位置 Ctrl+e 光标移动到最末尾 删除 Ctrl+k 删除此处至末尾的所有内容 Ctrl+u 删除此处至开始的所有内容 删除单个 Ctrl+d 删除当前 ...
- SpringMVC注解@RequestMapping @RequestParam @ResponseBody 和 @RequestBody 解析
SpringMVC Controller层获取参数及返回数据的方式: @RequestMapping @RequestMapping(“url”),这里的 url写的是请求路径的一部分,一般作用在 C ...
- idea配置echache.xml报错Cannot resolve file 'ehcache.xsd'
解决方法: 打开settings->languages&frameworks->schemas and dtds ,添加地址 http://ehcache.org/ehcache. ...