Free Support Forum - aspose.com

Is there a way to iterate over the contents pages?

Hi,

Is there a way to pull out all the headings and sub-headings from a contents page using Aspose.Words?

Thanks,

@playstationmasterboyy

Thanks for your inquiry. Yes, you can extract the content from Word document using Aspose.Words. You can check the heading of document using paragraph’s style e.g. “Heading 1”, “Heading 2”.

Please use Paragraph.ParagraphFormat.StyleName property to get the style name of paragraph and get its text using Paragraph.ToString(SaveFormat.Text) method.

If you still face problem, please ZIP and attach your input Word document along with desired output. We will then provide you more information about your query along with code.