Hi,
I am facing an issue when adding current document list style to newly added text within content controls.
The newly added text that you will find in the document is :
All Clause Types
test clause default
Currency
Effective Start Date
I have attached input & expected output documents. I need the content control around “All Clause Types” to have a listlevel =2 & append numbering 1.2 to it
and
the content control below it to have a listlevel = 3 and append no numbering to it based on the existing list style. Could you please help me to get the desired output programmatically?
Thanks!
List Level.zip (37.6 KB)
@pri_verd,
We are working over your query and will get back to you soon.
@pri_verd,
You can make the target Paragraph part of List by using the following code:
Document doc = new Document("D:\\List Level\\LLinput.docx");
doc.AcceptAllRevisions();
List list = doc.Lists[0];
Paragraph targetPara = null;
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
if (para.ToString(SaveFormat.Text).StartsWith("All Clause Types"))
{
targetPara = para;
break;
}
}
if (targetPara != null)
{
StructuredDocumentTag sdt = targetPara.ParentNode as StructuredDocumentTag;
sdt.LockContentControl = false;
sdt.LockContents = false;
targetPara.ListFormat.List = list;
targetPara.ListFormat.ListLevelNumber = 1;
}
doc.Save("D:\\List Level\\18.9.docx");