删除字段
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-Java | |
Document doc = new Document(getMyDir() + "Various fields.docx"); | |
Field field = doc.getRange().getFields().get(0); | |
field.remove(); |
您可以从以下位置下载此示例的示例文件 Aspose.Words GitHub.