public class FieldTemplate extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Retrieves the file name of the template used by the current document.
Examples:
Shows how to use a TEMPLATE field to display the local file system location of a document's template.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can set a template name using by the fields. This property is used when the "doc.AttachedTemplate" is empty.
// If this property is empty the default template file name "Normal.dotm" is used.
doc.getFieldOptions().setTemplateName("");
FieldTemplate field = (FieldTemplate) builder.insertField(FieldType.FIELD_TEMPLATE, false);
Assert.assertEquals(field.getFieldCode(), " TEMPLATE ");
builder.writeln();
field = (FieldTemplate) builder.insertField(FieldType.FIELD_TEMPLATE, false);
field.setIncludeFullPath(true);
Assert.assertEquals(field.getFieldCode(), " TEMPLATE \\p");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TEMPLATE.docx");
| Modifier and Type | Method and Description |
|---|---|
boolean |
getIncludeFullPath()
Gets whether to include the full file path name.
|
int |
getSwitchType(java.lang.String switchName) |
void |
setIncludeFullPath(boolean value)
Sets whether to include the full file path name.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic boolean getIncludeFullPath()
Examples:
Shows how to use a TEMPLATE field to display the local file system location of a document's template.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can set a template name using by the fields. This property is used when the "doc.AttachedTemplate" is empty.
// If this property is empty the default template file name "Normal.dotm" is used.
doc.getFieldOptions().setTemplateName("");
FieldTemplate field = (FieldTemplate) builder.insertField(FieldType.FIELD_TEMPLATE, false);
Assert.assertEquals(field.getFieldCode(), " TEMPLATE ");
builder.writeln();
field = (FieldTemplate) builder.insertField(FieldType.FIELD_TEMPLATE, false);
field.setIncludeFullPath(true);
Assert.assertEquals(field.getFieldCode(), " TEMPLATE \\p");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TEMPLATE.docx");
public void setIncludeFullPath(boolean value)
throws java.lang.Exception
Examples:
Shows how to use a TEMPLATE field to display the local file system location of a document's template.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can set a template name using by the fields. This property is used when the "doc.AttachedTemplate" is empty.
// If this property is empty the default template file name "Normal.dotm" is used.
doc.getFieldOptions().setTemplateName("");
FieldTemplate field = (FieldTemplate) builder.insertField(FieldType.FIELD_TEMPLATE, false);
Assert.assertEquals(field.getFieldCode(), " TEMPLATE ");
builder.writeln();
field = (FieldTemplate) builder.insertField(FieldType.FIELD_TEMPLATE, false);
field.setIncludeFullPath(true);
Assert.assertEquals(field.getFieldCode(), " TEMPLATE \\p");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.TEMPLATE.docx");
value - Whether to include the full file path name.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)