public class FieldInfo extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Inserts information about a document property.
Examples:
Shows how to work with INFO fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set a value for the "Comments" built-in property and then insert an INFO field to display that property's value.
doc.getBuiltInDocumentProperties().setComments("My comment");
FieldInfo field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.update();
Assert.assertEquals(field.getFieldCode(), " INFO Comments");
Assert.assertEquals(field.getResult(), "My comment");
builder.writeln();
// Setting a value for the field's NewValue property and updating
// the field will also overwrite the corresponding built-in property with the new value.
field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.setNewValue("New comment");
field.update();
Assert.assertEquals(" INFO Comments \"New comment\"", field.getFieldCode());
Assert.assertEquals("New comment", field.getResult());
Assert.assertEquals("New comment", doc.getBuiltInDocumentProperties().getComments());
doc.save(getArtifactsDir() + "Field.INFO.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getInfoType()
Gets the type of the document property to insert.
|
java.lang.String |
getNewValue()
Gets an optional value that updates the property.
|
int |
getSwitchType(java.lang.String switchName) |
void |
setInfoType(java.lang.String value)
Sets the type of the document property to insert.
|
void |
setNewValue(java.lang.String value)
Sets an optional value that updates the property.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getInfoType()
Examples:
Shows how to work with INFO fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set a value for the "Comments" built-in property and then insert an INFO field to display that property's value.
doc.getBuiltInDocumentProperties().setComments("My comment");
FieldInfo field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.update();
Assert.assertEquals(field.getFieldCode(), " INFO Comments");
Assert.assertEquals(field.getResult(), "My comment");
builder.writeln();
// Setting a value for the field's NewValue property and updating
// the field will also overwrite the corresponding built-in property with the new value.
field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.setNewValue("New comment");
field.update();
Assert.assertEquals(" INFO Comments \"New comment\"", field.getFieldCode());
Assert.assertEquals("New comment", field.getResult());
Assert.assertEquals("New comment", doc.getBuiltInDocumentProperties().getComments());
doc.save(getArtifactsDir() + "Field.INFO.docx");
public void setInfoType(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to work with INFO fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set a value for the "Comments" built-in property and then insert an INFO field to display that property's value.
doc.getBuiltInDocumentProperties().setComments("My comment");
FieldInfo field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.update();
Assert.assertEquals(field.getFieldCode(), " INFO Comments");
Assert.assertEquals(field.getResult(), "My comment");
builder.writeln();
// Setting a value for the field's NewValue property and updating
// the field will also overwrite the corresponding built-in property with the new value.
field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.setNewValue("New comment");
field.update();
Assert.assertEquals(" INFO Comments \"New comment\"", field.getFieldCode());
Assert.assertEquals("New comment", field.getResult());
Assert.assertEquals("New comment", doc.getBuiltInDocumentProperties().getComments());
doc.save(getArtifactsDir() + "Field.INFO.docx");
value - The type of the document property to insert.java.lang.Exceptionpublic java.lang.String getNewValue()
Examples:
Shows how to work with INFO fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set a value for the "Comments" built-in property and then insert an INFO field to display that property's value.
doc.getBuiltInDocumentProperties().setComments("My comment");
FieldInfo field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.update();
Assert.assertEquals(field.getFieldCode(), " INFO Comments");
Assert.assertEquals(field.getResult(), "My comment");
builder.writeln();
// Setting a value for the field's NewValue property and updating
// the field will also overwrite the corresponding built-in property with the new value.
field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.setNewValue("New comment");
field.update();
Assert.assertEquals(" INFO Comments \"New comment\"", field.getFieldCode());
Assert.assertEquals("New comment", field.getResult());
Assert.assertEquals("New comment", doc.getBuiltInDocumentProperties().getComments());
doc.save(getArtifactsDir() + "Field.INFO.docx");
public void setNewValue(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to work with INFO fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set a value for the "Comments" built-in property and then insert an INFO field to display that property's value.
doc.getBuiltInDocumentProperties().setComments("My comment");
FieldInfo field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.update();
Assert.assertEquals(field.getFieldCode(), " INFO Comments");
Assert.assertEquals(field.getResult(), "My comment");
builder.writeln();
// Setting a value for the field's NewValue property and updating
// the field will also overwrite the corresponding built-in property with the new value.
field = (FieldInfo) builder.insertField(FieldType.FIELD_INFO, true);
field.setInfoType("Comments");
field.setNewValue("New comment");
field.update();
Assert.assertEquals(" INFO Comments \"New comment\"", field.getFieldCode());
Assert.assertEquals("New comment", field.getResult());
Assert.assertEquals("New comment", doc.getBuiltInDocumentProperties().getComments());
doc.save(getArtifactsDir() + "Field.INFO.docx");
value - An optional value that updates the property.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)