We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to use template bullet format?

Hi,

I'm using vb.net and pptx. What I'm trying to do is to use same bullet format in template but the contents will be pulled from database automatically. The number of bullets will be determined by the number of the items in database. Could you please help?

Thanks,

Jane

Hi Jane,

I have tried to understand the issue shared by you. I have developed the sample code snippet for you. You can use it to add the bullets inside the slides text frame.

PresentationEx pres = new PresentationEx();

SlideEx slide = pres.Slides[0];

int iShpId = slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle , 200, 200, 200, 200);

AutoShapeEx aShp = (AutoShapeEx)slide.Shapes[iShpId];

TextFrameEx txtFrm = aShp.TextFrame;

//Getting the first paragraph of the text frame

ParagraphEx para = txtFrm.Paragraphs[0];

para.BulletType=BulletTypeEx.Numbered ;

short start = 1;

para.NumberedBulletStartWith =start;

para.Text="Welcome to Aspose.Slides";

para.BulletHeight=100;

int iContentCount=10;//Contents of database

ParagraphEx para_new;

for (int i = 0; i < iContentCount; i++)

{

para_new = new ParagraphEx(para);

para_new.Text = "Second Bullet_" + i;

txtFrm.Paragraphs.Add(para_new);

}

//Writing the presentation as a PPT file

pres.Write("K:\\Apple\\Numbered.pptx");

Thanks and Regards,

First of all, I'm using vb.net, not C#. And what I want is the bullet type in template, not the numbered bullet. I don't know how to add the filled square bullets that we have in the template. Please see the example in the attachment.

Hi Jane,

I have converted the code snippet to VB .NET for you. I have also added the squared bullet for you. Please share with us if you still feel any issue.

Dim pres As PresentationEx = New PresentationEx()

Dim slide As SlideEx = pres.Slides(0)

Dim iShpId As Integer = slide.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 50, 50, 500, 600)

'Dim iShpId As Integer = 0

Dim aShp As AutoShapeEx = CType(slide.Shapes(iShpId), AutoShapeEx)

Dim txtFrm As TextFrameEx = aShp.TextFrame

Dim para As ParagraphEx = txtFrm.Paragraphs(0)

para.BulletChar = Char.Parse(Char.ConvertFromUtf32(9632))

Dim iShpAsc As Integer = Convert.ToInt32(para.BulletChar)

para.BulletType = BulletTypeEx.Symbol

para.Text = "Welcome to Aspose.Slides"

para.BulletHeight = 100

Dim iContentCount As Integer = 10'Contents of database

Dim para_new As ParagraphEx

For iCount As Integer = 0 To iContentCount - 1

para_new = New ParagraphEx(para)

para_new.Text = "Bullet_" + iCount.ToString()

txtFrm.Paragraphs.Add(para_new)

Next

'Writing the presentation as a PPT file

pres.Write("D:\\Aspose Data\\Numbered.pptx")

Thanks and Regards,

Thanks! One more question. How can I change the color of the bullet?

Hi Jane,

Please use the following code snippet for setting the bullet color.

para.BulletColorFormat.ColorType = ColorTypeEx.RGB

para.BulletColorFormat.Color = Color.Red

para.RawIsBulletHardColor = NullableBool.True

Thanks and Regards,