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

Free Support Forum - aspose.com

Footnote id

Can you tell me how to retrieve footnote id in aspose?
If we save word document as XML, I can see id associated with footnote field. But this id is not coming with aspose API.

<w:footnoteReference w:id="1"/>

Its really required for us to create unique references and comparison in our utility.

Thanks
Snehal

@snehalghute You are right, there is no public API to get footnote id, because it is not stored in the Aspose.Words Document Object Model. The id attribute is used upon reading to associate the footnoteReference with the appropriate footnote from the footnotes.xml. Upon writing the document to DOCX, the ids are generated on the fly. So if, for example, there are 3 footnotes in your document and you remove the second one in the output document you will get 1 and 2 ids of the remaining footnotes. MS Word behaves the same way. So footnote id is unique within the document, but is not guaranteed to be be the same upon the document lifecycle.

If your requirement is to identify nodes within the same document, you can consider using Node.CustomNodeId property. But you should note, the specified value is not saved to an output file and exists only during the node lifetime.

I specifically want to identify footnotes from one of structureddocument tag. Then I retrieve footnotes from whole word document. From all footnotes, need to identify which are footnotes present in earlier structureddocument tag.

Is there any support for this?

Thanks
Snehal

@snehalghute You can get footnotes from SDT using code like this:

Document doc = new Document("C:\\Temp\\in.docx");

// Get some SDT
StructuredDocumentTag sdt = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

// Get footnotes within SDT.
NodeCollection footnotes = sdt.GetChildNodes(NodeType.Footnote, true);

Then you can either put the footnotes in the collection and then process them or mark them with Node.CustomNodeId property to identify them later.

Thank you for solution. Its working fine.

1 Like