将PDF转化为wrod
public static void CreateWord(string HtmlPath, string WordSavePath)
{
string inputName = HtmlPath;
//string ext = Path.GetExtension(inputName);
string outputName = WordSavePath;
if (File.Exists(inputName))
{
object oMissing = System.Reflection.Missing.Value;
object oTrue = true;
object oFalse = false;
Microsoft.Office.Interop.Word._Application oWord = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word._Document oWordDoc = new Microsoft.Office.Interop.Word.Document();
try
{ oWord.Visible = false;
// 这里是打开文件的扩展名
object openFormat = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatWebPages;
object openName = inputName; oWordDoc = oWord.Documents.Open(ref openName, ref oMissing, ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref openFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
object saveFileName = outputName;
oWord.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter; // 居中
oWord.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdWebView;//将web视图修改为默认视图,不然打开word的时候会以web视图去展示,而不是默认视图。(唯独这句代码是自己加的 = =|||)
//for (int i = 0; i < oWordDoc.Tables.Count; i++)
//{
// oWordDoc.Tables[i].PreferredWidth = 600;
//} // 这里是保存文件的扩展名
object saveFormat = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault;
//去掉软回车
oWordDoc.Content.Find.Text = "^l";
object FindText, ReplaceWith, Replace;//
object MissingValue = Type.Missing;
FindText = "^l";//要查找的文本
ReplaceWith = "^p";//替换文本
Replace = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll;
/**/
/*wdReplaceAll - 替换找到的所有项。
* wdReplaceNone - 不替换找到的任何项。
* wdReplaceOne - 替换找到的第一项。
* */
oWordDoc.Content.Find.ClearFormatting();
//移除Find的搜索文本和段落格式设置
if (oWordDoc.Content.Find.Execute(
ref FindText, ref MissingValue,
ref MissingValue, ref MissingValue,
ref MissingValue, ref MissingValue,
ref MissingValue, ref MissingValue, ref MissingValue,
ref ReplaceWith, ref Replace,
ref MissingValue, ref MissingValue,
ref MissingValue, ref MissingValue))
{
} oWordDoc.SaveAs(ref saveFileName, ref saveFormat, ref oMissing, ref oMissing, ref oFalse, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
}
catch (Exception)
{
throw;
}
finally
{
oWordDoc.Close(ref oTrue, ref oMissing, ref oMissing);
oWord.Quit(ref oTrue, ref oMissing, ref oMissing);
} }
}
将PDF转化为wrod的更多相关文章
- .net core 2.2 使用imagemagick 将pdf转化为png
工作需要将PDF文件每一页拆分为一个一个的png文件 测试环境:mac,visual studio for mac 2019 nuget:magick.net-Q16-AnyCPU 不能直接支持PDF ...
- 常用PDF文档开发库
C++库: 1,PDF类库 PoDoFo http://podofo.sourceforge.net/ PoDoFo 是一个用来操作 PDF 文件格式的 C++ 类库.它还包含一些小工具用来解析 ...
- 将word转化为swf 进行如同百度文库的般阅读
实现如同百度文库那样类似功能需要进行一系列转化,一般流程想将word转化为pdf格式,再将pdf格式转化为swf格式.在网页上显示其实都是swf格式内容. 首先将word转化为swf,需要调用com组 ...
- pdf转html插件~~~pdf2htmlEX安装,配置及使用
这是一个将pdf转化为html的服务,开源的. 此功能服务的代码在git上的地址为: https://github.com/coolwanglu/pdf2htmlEX/wiki 安装: 在ubuntu ...
- 在线预览文档(支持word、excel、ppt、pdf)+在线预览文档html版(转)
1.首先上网搜索一下有什么解决方案 (1).将文档转换为html,只支持支持office文档 (2).将文档转换为flash,实现类似百度文库的效果,除支持office文档外还支持pdf (1) a. ...
- 不错的PDF开发库
C++库: 1,PDF类库 PoDoFo http://podofo.sourceforge.net/ PoDoFo 是一个用来操作 PDF 文件格式的 C++ 类库.它还包含一些小工具用来解析 ...
- itext5和itext7操作pdf平铺和图层叠加(tiling, and N-upping)
区别 itext5 生成pdf版本:1.4(Acrobat5.x) itext7 生成pdf版本:1.7(Acrobat8.x) iText7生成的pdf文件大, itext7 Java库更加系统和完 ...
- css007 margin padding border
css007 margin padding border 1.理解盒模型(盒模型:就是把一些东西,包括html各种标签都包含在一个 看不见的盒子里) 1/在web浏览器中任何标签都是一个盒子,内容的周 ...
- Ghostscript命令实践
一. 将单张PDF文件igs.pdf转化为tiff文件. . gs -sDEVICE=tiffg4 -sOutputFile=igs.tiff -dMaxStripSize= igs.pdf -dAd ...
随机推荐
- monkey命令的基本使用
看到monkey,你想到了什么?今天给大家分享下monkey命令的基本使用 monkey测试是Android平台自动化测试的一种手段,通过monkey程序模拟用户触摸屏幕,滑动.按键操作等操作对设备上 ...
- ServiceStack.Redis 5.8 版本去掉每小时 6000 次访问限制
ServiceStack.Redis这个官方 Redis 访问组件从4.0版本后开始商业化了,在使用的时候会有很多限制: 1.类型限制 类型限制是20,这个组件自带序列化功能,使得我们可以直接把对象保 ...
- 写了个全局变量的bug,被同事们打脸!!!
话说栈长前阵子写了一个功能,测试 0 bug 就上线了,上线后也运行好好的,好多天都没有人反馈bug,超爽.. 不出问题还好,出问题就是大问题.. 最近有个客户反馈某些数据混乱问题,看代码死活看不出什 ...
- 如何在centos7安装dnf软件包
想在自己的笔记本CentOS7上安装dnf玩玩儿,但是根据百度出来的方法没有成功. yum install epel-release -y yum install dnf 现在将解决办法转载过来,如下 ...
- 【分区】使用 GPT 分区表分区并格式化 (非 FreeBSD 系统)
新购买的 Linux 云服务器,由于数据盘未做分区和格式化,无法使用. 注意: 数据盘中的数据在格式化后将全部被清空.请在格式化之前,确保数据盘中没有数据或已对重要数据进行备份.为避免服务发生异常,格 ...
- Charles抓包1-Charles安装汉化(附正版注册码)
目录 1.下载&&安装 2.汉化 1.下载&&安装 charles官网 charles下载 下载后直接安装即可. 2.汉化 下载提供的汉化包charles.jar(加群 ...
- 面向对象存储框架:Obase快速入门
在项目中完成对象建模后,可以使用Obase来进行对象的管理(例如对象持久化),本篇教程将创建一个.NET Core控制台应用,来展示Obase的配置和对象的增删改查操作.本篇教程旨在指引简单入门. 本 ...
- Anaconda 安装tensorflow出现错误
C:\ProgramData\Anaconda3\envs\python36tfgpu\lib\site-packages\tensorflow\python\framework\dtypes.py: ...
- 漏洞复现 MS11-003
0x01漏洞简介 ms11-003(windows7IE溢出攻击) 是利用IE8中对css的解析存在一个问题,导致任何访问包含非法css的页面将导致IE8崩溃重启的漏洞. 0x02环境准备 攻击机:k ...
- Linux 开放指定端口号
1.开启防火墙 [root@localhost opt]# systemctl start firewalld 2.查看当前防火墙状态 [root@localhost opt]# systemctl ...