- OpenXML SDK
- Spire.Doc
- Download Sample Code
class Program
{
static void Main(string[] args)
{
string fileName = "OpenXML.docx";
GetCommentsFromDocument(fileName);
}
public static void GetCommentsFromDocument(string fileName)
{
using (WordprocessingDocument wordDoc =
WordprocessingDocument.Open(fileName, false))
{
WordprocessingCommentsPart commentsPart =
wordDoc.MainDocumentPart.WordprocessingCommentsPart;
if (commentsPart != null && commentsPart.Comments != null)
{
foreach (Comment comment in commentsPart.Comments.Elements())
{
Console.WriteLine(comment.InnerText);
}
}
}
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
string fileName = "OpenXML.docx";
GetCommentsFromDocument(fileName);
}
public static void GetCommentsFromDocument(string fileName)
{
Document document = new Document();
document.LoadFromFile(fileName);
foreach (Comment comment in document.Comments)
{
foreach (Paragraph para in comment.Body.Paragraphs)
{
Console.WriteLine(para.Text);
}
}
Console.ReadLine();
}
}
