public class FieldInclude extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Inserts all or part of the text and graphics contained in another document.
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getBookmarkName()
Gets the name of the bookmark in the document to include.
|
boolean |
getLockFields()
Gets whether to prevent fields in the included document from being updated.
|
java.lang.String |
getNamespaceMappings() |
java.lang.String |
getSourceFullName()
Gets the location of the document.
|
int |
getSourceFullNameArgumentIndex() |
int |
getSwitchType(java.lang.String switchName) |
java.lang.String |
getTextConverter()
Gets the name of the text converter for the format of the included file.
|
java.lang.String |
getXPath() |
java.lang.String |
getXslTransformation() |
void |
setBookmarkName(java.lang.String value)
Sets the name of the bookmark in the document to include.
|
void |
setLockFields(boolean value)
Sets whether to prevent fields in the included document from being updated.
|
void |
setSourceFullName(java.lang.String value)
Sets the location of the document.
|
void |
setTextConverter(java.lang.String value)
Sets the name of the text converter for the format of the included file.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getSourceFullName()
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
public void setSourceFullName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
value - The location of the document.java.lang.Exceptionpublic java.lang.String getBookmarkName()
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
public void setBookmarkName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
value - The name of the bookmark in the document to include.java.lang.Exceptionpublic boolean getLockFields()
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
public void setLockFields(boolean value)
throws java.lang.Exception
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
value - Whether to prevent fields in the included document from being updated.java.lang.Exceptionpublic java.lang.String getTextConverter()
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
public void setTextConverter(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to create an INCLUDE field, and set its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude) builder.insertField(FieldType.FIELD_INCLUDE, true);
field.setSourceFullName(getMyDir() + "Bookmarks.docx");
field.setBookmarkName("MyBookmark1");
field.setLockFields(false);
field.setTextConverter("Microsoft Word");
Assert.assertTrue(field.getFieldCode().matches(" INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\""));
doc.updateFields();
doc.save(getArtifactsDir() + "Field.INCLUDE.docx");
value - The name of the text converter for the format of the included file.java.lang.Exceptionpublic java.lang.String getNamespaceMappings()
public java.lang.String getXPath()
public java.lang.String getXslTransformation()
public int getSourceFullNameArgumentIndex()
public int getSwitchType(java.lang.String switchName)