Making your slides easy to read is vital to creating an effective PowerPoint presentation. One of the most common ways of doing this is to format the text as a bulleted or numbered list. A list can help organize information in a neat manner as well as attract the reader’s attention. In this article, you will learn how to create numbered lists and bulleted lists in a PowerPoint slide in Java using Spire.Presentation for Java.
- Create a Numbered List in PowerPoint
- Create a Bulleted List with Symbol Bullets in PowerPoint
- Create a Bulleted List with Image Bullets in PowerPoint
Install Spire.Presentation for Java
First of all, you're required to add the Spire.Presentation.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.
<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.presentation</artifactId> <version>9.10.2</version> </dependency> </dependencies>
Create a Numbered List in PowerPoint in Java
Spire.Presentation supports adding numerals or bullet points in front of paragraphs to create a numbered or bulleted list. To specify the bullet type, use ParagraphEx.setBulletType() method. The following are the steps to create a numbered list in a PowerPoint slide using Spire.Presentation for Java.
- Create a Presentation object.
- Get the first slide using Presentation.getSlides().get() method.
- Append a shape to the slide using ISlide.getShapes().appendShape() method.
- Specify list content inside a String list.
- Create paragraphs based on the list content, and set the bullet type of these paragraphs to NUMBERED using ParagraphEx.setBulletType() method.
- Set the numbered bullet style using ParagraphEx.setBulletStyle() method.
- Save the document to a PowerPoint file using Presentation.saveToFile() method.
- Java
import com.spire.presentation.*; import com.spire.presentation.drawing.FillFormatType; import java.awt.*; import java.awt.geom.Rectangle2D; public class CreateNumberedList { public static void main(String[] args) throws Exception { //Create a Presentation object Presentation presentation = new Presentation(); presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9); //Get the first slide ISlide slide = presentation.getSlides().get(0); //Append a shape to the slide and set shape style Rectangle2D rect = new Rectangle2D.Double(50, 50, 300, 200); IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, rect); shape.getLine().setFillType(FillFormatType.NONE); shape.getFill().setFillType(FillFormatType.NONE); //Add text to the default paragraph ParagraphEx titleParagraph = shape.getTextFrame().getParagraphs().get(0); titleParagraph.setText("Required Web Development Skills:"); titleParagraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID); titleParagraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black); titleParagraph.setAlignment(TextAlignmentType.LEFT); //Specify list content String[] listContent = new String[] { " Command-line Unix", " Vim", " HTML", " CSS", " Python", " JavaScript", " SQL" }; //Create a numbered list for(int i = 0; i < listContent.length; i ++) { ParagraphEx paragraph = new ParagraphEx(); shape.getTextFrame().getParagraphs().append(paragraph); paragraph.setText(listContent[i]); paragraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID); paragraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black); paragraph.setBulletType(TextBulletType.NUMBERED); paragraph.setBulletStyle(NumberedBulletStyle.BULLET_ARABIC_PERIOD); } //Save the document presentation.saveToFile("NumberedList.pptx", FileFormat.PPTX_2013); } }
Create a Bulleted List with Symbol Bullets in PowerPoint in Java
The process of creating a bulleted list using symbol bullets is very similar to that of creating a numbered list. The only difference is that you need to set the bullet type to SYMBOL. The following are the steps.
- Create a Presentation object.
- Get the first slide using Presentation.getSlides().get() method.
- Append a shape to the slide using ISlide.getShapes().appendShape() method.
- Specify list content inside a String list.
- Create paragraphs based on the list content, and set the bullet type of these paragraphs to SYMBOL using ParagraphEx.setBulletType() method.
- Save the document to a PowerPoint file using Presentation.saveToFile() method.
- Java
import com.spire.presentation.*; import com.spire.presentation.drawing.FillFormatType; import java.awt.*; import java.awt.geom.Rectangle2D; public class CreateBulletedListWithSymbol { public static void main(String[] args) throws Exception { //Create a Presentation object Presentation presentation = new Presentation(); presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9); //Get the first slide ISlide slide = presentation.getSlides().get(0); //Append a shape to the slide and set shape style Rectangle2D rect = new Rectangle2D.Double(50, 50, 350, 200); IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, rect); shape.getLine().setFillType(FillFormatType.NONE); shape.getFill().setFillType(FillFormatType.NONE); //Add text to the default paragraph ParagraphEx titleParagraph = shape.getTextFrame().getParagraphs().get(0); titleParagraph.setText("Computer Science Subjects:"); titleParagraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID); titleParagraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black); titleParagraph.setAlignment(TextAlignmentType.LEFT); //Specify list content String[] listContent = new String[] { " Data Structure", " Algorithm", " Computer Networks", " Operating System", " Theory of Computations", " C Programming", " Computer Organization and Architecture" }; //Create a bulleted list with symbol bullets for(int i = 0; i < listContent.length; i ++) { ParagraphEx paragraph = new ParagraphEx(); shape.getTextFrame().getParagraphs().append(paragraph); paragraph.setText(listContent[i]); paragraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID); paragraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black); paragraph.setBulletType(TextBulletType.SYMBOL); } //Save the document presentation.saveToFile("SymbolBullets.pptx", FileFormat.PPTX_2013); } }
Create a Bulleted List with Image Bullets in PowerPoint in Java
To use an image as bullet points, you need to set the bullet type to PICTURE and specify an image for the BulletPicture object. The following are the detailed steps.
- Create a Presentation object.
- Get the first slide using Presentation.getSlides().get() method.
- Append a shape to the slide using ISlide.getShapes().appendShape() method.
- Specify list content inside a String list.
- Create paragraphs based on the list content, and set the bullet type of these paragraphs to PICTURE using ParagraphEx.setBulletType() method.
- Set the image for the bullets using Paragraph.getBulletPicture().setEmbedImage() method.
- Save the document to a PowerPoint file using Presentation.saveToFile() method.
- Java
import com.spire.presentation.*; import com.spire.presentation.drawing.FillFormatType; import javax.imageio.ImageIO; import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.File; public class CreateBulletedListWithImage { public static void main(String[] args) throws Exception { //Create a Presentation object Presentation presentation = new Presentation(); presentation.getSlideSize().setType(SlideSizeType.SCREEN_16_X_9); //Get the first slide ISlide slide = presentation.getSlides().get(0); //Append a shape to the slide and set shape style Rectangle2D rect = new Rectangle2D.Double(50, 50, 400, 180); IAutoShape shape = slide.getShapes().appendShape(ShapeType.RECTANGLE, rect); shape.getLine().setFillType(FillFormatType.NONE); shape.getFill().setFillType(FillFormatType.NONE); //Add text to the default paragraph ParagraphEx titleParagraph = shape.getTextFrame().getParagraphs().get(0); titleParagraph.setText("Project Task To-Do List:"); titleParagraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID); titleParagraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black); titleParagraph.setAlignment(TextAlignmentType.LEFT); //Specify list content String[] listContent = new String[] { " Define projects and tasks you're working on", " Assign people to tasks", " Define the priority levels of your tasks", " Keep track of the progress status of your tasks", " Mark tasks as done when completed" }; //Create a bulleted list with image bullets BufferedImage image = ImageIO.read(new File("C:\\Users\\Administrator\\Desktop\\R-C25.png")); for(int i = 0; i < listContent.length; i ++) { ParagraphEx paragraph = new ParagraphEx(); shape.getTextFrame().getParagraphs().append(paragraph); paragraph.setText(listContent[i]); paragraph.getTextRanges().get(0).getFill().setFillType(FillFormatType.SOLID); paragraph.getTextRanges().get(0).getFill().getSolidColor().setColor(Color.black); paragraph.setBulletType(TextBulletType.PICTURE); paragraph.getBulletPicture().setEmbedImage(presentation.getImages().append(image)); } //Save the document presentation.saveToFile("ImageBullets.pptx", FileFormat.PPTX_2013); } }
Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.