将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 ...
随机推荐
- WinUI 3试玩报告
1. 什么是 WinUI 3 在微软 Build 2020 开发者大会上,WinUI 团队宣布可公开预览的 WinUI 3 Preview 1,它让开发人员可以在 Win32 中使用 WinUI.Wi ...
- 对Activity启动模式的理解
对Activity启动模式的理解 应用场景 在已打开多个Activity应用B的前提下,应用A调用应用B后点击返回按钮,需要直接返回到A应用,而不是打开B应用的上一个Activity 一个Task可以 ...
- Redis集群-主从模式
1.架构设计 集群在单台主机上模拟搭建6个节点(3主3从的集群): 2.配置 创建与端口相同的文件夹存储Redis配置文件和持久化文件. 目录如下: 每个节点配置文件如下: 节点1: bind 192 ...
- [apue] sysconf 的四种返回状态
众所周知,sysconf 用来返回某种常量的定义或者资源的上限,前者用于应用动态的判断系统是否支持某种标准或能力.后者用于决定资源分配的尺寸. 但是你可能不知道的是,sysconf 可以返回四种状态: ...
- Linux系统管理——Linux简介
UNIX与Linux发展史 UNIX发展历史 1.1965年,美国麻省理工学院(MIT),通用电气公司(GE)及AT&T的贝尔实验室联合开发Multics工程计划,其目标是开发一种交互式的具有 ...
- Cookie和localStorage的查询、设置、修改及删除
感谢:链接(视频讲解很详细) cookie:是一种字符串表示的数据,用于在本地记录用户的基本信息(账号,密码等),具有时限性. 数据的具体内容: (图源上文视频链接) localStorage:与co ...
- 这一次搞懂SpringMVC原理
@ 目录 前言 正文 请求入口 组件初始化 调用Controller 参数.返回值解析 总结 前言 前面几篇文章,学习了Spring IOC.Bean实例化过程.AOP.事务的源码和设计思想,了解了S ...
- 【JMeter_10】JMeter逻辑控制器__ForEach控制器<ForEach Controller>
ForEach控制器<ForEach Controller> 业务逻辑: ForEach控制器一般与用户自定义变量/JDBC结果变量一起使用,可以认为他就是一种遍历型循环,该节点下的脚本内 ...
- belongsTo和hasOne的区别
简单的讲就是,没有太大的区别,只是在逻辑上出现的思想的偏差(逻辑的合理性).belongsTo:可以理解为属于hasOne:可以理解为拥有 首先,我们创建两张表.user表 字段 id name pa ...
- CSS sprites的定义及使用
定义:CSS sprites 其实就是把网页中的一些背景图片整合到一张图片文件中,再利用CSS的“background-image”.“background-repeat”.“background-p ...