Remove Fields
Contents
[
Hide
]
Sometimes it is necessary to remove a field from a document. This may occur when it needs to be replaced with a different field type or when the field is no longer needed in the document. For example the TOC field when saving to HTML.
To remove a field inserted into a document using DocumentBuilder.InsertField, use the returned Field object, which provides a convenient Remove method for easily removing the field from the document.
The following code example shows how to remove a field from the document:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(MyDir + "Various fields.docx"); | |
Field field = doc.Range.Fields[0]; | |
field.Remove(); |
You can download the sample file of this example from Aspose.Words GitHub.