Remove highlight from document(Aspose Word 删除高亮)
Thanks for your inquiry. You can do it using DocumentVisitor. Please try using the following code: // Open document.
Document doc = new Document("C:\\Temp\\test2.docx"); ChangeHighlightColor changeHighlightColor = new ChangeHighlightColor(Color.Transparent); doc.Accept(changeHighlightColor); doc.Save("C:\\Temp\\out.docx"); class ChangeHighlightColor : DocumentVisitor
{
public ChangeHighlightColor(System.Drawing.Color highlighColor)
{
mHighlighColor = highlighColor;
} /// <summary>
/// Called when a FieldEnd node is encountered in the document.
/// </summary>
public override VisitorAction VisitFieldEnd(Aspose.Words.Fields.FieldEnd fieldEnd)
{
//Simply change font name
ChangeFont(fieldEnd.Font);
return VisitorAction.Continue;
} /// <summary>
/// Called when a FieldSeparator node is encountered in the document.
/// </summary>
public override VisitorAction VisitFieldSeparator(Aspose.Words.Fields.FieldSeparator fieldSeparator)
{
ChangeFont(fieldSeparator.Font);
return VisitorAction.Continue;
} /// <summary>
/// Called when a FieldStart node is encountered in the document.
/// </summary>
public override VisitorAction VisitFieldStart(Aspose.Words.Fields.FieldStart fieldStart)
{
ChangeFont(fieldStart.Font);
return VisitorAction.Continue;
} /// <summary>
/// Called when a Footnote end is encountered in the document.
/// </summary>
public override VisitorAction VisitFootnoteEnd(Footnote footnote)
{
ChangeFont(footnote.Font);
return VisitorAction.Continue;
} /// <summary>
/// Called when a FormField node is encountered in the document.
/// </summary>
public override VisitorAction VisitFormField(Aspose.Words.Fields.FormField formField)
{
ChangeFont(formField.Font);
return VisitorAction.Continue;
} /// <summary>
/// Called when a Paragraph end is encountered in the document.
/// </summary>
public override VisitorAction VisitParagraphEnd(Paragraph paragraph)
{
ChangeFont(paragraph.ParagraphBreakFont);
return VisitorAction.Continue;
} /// <summary>
/// Called when a Run node is encountered in the document.
/// </summary>
public override VisitorAction VisitRun(Run run)
{
ChangeFont(run.Font);
return VisitorAction.Continue;
} /// <summary>
/// Called when a SpecialChar is encountered in the document.
/// </summary>
public override VisitorAction VisitSpecialChar(SpecialChar specialChar)
{
ChangeFont(specialChar.Font);
return VisitorAction.Continue;
} private void ChangeFont(Font font)
{
font.HighlightColor = mHighlighColor;
}
private System.Drawing.Color mHighlighColor = System.Drawing.Color.Transparent;
} Best regards,
Remove highlight from document(Aspose Word 删除高亮)的更多相关文章
- Aspose Word.Dll库自带的bug导致The document appears to be corrupted and cannot be loaded 问题处理。
问题的详细描述: C#在开发过程中使用Aspose.word.dll库去实现word套打功能.但是,最近客户反映出现了一个问题,在打印文档的时候,系统报错.经过定位分析发现是Aspose.word.d ...
- 利用Aspose.Word控件和Aspose.Cell控件,实现Word文档和Excel文档的模板化导出
我们知道,一般都导出的Word文档或者Excel文档,基本上分为两类,一类是动态生成全部文档的内容方式,一种是基于固定模板化的内容输出,后者在很多场合用的比较多,这也是企业报表规范化的一个体现. 我的 ...
- Aspose Word模板使用总结
Aspose Word模板使用总结 1.创建word模版,使用MergeFeild绑定数据 新建一个Word文档,命名为Template.doc 注意:这里并不是输入"< ...
- 利用Aspose.Word控件实现Word文档的操作
Aspose系列的控件,功能都挺好,之前一直在我的Winform开发框架中用Aspose.Cell来做报表输出,可以实现多样化的报表设计及输出,由于一般输出的内容比较正规化或者多数是表格居多,所以一般 ...
- 黄聪:利用Aspose.Word控件实现Word文档的操作(转)
撰写人:伍华聪 http://www.iqidi.com Aspose系列的控件,功能都挺好,之前一直在我的Winform开发框架中用Aspose.Cell来做报表输出,可以实现多样化的报表设计及 ...
- Aspose.Word邮件合并之自定义数据源
Aspose.Word在进行邮件合并时,默认的几个重载方法对Database支持比较友好,但是也可以通过自定义数据源来实现从集合或者对象中返回数据进行邮件合并. 自定义数据源主要是通过实现IMailM ...
- aspose.word 使用简单方法
aspose.word使用简单方法 概念介绍 使用aspose生成word报表步骤: 加载word模板 提供数据源 填充 加载模板 提供了4种重载方法 1 2 3 4 5 public Documen ...
- Word 代码高亮
整理文档比较费事,提供个脚本放在VBA里,使Word 代码高亮的一种方法是改变颜色 'script to high light code In document Private Function is ...
- aspose.word 读取word段落内容
注:转载请标明文章原始出处及作者信息 aspose.word 插件下载 链接: http://pan.baidu.com/s/1qXIgOXY 密码: wsj2 使用原因:无需安装office,无兼容 ...
随机推荐
- couchbase failover 集群故障自动转移方案研究!
最近迷上Couchbase了,现在所有的站点全部试用Couchbase进行缓存及持久化,这样以来貌似风险比较大啊,缓存服务器挂了就完了. 看到有讲到Couchbase的集群方案很简单,于是照着教程做了 ...
- Spring入门Hello World
这里是关于Hello World的一些基本的操作 Spring 是一个重量级的容器框架,用来配置bean并维护bean之间的关系的框架 想要最初的使用Spring就要学会最基本的配置 <1> ...
- SQL Server数据类型
转载:http://www.ezloo.com/2008/10/sql_server_data_type.html 数据类型是数据的一种属性,是数据所表示信息的类型.任何一种语言都有它自己所固有 ...
- WindowsServer2003SP2EnterpriseEdition在Virtual上的安装
下载镜像(迅雷): http://192.168.0.101/WindowsServer2003SP2EnterpriseEdition.iso?fid=fWljwnwNgumTtRIy- *BY*a ...
- 在CentOS6.0上安装Oracle 11gR2 (11.2.0.1)以及基本的配置(一)
首先安装CentOS6.0 就不用说了.安装即可.唯一需要注意的就是后面Oracle 11G Installation guide中的Checking the Software Requireme ...
- ios 字符串替换方法
string=[string stringByReplacingOccurrencesOfString:@"-"withString:@"/"];
- 反射(学习整理)----Class类和加载器ClassLoader类的整理
1.学习反射的时整理的笔记!Class类和ClassLoader类的简单介绍 反射机制中的Class Class内部到底有什么呢?看下图! 代码: Class cls=Person.class; .C ...
- CentOS6.3安装VBoxAdditions
yum update kernel yum install kernel-devel gcc gcc-c++
- JavaScript H5 Canvas
Canvas 由于浏览器对HTML5标准支持不一致,所以,通常在<canvas>内部添加一些说明性HTML代码,如果浏览器支持Canvas,它将忽略<canvas>内部的HTM ...
- ZendFramework使用中常见问题
MVC 代码书写:控制器代码书写:<?phpclass IndexController extends Zend_Controller_Action{ function init() { $th ...