In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people don't understand the knowledge points of this article "how C#adds emphasis to characters in Word", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "how C#adds emphasis to characters in Word".
preface
In Word add emphasis, that is, emphasis symbol, you can select the character, right mouse click, select "font", in the window can directly select "emphasis" to add to the text, to strengthen the important text content reminder purpose, as shown below:
With C#, we can find strings that need to be highlighted, and then add symbols through attribute values in string format. This will be explained in detail below.
Introduction of dll method 1
introduced manually
Download Free Spire.Doc for. NET locally, extract, and install. After installation, locate Spire.Doc.dll in the BIN folder under the installation path. Then open Solution Explorer in Visual Studio, right-click References, add references, and add references to the dll file under the local path BIN folder.
Method 2
NuGet Installation (2 Ways)
(1) Open Solution Explorer in Visual Studio, right-click References, Manage NuGet Packages, search for Free Spire.Doc, and click Install. Wait for the program installation to complete.
(2) Copy the following to the PM console installation:
Install-Package FreeSpire.Doc -Version 10.2.0
Add accent
The code steps are as follows, which can be referred to to for adding symbols:
Create an object of the Document class.
Load the Word document locally using the Document.LoadFromFile() method.
FindAllString() finds the specified text string.
Adds an accent to a string through the CharacteristFormat.EmphasisMark attribute.
Save the document as a new Word document using the Document.SaveToFile() method.
C#using Spire.Doc;using Spire.Doc.Documents;using System.Drawing;namespace EmphasisMark{ class Program { static void Main(string[] args) { //Create Document object Document document = new Document(); //Load Word document document.LoadFromFile("sample.docx"); //Find the specified string TextSelection[] textSelections = document.FindAllString("Analysis Report", false, true); //add accent to string foreach (TextSelection selection in textSelections) { selection.GetAsOneRange().CharacterFormat.EmphasisMark = Emphasis.DotBelow; } //Save document document.SaveToFile("Result.docx", FileFormat.Docx2013); System.Diagnostics.Process.Start("Result.docx"); } }}vb.netImports Spire.DocImports Spire.Doc.DocumentsImports System.DrawingNamespace EmphasisMark Class Program Private Shared Sub Main(args As String()) 'Create Document object Dim document As New Document() 'Load Word Document document.LoadFromFile("sample.docx") 'Find specified string Dim textSelections As TextSelection() = document.FindAllString(Analysis Report, False, True) 'Add accent to string For Each selection As TextSelection In textSelections selection.GetAsOneRange().CharacterFormat.EmphasisMark = Emphasis.DotBelow Next 'Save Document document.SaveToFile("Result.docx", FileFormat.Docx2013) System.Diagnostics.Process.Start("Result.docx") End Sub End ClassEnd Namespace
Add Effect:
The above is the content of this article about "how C#adds emphasis to characters in Word." I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.