Hi ,
I am using DocumentFormat.OpenXml for reading content from .docX file in asp.net c#.
I have issue with paragraph.InnerText it is given " TOC \\o \"1-2\" \\h \\z \\u 1.Introduction PAGEREF _Toc294041589 \\h 4" but I need only content without heading. how I can achieve it.
My Code
Package wordPackage = Package.Open(filePath, FileMode.Open, FileAccess.Read);
using (WordprocessingDocument wordDocument = WordprocessingDocument.Open(wordPackage))
{
StringBuilder stringBuilder = new StringBuilder();
IEnumerable<Paragraph> paragraphs = wordDocument.MainDocumentPart.Document.Body.Elements<Paragraph>();
foreach (var paragraph in paragraphs)
{
Console.WriteLine(paragraph.InnerText);
stringBuilder.Append(paragraph.InnerText + "\r\n");
}
string content = stringBuilder.ToString();
}

