We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extracting Footer Text/Contents


I’ve been looking through a few posts trying to narrow down what I’m looking/hoping to achieve and I’d be grateful for some clarification on the matter.

Currently I’m trying to extract the contents of a documents footer so that it can be stored and used at a later date. I’ve been able to insert footers using the document builder in the past and while reading round I’ve seen several posts relating to the Document Visitor.

Initially it mentioned having to create a class that was derived from an interface and then with further reading, I saw that this was no longer the case and that there was now a prebuilt class to remove the need for some overriding to take place. When trying this it was returning numerous issues that I’m currently trying to work through to see if I can reach a resolution myself.

Is there any documentation of simply extracting the text of the footer from a specified document? Formatting preservation isn’t 100% necessary, but if there are any extensions that can enable this it would be hugely helpful.

Thanks in advance for any assistance!

Hi Jak,

Thanks for your inquiry. Please try executing the following simple code if you just want to extract text from footer:

HeaderFooter fp = doc.FirstSection.HeadersFooters[HeaderFooterType.FooterPrimary];
string text = fp.ToString(SaveFormat.Text);

Please also refer to the following article which outlines how to extract content from any part of the document:

I hope, this helps.

Best regards,

Hi Awais,

Thanks for that, I’ll go and give it a go, thanks for the help!

Hi Awais,

The code works perfectly, thanks for your help with it!

Just so I’m understanding this correctly, the link you refer to in your reply, will this preserve any formatting and images that might be present in the footer node for example or will I need to combine several approaches to extract a fully formatted footer?

I’ve been able to extract images using the shapes approach and just wondering if I would need to use that in conjunction with this or if I can use the nodes to extract the footer in some preserved form?


Hi Jak,

Thanks for your inquiry. Yes, this will preserve formatting. You just need to determine where the extraction of the content is to begin inside the footer and to end at i.e. the start node and the end node. Every element (text, table, images etc) inside this range will be extracted including the formatting they may have.

Best regards,