public class FieldKeywords extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Retrieves, and optionally sets, the document's keywords, as recorded in the Keywords property of the built-in document properties.
Examples:
Shows to insert a KEYWORDS field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add some keywords, also referred to as "tags" in File Explorer.
doc.getBuiltInDocumentProperties().setKeywords("Keyword1, Keyword2");
// The KEYWORDS field displays the value of this property.
FieldKeywords field = (FieldKeywords) builder.insertField(FieldType.FIELD_KEYWORD, true);
field.update();
Assert.assertEquals(field.getFieldCode(), " KEYWORDS ");
Assert.assertEquals(field.getResult(), "Keyword1, Keyword2");
// Setting a value for the field's Text property,
// and then updating the field will also overwrite the corresponding built-in property with the new value.
field.setText("OverridingKeyword");
field.update();
Assert.assertEquals(" KEYWORDS OverridingKeyword", field.getFieldCode());
Assert.assertEquals("OverridingKeyword", field.getResult());
Assert.assertEquals("OverridingKeyword", doc.getBuiltInDocumentProperties().getKeywords());
doc.save(getArtifactsDir() + "Field.KEYWORDS.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getText()
Gets the text of the keywords.
|
void |
setText(java.lang.String value)
Sets the text of the keywords.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getText()
Examples:
Shows to insert a KEYWORDS field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add some keywords, also referred to as "tags" in File Explorer.
doc.getBuiltInDocumentProperties().setKeywords("Keyword1, Keyword2");
// The KEYWORDS field displays the value of this property.
FieldKeywords field = (FieldKeywords) builder.insertField(FieldType.FIELD_KEYWORD, true);
field.update();
Assert.assertEquals(field.getFieldCode(), " KEYWORDS ");
Assert.assertEquals(field.getResult(), "Keyword1, Keyword2");
// Setting a value for the field's Text property,
// and then updating the field will also overwrite the corresponding built-in property with the new value.
field.setText("OverridingKeyword");
field.update();
Assert.assertEquals(" KEYWORDS OverridingKeyword", field.getFieldCode());
Assert.assertEquals("OverridingKeyword", field.getResult());
Assert.assertEquals("OverridingKeyword", doc.getBuiltInDocumentProperties().getKeywords());
doc.save(getArtifactsDir() + "Field.KEYWORDS.docx");
public void setText(java.lang.String value)
throws java.lang.Exception
Examples:
Shows to insert a KEYWORDS field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add some keywords, also referred to as "tags" in File Explorer.
doc.getBuiltInDocumentProperties().setKeywords("Keyword1, Keyword2");
// The KEYWORDS field displays the value of this property.
FieldKeywords field = (FieldKeywords) builder.insertField(FieldType.FIELD_KEYWORD, true);
field.update();
Assert.assertEquals(field.getFieldCode(), " KEYWORDS ");
Assert.assertEquals(field.getResult(), "Keyword1, Keyword2");
// Setting a value for the field's Text property,
// and then updating the field will also overwrite the corresponding built-in property with the new value.
field.setText("OverridingKeyword");
field.update();
Assert.assertEquals(" KEYWORDS OverridingKeyword", field.getFieldCode());
Assert.assertEquals("OverridingKeyword", field.getResult());
Assert.assertEquals("OverridingKeyword", doc.getBuiltInDocumentProperties().getKeywords());
doc.save(getArtifactsDir() + "Field.KEYWORDS.docx");
value - The text of the keywords.java.lang.Exception