删除字段
Contents
[
Hide
]
有时需要从文档中删除字段。 当需要替换为不同的字段类型或文档中不再需要该字段时,可能会发生这种情况。 例如保存到HTML时的TOC
字段。
使用DocumentBuilder删除插入到文档中的字段。InsertField,使用返回的Field对象,它提供了一个方便的Remove方法,用于轻松地从文档中删除字段。
下面的代码示例演示如何从文档中删除字段:
This file contains 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-C | |
auto doc = MakeObject<Document>(MyDir + u"Various fields.docx"); | |
SharedPtr<Field> field = doc->get_Range()->get_Fields()->idx_get(0); | |
field->Remove(); |