Hi,
I am using the following code to locate image in a table.
using (var document = WordprocessingDocument.Open(fileName, true)) {
var docPart = document.MainDocumentPart;
var doc = docPart.Document;
DocumentFormat.OpenXml.Wordprocessing.Table myTable = doc.Body.Descendants<DocumentFormat.OpenXml.Wordprocessing.Table>().First();
List<Paragraph> paras = myTable.Descendants<DocumentFormat.OpenXml.Wordprocessing.Paragraph>().ToList();
foreach (Paragraph p in paras) {
string d = p.InnerXml;
if (d.Contains("w:drawing")) {
Console.WriteLine("this paragraph contains image");
//Need Code to extract the image inside the <w:drawing> element
}
else Console.WriteLine("this paragraph does not contains image");
}
}
Is this the right way.
One more thing: I want to extract the image in that paragraph whenever the code finds one
Thanks in advance.