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)
    Dim list As Aspose.Words.Lists.List = docReport.Lists.Add(ListTemplate.NumberArabicParenthesis)
    ' Modify the formatting of the list.
    With list.ListLevels(0)
        .NumberFormat = ChrW(61623)
        .TrailingCharacter = ListTrailingCharacter.Tab
        .NumberStyle = NumberStyle.Bullet

        .Alignment = ListLevelAlignment.Left
        .Font.Color = spec.DiagnosisColor
        With .Font
            .Size = 8
            .Name = "Symbol"
        End With
    End With

    .StartBookmark("bull")

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

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

                resetBullets = False
                line = vbNewLine & line
            End If

            .Write(line)
        Else
            .ListFormat.List = Nothing
            .ListFormat.RemoveNumbers()
            resetBullets = True
        End If
    Next

    .EndBookmark("bull")
End With

What I want as output is:

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

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

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.