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

Free Support Forum - aspose.com

First bullet is not colored; Bullet not removed on empty line

Hi,

I’m trying to add bullet-ed lines in a cell (lines have color blue) using aspose.words/VB.Net.

The problem is that The very first bullet is not being colored blue like the rest of bullets on other lines, plus I have a problem where I want to add an empty line, it’s being added with a bullet, and I can’t find a way to remove it, please help.

This is the code I’m using (tried some other workarounds already, but didn’t work):

	With builder
.Font.Color = Color.Blue
.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(0.5)
        <span style="color:blue;">Dim</span> list <span style="color:blue;">As</span> Aspose.Words.Lists.<span style="color:#2b91af;">List</span> = docReport.Lists.Add(<span style="color:#2b91af;">ListTemplate</span>.NumberArabicParenthesis)
        <span style="color:green;">' Modify the formatting of the list.</span>
        <span style="color:blue;">With</span> list.ListLevels(0)
            .NumberFormat = ChrW(61623)
            .TrailingCharacter = <span style="color:#2b91af;">ListTrailingCharacter</span>.Tab
            .NumberStyle = <span style="color:#2b91af;">NumberStyle</span>.Bullet

            .Alignment = <span style="color:#2b91af;">ListLevelAlignment</span>.Left
            .Font.Color = spec.DiagnosisColor
            <span style="color:blue;">With</span> .Font
                .Size = 8
                .Name = <span style="color:#a31515;">"Symbol"</span>
            <span style="color:blue;">End</span> <span style="color:blue;">With</span>
        <span style="color:blue;">End</span> <span style="color:blue;">With</span>

        .StartBookmark(<span style="color:#a31515;">"bull"</span>)

        .ListFormat.List = list
        .ListFormat.ApplyBulletDefault()

        <span style="color:blue;">Dim</span> resetBullets <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span>
        <span style="color:blue;">Dim</span> tt() = spec.Diagnosis.Split(vbNewLine)
        <span style="color:blue;">For</span> <span style="color:blue;">Each</span> line <span style="color:blue;">As</span> <span style="color:blue;">String</span> <span style="color:blue;">In</span> tt
            <span style="color:blue;">If</span> line.Trim.Length > 0 <span style="color:blue;">Then</span>
                <span style="color:blue;">If</span> resetBullets <span style="color:blue;">Then</span>
                    .ListFormat.List = list
                    .ListFormat.ApplyBulletDefault()
                    .Font.Color = Color.Blue<br>

                    resetBullets = <span style="color:blue;">False</span>
                    line = vbNewLine & line
                <span style="color:blue;">End</span> <span style="color:blue;">If</span>

                .Write(line)
            <span style="color:blue;">Else</span>
                .ListFormat.List = <span style="color:blue;">Nothing</span>
                .ListFormat.RemoveNumbers()
                resetBullets = <span style="color:blue;">True</span>
            <span style="color:blue;">End</span> <span style="color:blue;">If</span>
        <span style="color:blue;">Next</span>

        .EndBookmark(<span style="color:#a31515;">"bull"</span>)
    <span style="color:blue;">End</span> <span style="color:blue;">With</span></pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><span style="font-family: 'Times New Roman'; font-size: medium; white-space: normal;">What I want as output is:</span></pre><pre style="font-family: Consolas; font-size: 13px; background: white;">

· suspicious


· COLON AND RECTUM

· SPECIMEN:

· Tumor Site: Cecum

But I'm getting:

· suspicious

·

· COLON AND RECTUM

· SPECIMEN:

· Tumor Site: Cecum

Hi Saleem,

Thanks for your inquiry. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v14.5.0) from here and let us know how it goes on your side.

If the problem still remains, please share following detail for investigation purposes.


  • Please attach your input Word document, if you are using any.
  • Please

    create a standalone/runnable simple application (for example a Console
    Application Project
    ) that demonstrates the code (Aspose.Words code) you used to generate
    your output document

  • Please attach the output Word file that shows the undesired behavior.
  • Please
    attach your target Word document showing the desired behavior. You can
    use Microsoft Word to create your target Word document. I will
    investigate as to how you are expecting your final document be generated
    like.

As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

Hi again,

I used the latest Aspose.Words (14.5.0) and the first bullet color is now fixed :slight_smile:

However the second problem, when I’m not able to remove the bullet from an empty line and make it show again on other not empty lines did not work for me yet. It seems I’m getting it wrong somewhere in my code.

Please check attached files to this post and help me fix this (I attached input, output and desired word documents, plus w small vb.net app that demonstrates how I implemented the bullets).
Thank you,
Saleem.

Hi Saleem,

Thanks for your inquiry. In your case, you need to call the ListFormat.RemoveNumbers method where you want to break the list and insert empty paragraph. After this assign the same List to ListFormat.List property. Please check the following highlighted code below.

Please let us know if you have any more queries.


Using docStream As New FileStream("C:/testInput.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)

docReport = New Document(docStream)

builder = New DocumentBuilder(docReport)

Dim tbl As Table = docReport.Range.Bookmarks("tbl").BookmarkStart.GetAncestor(NodeType.Table)

builder.MoveTo(tbl.FirstRow.LastCell.FirstParagraph)

Dim list As Aspose.Words.Lists.List = docReport.Lists.Add(ListTemplate.NumberArabicParenthesis)

With list.ListLevels(0)

.NumberFormat = ChrW(61623)

.TrailingCharacter = ListTrailingCharacter.Tab

.NumberStyle = NumberStyle.Bullet

.Alignment = ListLevelAlignment.Left

.Font.Color = Color.Blue

With .Font

.Size = 8

.Name = "Symbol"

End With

End With

builder.Font.Size = 11

builder.Font.Bold = True

builder.ParagraphFormat.LeftIndent = ConvertUtil.InchToPoint(0)

builder.Font.Color = Color.Blue

builder.ParagraphFormat.SpaceBefore = 0

builder.ParagraphFormat.SpaceAfter = 0

builder.ListFormat.List = list

builder.Writeln("DOC")

builder.Writeln("PDF")

builder.Writeln("HTML")

builder.Writeln("MHTML")

builder.ListFormat.RemoveNumbers()

builder.Writeln("")

builder.ListFormat.List = list

builder.Writeln("DOC")

builder.Writeln("PDF")

builder.Writeln("HTML")

builder.Writeln("MHTML")

builder.ListFormat.RemoveNumbers()

docReport.Save("c:/out.docx")

End Using

This works perfectly, thank you a lot :smiley:

Hi Saleem,

Thanks
for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Ok I have one more issue :smiley:

I have a bookmark I’m adding to a cell, bookmark name is: "wb_FieldName__AT__PART_1_Addednum_2pts_nl"
It’s added normally at first, but once the following line is executed:
docReport.Save(“C:\testOutput.docx”, SaveFormat.Docx)

bookmark is being renamed to:
"wb_FieldName__AT__PART_1_Addednum_2pts_n"

Maybe the bookmark name’s length is too much, but I will need to use such bookmarks, so I hope this has a solution :S


I attached the documents used to reproduce this error.

Hi Saleem,

Thanks
for your inquiry. This problem occurs because it is by Microsoft Word design that bookmark name length is limited to 40 characters. There is no way you can override this behavior using
Aspose.Words.

Please let us know if you have any more queries.