Manage Bullet and Numbered Lists
In Microsoft PowerPoint, you can create bullet and numbered lists the same way you do in Word and other text editors. Aspose.Slides for .NET also allows you to use bullets and numbers in slides in your presentations.
Why Use Bullet Lists?
Bullet lists help you to organize and present information quickly and efficiently.
Bullet List Example
In most cases, a bullet list serves these three main functions:
- draws your readers or viewers attention to important information
- allows your readers or viewers to scan for key points easily
- communicates and delivers important details efficiently.
Why Use Numbered Lists?
Numbered lists also help in organizing and presenting information. Ideally, you should use numbers (in place of bullets) when the order of the entries (for example, step 1, step 2, etc.) is important or when an entry has to be referenced (for example, see step 3).
Numbered List Example
This is a summary of the steps (step 1 to step 15) in the Creating Bullets procedure below:
- Create an instance of the presentation class.
- Perform several tasks (step 3 to step 14).
- Save the presentation.
Creating Bullets
To create a bullet list, through these steps:
- Create an instance of the Presentation class.
- Access the slide (in which you want to add a bullet list) in slide collection through the ISlide object.
- Add an AutoShape in the selected slide.
- Access the TextFrame of the added shape.
- Remove the default paragraph in the TextFrame.
- Create the first paragraph instance using the Paragraph class.
- Set the bullet type to Symbol and then set the bullet character.
- Set the Paragraph Text.
- Set the Paragraph Indent to set the bullet.
- Set the Color of the Bullet.
- Set the Height of the Bullet.
- Add the created paragraph in the TextFrame paragraph collection.
- Add the second paragraph and repeat steps 7-12.
- Save the presentation.
This sample code in C#—an implementation of the steps above—shows you to create a bullet list in a slide:
using (Presentation pres = new Presentation())
{
ISlide slide = pres.Slides[0];
IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100);
ITextFrame textFrame = autoShape.TextFrame;
textFrame.Paragraphs.Clear();
Paragraph paragraph = new Paragraph();
paragraph.ParagraphFormat.Bullet.Type = BulletType.Symbol;
paragraph.ParagraphFormat.Bullet.Char = '*';
paragraph.ParagraphFormat.Indent = 15;
paragraph.ParagraphFormat.Bullet.IsBulletHardColor = NullableBool.True;
paragraph.ParagraphFormat.Bullet.Color.Color = Color.Red;
paragraph.ParagraphFormat.Bullet.Height = 100;
paragraph.Text = "My text";
textFrame.Paragraphs.Add(paragraph);
// ...
pres.Save("pres.pptx", SaveFormat.Pptx);
}
Creating Picture Bullets
Aspose.Slides for .NET allows you to change the bullets on bullet lists. You get to replace the bullets with custom symbols or images. If you want to add visual interest to a list or draw even more attention to entries on a list, you can use your own image as the bullet.
Ideally, if you intend to replace the regular bullet symbol with a picture, you may want to select a simple graphics image with a transparent background. Such images work best as custom bullet symbols.
In any case, the image you choose will be reduced to a very small size, so we strongly recommend you select an image that looks good (as a replacement for the bullet symbol) in a list.
To create a picture bullet, go through these steps:
- Create an instance of the Presentation class.
- Access the desired slide in slide collection using the ISlide object.
- Add an AutoShape in the selected slide.
- Access the TextFrame of the added shape.
- Remove the default paragraph in the TextFrame.
- Create the first paragraph instance using the Paragraph class.
- Load Image from disk and add it to Presentation.Images and then use the IPPImage instance that was returned from the AddImage method.
- Set the bullet type to Picture and then set the image.
- Set the Paragraph Text.
- Set the Paragraph Indent to set the bullet.
- Set the Color of Bullet.
- Set the Height of Bullets.
- Add the created paragraph in the TextFrame paragraph collection.
- Add the second paragraph and repeat steps 7-13.
- Save the presentation.
This C# code shows you to create a picture bullet in a slide:
using (Presentation pres = new Presentation())
{
ISlide slide = pres.Slides[0];
IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100);
ITextFrame textFrame = autoShape.TextFrame;
textFrame.Paragraphs.Clear();
Paragraph paragraph = new Paragraph();
paragraph.ParagraphFormat.Bullet.Type = BulletType.Picture;
IPPImage image = pres.Images.AddImage(File.ReadAllBytes("image.png"));
paragraph.ParagraphFormat.Bullet.Picture.Image = image;
paragraph.ParagraphFormat.Indent = 15;
paragraph.ParagraphFormat.Bullet.Height = 100;
paragraph.Text = "My text";
textFrame.Paragraphs.Add(paragraph);
// ...
pres.Save("pres.pptx", SaveFormat.Pptx);
}
Creating Multilevel Bullets
To create a bullet list that contains items on different levels—additional lists under the main bullet list—go through these steps:
- Create an instance of the Presentation class.
- Access the desired slide in slide collection using the ISlide object.
- Add an AutoShape in the selected slide.
- Access the TextFrame of the added shape.
- Remove the default paragraph in the TextFrame.
- Create the first paragraph instance using the Paragraph class and with depth set to 0.
- Create the second paragraph instance using the Paragraph class and the depth set to 1.
- Create the third paragraph instance using the Paragraph class and the depth set to 2.
- Create the fourth paragraph instance using the Paragraph class and the depth set to 3.
- Add the created paragraphs in the TextFrame paragraph collection.
- Save the presentation.
This code, which is an implementation of the steps above, shows you how to create a multilevel bullet list in C#:
using (Presentation pres = new Presentation())
{
ISlide slide = pres.Slides[0];
IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 300, 300);
ITextFrame textFrame = autoShape.TextFrame;
textFrame.Paragraphs.Clear();
Paragraph paragraph = new Paragraph();
paragraph.ParagraphFormat.Depth = 0;
paragraph.Text = "My text Depth 0";
textFrame.Paragraphs.Add(paragraph);
Paragraph paragraph2 = new Paragraph();
paragraph2.ParagraphFormat.Depth = 0;
paragraph2.Text = "My text Depth 1";
textFrame.Paragraphs.Add(paragraph2);
Paragraph paragraph3 = new Paragraph();
paragraph3.ParagraphFormat.Depth = 2;
paragraph3.Text = "My text Depth 2";
textFrame.Paragraphs.Add(paragraph3);
Paragraph paragraph4 = new Paragraph();
paragraph4.ParagraphFormat.Depth = 3;
paragraph4.Text = "My text Depth 3";
textFrame.Paragraphs.Add(paragraph4);
pres.Save("pres.pptx", SaveFormat.Pptx);
}
Creating Numbers
This C# code shows you how to create a numbered list in a slide:
using (Presentation pres = new Presentation())
{
ISlide slide = pres.Slides[0];
IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100);
ITextFrame textFrame = autoShape.TextFrame;
textFrame.Paragraphs.Clear();
Paragraph paragraph = new Paragraph();
paragraph.ParagraphFormat.Bullet.Type = BulletType.Numbered;
paragraph.Text = "My text 1";
textFrame.Paragraphs.Add(paragraph);
Paragraph paragraph2 = new Paragraph();
paragraph2.ParagraphFormat.Bullet.Type = BulletType.Numbered;
paragraph2.Text = "My text 2";
textFrame.Paragraphs.Add(paragraph2);
// ...
pres.Save("pres.pptx", SaveFormat.Pptx);
}