Bulleted List item. How to determine shape of bullet

Hi Aspose Team,
I have a word document which has list type as bullet which are of type as follows,

  1. BulletSquare
  2. BulletDisk
  3. BulletCircle

How do i programmatically determine the type of bullets.
currently i using following code to determine if its bullet
NumberStyle.BULLET;

Thanks for your inquiry. I will try to compose a working code example for you and post it here in a short time.

Hi
Try to use following example to set custom bullets.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.ApplyBulletDefault();
builder.ListFormat.ListLevel.NumberFormat = "\x006F";
builder.Writeln("test");
builder.Write("test");
builder.ListFormat.ApplyBulletDefault();
builder.ListFormat.ListLevel.NumberFormat = "\x00A8";
builder.Writeln("test");
builder.Write("test");
builder.ListFormat.ApplyBulletDefault();
builder.ListFormat.ListLevel.NumberFormat = "\x00B7";
builder.Writeln("test");
builder.Write("test");
doc.Save("test.doc");

And see following links to learn more.
https://reference.aspose.com/words/net/aspose.words.lists/listlevel/numberformat/

https://forum.aspose.com/c/words/8

I hope that it will help you.

Hi,
I am using API for java to build the document.
I restructured the above code as follows,

builder.getListFormat().applyBulletDefault();
builder.getListFormat().getListLevel().setNumberFormat("\\x006F");
builder.writeln("test");
builder.write("test");
builder.getListFormat().applyBulletDefault();
builder.getListFormat().getListLevel().setNumberFormat("\\x00A8");
builder.writeln("test");
builder.write("test");
builder.getListFormat().applyBulletDefault();
builder.getListFormat().getListLevel().setNumberFormat("\\x00B7");
builder.writeln("test");
builder.write("test");

but i am getting garbled output.
Also if possible can you publish the code which can be compiled using java compiler.
Thanks,
Anup

Hi
String you set as custom bullet can be just a string or a hex code of symbol. If you write builder.getListFormat().getListLevel().setNumberFormat("\x00A8"); string isn’t hex code. That’s why you get garbed output. Try to use following code.
builder.getListFormat().getListLevel().setNumberFormat("\x00A8");
or
builder.getListFormat().getListLevel().setNumberFormat("-");
if you want use “-” as bullet.
I hope that it will help you.

Hi Vitaly,
In java if you want to assign a string “\x00A8” it will give an error , you need to provide a escape sequence for character “”. So the String would be \x00A8" .
Also my query was about reading the list charater like bullet , diamond bullet or start bullet.
currently i am using following code to determine if the list style is a bullet or not.

ListFormat listFormat = (ListFormat)Paragraph.getListFormat();
ListLevel listLevel = listFormat.getListLevel();
int listStyle = listLevel.getNumberStyle();
if(listStyle==NumberStyle.BULLET) {
    listStyleDefn = "BULLET";
}

So my query is how do i determine if the bullet is of type dot, diamond, circle , star etc.
Thanks ,
Anup

Hi
You can try to get an array of symbol codes. Than get a symbol of current bullet and search it in the array. See following example.

if (listStyle == NumberStyle.Bullet)
{
    listStyleDefn = "BULLET";
    // geting symbol code
    int symbolCode = Convert.ToChar(listLevel.NumberFormat);
    switch (symbolCode)
    {
        case 111:
            {
                symbol = "circle";
                break;
            }
        case 61607:
            {
                symbol = "square";
                break;
            }
        case 183:
            {
                symbol = "disk";
                break;
            }
        case 168:
            {
                symbol = "romb";
                break;
            }
        case 61482:
            {
                symbol = "star";
                break;
            }
        default:
            {
                symbol = "unknown";
                break;
            }
    }
}

I hope that it will help you.

Hi,
The following line is giving problem,

int symbolCode = Convert.ToChar(listLevel.NumberFormat);

if you look the NumberFormat method of listLevel its like,

String numberFormat = listLevel.getNumberFormat();

So the getNumberFormat()if ListLevel returns string. The value of string returned is a special character like ‘?’ or ‘o’. This is throwing an exception whein i try to use following code,

int symbolCode = Integer.parseInt(numberFormat);

Thanks,
Anup

Hi
Try use following code to get symbol code.

String s = listLevel.getNumberFormat(); 
byte[] codes = s.getBytes("US-ASCII");

byte code = codes[0];

I hope that it will help you.

Hello Vitaly,
Thanks a lot for the information. I was able to proceed , but i am still facing some problem,
I see following type of bullets.
BULLET_DEFAULT, BULLET_CIRCLE, BULLET_SQUARE, BULLET_DISK,BULLET_ROMB,BULLET_STAR
The following is only returning two values 63 and 111
String s = listLevel.getNumberFormat();
byte[] codes = s.getBytes(“US-ASCII”);
byte code = codes[0];
111 for BULLET_CIRCLE
63 for BULLET_DEFAULT, BULLET_SQUARE, BULLET_DISK, BULLET_ROMB and BULLET_STAR.
I am not sure but i feel when we are doing transformation from string to array of bytes are some value getting truncated. A unsigned byte can 128 so it might be truncating the value. I tried getting length of the “byte[] codes” it was “1” for all the type of bullets.
Thanks,
Anup

Hi
Try to use Unicode codepage.

byte[] codes = s.getBytes("UTF-8");

Best regards.

I am also facing similar problem. How can I determine the type of the bullet? s.getBytes(“UTF-8”) is not working and with s.getBytes(“US-ASCII”) only two values 63 and 111 are being retrieved.

Hello!
Thank you for your interest in Aspose.Words.
Please attach the source document or show how you are constructing it. Are you also using Aspose.Words for Java? I’ll take a look how we can determine bullet types.
Regards,