为 .NET 安装 Spire.Doc
首先,您需要将 Spire.Doc for.NET 包中包含的 DLL 文件添加为 .NET 项目中的引用。DLL 文件可以从此链接下载或通过NuGet安装。
PM> Install-Package Spire.Doc将强调标记应用于指定文本
详细步骤如下:
- 创建一个文档实例。
- 使用Document.LoadFromFile()方法从磁盘加载 Word 文档。
- 使用Document.FindAllString()方法查找您需要强调的文本。
- 通过CharacterFormat.EmphasisMark属性将强调标记应用于找到的文本。
- 使用Document.SaveToFile()方法将文档保存到另一个 Word 文件。
【C#】
using System;using Spire.Doc;using Spire.Doc.Documents;namespace applyemphasismark{class Program{static void Main(string[] args){//Create a Document instanceDocument document = new Document();//Load the Word document from diskdocument.LoadFromFile(@"D:testptest.docx");//Find text you want to emphasizeTextSelection[] textSelections = document.FindAllString("Spire.Doc for .NET", false, true);//Apply emphasis mark to the found textforeach (TextSelection selection in textSelections){selection.GetAsOneRange().CharacterFormat.EmphasisMark = Emphasis.Dot;}//Save the document to another Word filestring output = "ApllyEmphasisMark.docx";document.SaveToFile(output, FileFormat.Docx);}}}
【VB.NET】
using System;using Spire.Doc;using Spire.Doc.Documents;namespace applyemphasismark{class Program{static void Main(string[] args){//Create a Document instanceDocument document = new Document();//Load the Word document from diskdocument.LoadFromFile(@"D:testptest.docx");//Find text you want to emphasizeTextSelection[] textSelections = document.FindAllString("Spire.Doc for .NET", false, true);//Apply emphasis mark to the found textforeach (TextSelection selection in textSelections){selection.GetAsOneRange().CharacterFormat.EmphasisMark = Emphasis.Dot;}//Save the document to another Word filestring output = "ApllyEmphasisMark.docx";document.SaveToFile(output, FileFormat.Docx);}}}

以上便是如何在 Word 中应用强调标记(C#/VB.NET),如果您有其他问题也可以继续浏览本系列文章,获取相关教程,你还可以给我留言或者加入我们的官方技术交流群。
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询在线客服 ;
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!