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?
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,
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");
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.