Apply Emphasis Marks in Word in Java

In Word, you can emphasize some important contents by adding specific symbols such as underline, overline and highlight colors. In addition, you can also use emphasis mark to make the content more noticable. This article will share how to programmatically apply emphasis marks to text in Word using Free Spire.Doc for Java.

Import Dependency

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies>

Sample Code

import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.shape.*;

public class applyEmphasisMark {
public static void main(String[] args) {
//Create word document
Document document = new Document();

//Load the document from disk
document.loadFromFile("test.docx");

//Find text to emphasize
TextSelection[] textSelections = document.findAllString("Ancient Olympics", false, true);

//Set emphasis mark to the found text
for (TextSelection selection : textSelections) {
selection.getAsOneRange().getCharacterFormat().setEmphasisMark(Emphasis.Dot);
}

//Save the file
document.saveToFile("EmphasisMark.docx", FileFormat.Docx);
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store