Hi
I am using below code to get all the paragraphs within the document.
paragraphs = CurrentSourceDocument.GetChildNodes(NodeType.Paragraph, True).ToArray()
but the problem is it also include the paragraphs that are within cells of a table.
Can you please help me in getting only normal paragraphs(i.e.exclude paragraphs inside tables)
Thanks
Timothy delixus
This message was posted using Page2Forum from Aspose.Words for .NET - Documentation
Hello
Thanks for your request. You can try using the following code:
Document doc = new Document("C:\\Temp\\in.docx");
foreach(Paragraph par in doc.GetChildNodes(NodeType.Paragraph, true))
{
if (par.GetAncestor(NodeType.Cell) != null)
Console.WriteLine(par.GetText() + " - IsInsideTable");
}
Best regards,
Hi
It worked Thanks.
Can you please help me to exclude header and footer paragraphs also.
Thanks
AndreyN
September 1, 2011, 9:37am
4
Hello
Thanks for your request. In this case you should use the following code:
Document doc = new Document("C:\\Temp\\in.docx");
foreach(Paragraph par in doc.GetChildNodes(NodeType.Paragraph, true))
{
if (par.GetAncestor(NodeType.HeaderFooter) != null)
Console.WriteLine(par.GetText() + " - IsInsideHeaderFooter");
}
Best regards,
Hi,
Is their some way to exclude header and footers.
Currently i am using below code:
paragraphs = CurrentSourceDocument.GetChildNodes(NodeType.Paragraph, True).ToArray()
I dont want to loop again and check if its header or footer node then remove.
Thanks
AndreyN
September 12, 2011, 6:29am
6
Hello
Thanks for your request. The only way to exclude HeaderFooter paragraphs from a collection is loop through this collection and remove unneeded paragraphs.
Could you please also describe your main requirement, maybe I will find the other way to achieve what you need.
Best regards,