Free Support Forum - aspose.com

How to insert CheckBox instead of list bullets

I generate a word document using .insertHtml() method.

After inserting all elements I need to go through each list, remove bullets and insert checkboxs in front of the text. It must look like bullets, but it must be checkboxes.

I do like this…

foreach (List list in doc.Lists)
{
foreach (ListLevel level in list.ListLevels)
{
level.NumberFormat = “”; //Cleans bullets, maybe there is better solution?
… here I need to insert checkbox, but I do not know how…
}
}
}

Questions:
How to insert CheckBox instead of list bullets?
Method level.NumberStyle = NumberStyle.None; does not remove bullets. Is it right?
:slight_smile:

Hello

Thank you for your interest in Aspose.Words. Could you please attach your input and expected output documents here for testing? I will check them and provide you more information.

Best regards,

Here is an example how it must look.

p.s. I am a newbie here. I posted this question in Aspose.Priority.Support area also. You can move this thread there.

Hello

Thank you for additional information. In this case you can try suing the code like the following:

Document doc = new Document("C:\\Temp\\in.doc");

DocumentBuilder builder = new DocumentBuilder(doc);

// Get collection of Paragraph nodes.

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);

// Loop throught all Paragraphs.

foreach (Paragraph par in paragraphs)

{

if (par.IsListItem && (par.HasChildNodes || !par.IsEndOfSection))

{

//Get label of list item

string label = par.ListLabel.LabelString + "\t";

//Create run that will represent label in the document

Run labelRun = new Run(doc, label);

//We should import paragraph indents

double leftIndent = par.ListFormat.ListLevel.NumberPosition;

//Remove list label

par.ListFormat.RemoveNumbers();

//Insert label at the begining of paragraph

par.ChildNodes.Insert(0, labelRun);

builder.MoveTo(labelRun);

//Insert CheckBox at the begining of paragraph

builder.InsertCheckBox("chkYes", false, 11);

par.ParagraphFormat.LeftIndent = leftIndent;

}

}

doc.Save("C:\\Temp\\out.doc");

Best regards,

Thank you for quick response! It actually works! :slight_smile: