Hi Team,
I want to find the particular heading in the document then I need to check the heading below the particular content. both the heading and content matched and do not need to add a comment.
if the heading below the content is not matched we need to add the comment.
Please find the below input and expected output.
Expeceted_output200.docx (17.0 KB)
Input_word_document200.docx (13.0 KB)
string description = "This is the Heading 3";
string heading = "Heading 3";
var listHeadings = doc.GetChildNodes(NodeType.Paragraph, true).Cast<Paragraph>().Where(p => p.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1);
foreach (Paragraph paragraph in listHeadings)
{
if (paragraph.ToString(SaveFormat.Text).Trim().Equals(heading, StringComparison.InvariantCultureIgnoreCase))
{
var commenttextTopMarginText = "This description is worng";
Comment comment = new Comment(doc, "mmh", "007", DateTime.Today);
comment.Paragraphs.Add(new Paragraph(doc));
comment.FirstParagraph.AppendChild(new Run(doc, commenttextTopMarginText));
CommentRangeStart start = new CommentRangeStart(doc, comment.Id);
CommentRangeEnd end = new CommentRangeEnd(doc, comment.Id);
paragraph.PrependChild(start);
paragraph.AppendChild(comment);
paragraph.AppendChild(end);
}
}