Insert Bullet Point Symbols in Word in Java

Andrew Wilson
2 min readJan 13, 2023

--

Bullet point symbols are typographical symbols used to introduce items in a list. They are often used to categorize things, topics, and ideas in research papers, technical writing, reference works. In MS Word, you can add various bullet point symbols such as circulars, squares, asterisks, black dots, or arrows. This article will share how to programmatically insert bullet point symbols in a Word document using Free Spire.Doc for Java.

Install the Library (Two Methods)

Method 1: Download the free Java library and unzip it. Then add the Spire.Doc.jar file to your Java application as dependency.
Method 2: Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.

<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

With Free Spire.Doc for Java, you can set ASCII characters (special symbols) as bullet points in a Word document. Below are the complete sample code to apply four different bullet point symbols.

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.Section;
import com.spire.doc.documents.ListStyle;
import com.spire.doc.documents.ListType;
import com.spire.doc.documents.Paragraph;

public class SetBulletPoints {

public static void main(String[] args) {

//Create a Document object and load a sample file
Document doc = new Document();
doc.loadFromFile("E:\\Files\\input11.docx");

//Get the first section
Section section = doc.getSections().get(0);

//Create four list styles based on different ASCII characters
ListStyle listStyle1 = new ListStyle(doc, ListType.Bulleted);
listStyle1.getLevels().get(0).setBulletCharacter("\u006e");
listStyle1.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
listStyle1.setName("liststyle1");
doc.getListStyles().add(listStyle1);

ListStyle listStyle2 = new ListStyle(doc, ListType.Bulleted);
listStyle2.getLevels().get(0).setBulletCharacter("\u0075");
listStyle2.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
listStyle2.setName("liststyle2");
doc.getListStyles().add(listStyle2);

ListStyle listStyle3 = new ListStyle(doc, ListType.Bulleted);
listStyle3.getLevels().get(0).setBulletCharacter("\u00b2");
listStyle3.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
listStyle3.setName("liststyle3");
doc.getListStyles().add(listStyle3);

ListStyle listStyle4 = new ListStyle(doc, ListType.Bulleted);
listStyle4 .getLevels().get(0).setBulletCharacter("\u00d8");
listStyle4 .getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
listStyle4.setName("liststyle4");
doc.getListStyles().add(listStyle4);

//apply the four list styles to four paragraphs
Paragraph p1 = section.getParagraphs().get(0);
p1.getListFormat().applyStyle(listStyle1.getName());

Paragraph p2 = section.getParagraphs().get(1);
p2.getListFormat().applyStyle(listStyle2.getName());

Paragraph p3 = section.getParagraphs().get(2);
p3.getListFormat().applyStyle(listStyle3.getName());

Paragraph p4= section.getParagraphs().get(3);
p4.getListFormat().applyStyle(listStyle4.getName());

//Save to file
doc.saveToFile("SetBulletCharacter.docx", FileFormat.Docx);
}
}

--

--

Andrew Wilson
Andrew Wilson

Written by Andrew Wilson

Explore C#, Java and Python solutions for processing Word/Excel/PowerPoint/PDF files.

No responses yet