博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Remove highlight from document(Aspose Word 删除高亮)
阅读量:6720 次
发布时间:2019-06-25

本文共 2700 字,大约阅读时间需要 9 分钟。

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;    }     ///     /// Called when a FieldEnd node is encountered in the document.    ///     public override VisitorAction VisitFieldEnd(Aspose.Words.Fields.FieldEnd fieldEnd)    {        //Simply change font name        ChangeFont(fieldEnd.Font);        return VisitorAction.Continue;    }     ///     /// Called when a FieldSeparator node is encountered in the document.    ///     public override VisitorAction VisitFieldSeparator(Aspose.Words.Fields.FieldSeparator fieldSeparator)    {        ChangeFont(fieldSeparator.Font);        return VisitorAction.Continue;    }     ///     /// Called when a FieldStart node is encountered in the document.    ///     public override VisitorAction VisitFieldStart(Aspose.Words.Fields.FieldStart fieldStart)    {        ChangeFont(fieldStart.Font);        return VisitorAction.Continue;    }     ///     /// Called when a Footnote end is encountered in the document.    ///     public override VisitorAction VisitFootnoteEnd(Footnote footnote)    {        ChangeFont(footnote.Font);        return VisitorAction.Continue;    }     ///     /// Called when a FormField node is encountered in the document.    ///     public override VisitorAction VisitFormField(Aspose.Words.Fields.FormField formField)    {        ChangeFont(formField.Font);        return VisitorAction.Continue;    }     ///     /// Called when a Paragraph end is encountered in the document.    ///     public override VisitorAction VisitParagraphEnd(Paragraph paragraph)    {        ChangeFont(paragraph.ParagraphBreakFont);        return VisitorAction.Continue;    }     ///     /// Called when a Run node is encountered in the document.    ///     public override VisitorAction VisitRun(Run run)    {        ChangeFont(run.Font);        return VisitorAction.Continue;    }     ///     /// Called when a SpecialChar is encountered in the document.    ///     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,

 

转载地址:http://grjmo.baihongyu.com/

你可能感兴趣的文章
bzoj2792
查看>>
data encryption
查看>>
UVA10692:Huge Mods
查看>>
动态加载js和css
查看>>
swift - UITextView的用法
查看>>
MarkdownPad基于语法示例
查看>>
区块链开发_比特币开发1
查看>>
幸福是一种感觉
查看>>
udp接收
查看>>
Linux批量处理文件脚本
查看>>
MVC之Ajax异步操作
查看>>
pwn学习(1)
查看>>
复习常用算法_冒泡算法
查看>>
reading/writing files in Python
查看>>
LCA 树链剖分
查看>>
JSP下载txt 和 Excel两种文件
查看>>
写在年尾
查看>>
找水王
查看>>
路过Haxe
查看>>
从零开始学java (继承)
查看>>