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).希望方法中的代码能为 ...
随机推荐
- 田忌赛马Java解答
你一定听过田忌赛马的故事吧? 如果3匹马变成1000匹,齐王仍然让他的马按从优到劣的顺序出赛,田忌可以按任意顺序选择他的赛马出赛.赢一局,田忌可以得到200两银子,输一局,田忌就要输掉200两 ...
- vuex的一个坑
1 error in callback for watcher "function (){ return this._data.$$state }" 用深拷贝解决 2 接口依赖: ...
- ng-深度学习-课程笔记-5: 深层神经网络(Week4)
1 深度L层神经网络( Deep L-layer Neural network ) 针对具体问题很难判断需要几层的网络,所以先试试逻辑回归是比较合理的做法,然后再试试单隐层,把隐层数量当作一个超参数, ...
- 20145325张梓靖 《Java程序设计》第16周课程总结
20145325张梓靖 <Java程序设计>第16周课程总结 实验报告链接汇总 实验一 "Java开发环境的熟悉" 实验二 "Java面向对象程序设计&quo ...
- git使用合集
1.git 克隆时重命名本地文件夹或目录 如:git clone https://github.com/torvalds/linux.git linux_kernel 2.git查看tag git t ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends(暴力)
http://codeforces.com/contest/761/problem/B 题意: 有一个长度为l的环形跑道,跑道上有n个障碍,现在有2个人,给出他们每过多少米碰到障碍,判断他们跑的是不是 ...
- Learning Ansible with Vagrant
介绍 Vagrant介绍 Vagrant是一款构建虚拟开发环境的工具,Vagrant的使用依赖于VirtualBox,VMware等一些虚拟机,通过Vagrant能更加方便的管理虚拟机,同时还能够通过 ...
- /etc/apt/sources.list.d/ros-latest.list' permission denied
换为英文的' sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt ...
- thinkphp3.2笔记(5)创建项目 创建模型 实例化
一 创建项目 1 拷贝框架 目录 public thinkphp .htaccess index.php [application不用拷贝,会自动生成] 2 public 下面创 ...
- java.lang.NoSuchMethodError: org.springframework.core.io.ResourceEditor
这种情况一般是jar包版本问题,pom导入的jar包存在一个2.5.6的,删掉即可.