public class FieldGoToButton extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Inserts a jump command, such that when it is activated, the insertion point of the document is moved to the specified location.
Examples:
Shows to insert a GOTOBUTTON field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add a GOTOBUTTON field. When we double-click this field in Microsoft Word,
// it will take the text cursor to the bookmark whose name the Location property references.
FieldGoToButton field = (FieldGoToButton) builder.insertField(FieldType.FIELD_GO_TO_BUTTON, true);
field.setDisplayText("My Button");
field.setLocation("MyBookmark");
Assert.assertEquals(field.getFieldCode(), " GOTOBUTTON MyBookmark My Button");
// Insert a valid bookmark for the field to reference.
builder.insertBreak(BreakType.PAGE_BREAK);
builder.startBookmark(field.getLocation());
builder.writeln("Bookmark text contents.");
builder.endBookmark(field.getLocation());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.GOTOBUTTON.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDisplayText()
Gets the text of the "button" that appears in the document, such that it can be selected to activate the jump.
|
java.lang.String |
getLocation()
Gets the name of a bookmark, a page number, or some other item to jump to.
|
void |
setDisplayText(java.lang.String value)
Sets the text of the "button" that appears in the document, such that it can be selected to activate the jump.
|
void |
setLocation(java.lang.String value)
Sets the name of a bookmark, a page number, or some other item to jump to.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getLocation()
Examples:
Shows to insert a GOTOBUTTON field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add a GOTOBUTTON field. When we double-click this field in Microsoft Word,
// it will take the text cursor to the bookmark whose name the Location property references.
FieldGoToButton field = (FieldGoToButton) builder.insertField(FieldType.FIELD_GO_TO_BUTTON, true);
field.setDisplayText("My Button");
field.setLocation("MyBookmark");
Assert.assertEquals(field.getFieldCode(), " GOTOBUTTON MyBookmark My Button");
// Insert a valid bookmark for the field to reference.
builder.insertBreak(BreakType.PAGE_BREAK);
builder.startBookmark(field.getLocation());
builder.writeln("Bookmark text contents.");
builder.endBookmark(field.getLocation());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.GOTOBUTTON.docx");
public void setLocation(java.lang.String value)
throws java.lang.Exception
Examples:
Shows to insert a GOTOBUTTON field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add a GOTOBUTTON field. When we double-click this field in Microsoft Word,
// it will take the text cursor to the bookmark whose name the Location property references.
FieldGoToButton field = (FieldGoToButton) builder.insertField(FieldType.FIELD_GO_TO_BUTTON, true);
field.setDisplayText("My Button");
field.setLocation("MyBookmark");
Assert.assertEquals(field.getFieldCode(), " GOTOBUTTON MyBookmark My Button");
// Insert a valid bookmark for the field to reference.
builder.insertBreak(BreakType.PAGE_BREAK);
builder.startBookmark(field.getLocation());
builder.writeln("Bookmark text contents.");
builder.endBookmark(field.getLocation());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.GOTOBUTTON.docx");
value - The name of a bookmark, a page number, or some other item to jump to.java.lang.Exceptionpublic java.lang.String getDisplayText()
Examples:
Shows to insert a GOTOBUTTON field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add a GOTOBUTTON field. When we double-click this field in Microsoft Word,
// it will take the text cursor to the bookmark whose name the Location property references.
FieldGoToButton field = (FieldGoToButton) builder.insertField(FieldType.FIELD_GO_TO_BUTTON, true);
field.setDisplayText("My Button");
field.setLocation("MyBookmark");
Assert.assertEquals(field.getFieldCode(), " GOTOBUTTON MyBookmark My Button");
// Insert a valid bookmark for the field to reference.
builder.insertBreak(BreakType.PAGE_BREAK);
builder.startBookmark(field.getLocation());
builder.writeln("Bookmark text contents.");
builder.endBookmark(field.getLocation());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.GOTOBUTTON.docx");
public void setDisplayText(java.lang.String value)
throws java.lang.Exception
Examples:
Shows to insert a GOTOBUTTON field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add a GOTOBUTTON field. When we double-click this field in Microsoft Word,
// it will take the text cursor to the bookmark whose name the Location property references.
FieldGoToButton field = (FieldGoToButton) builder.insertField(FieldType.FIELD_GO_TO_BUTTON, true);
field.setDisplayText("My Button");
field.setLocation("MyBookmark");
Assert.assertEquals(field.getFieldCode(), " GOTOBUTTON MyBookmark My Button");
// Insert a valid bookmark for the field to reference.
builder.insertBreak(BreakType.PAGE_BREAK);
builder.startBookmark(field.getLocation());
builder.writeln("Bookmark text contents.");
builder.endBookmark(field.getLocation());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.GOTOBUTTON.docx");
value - The text of the "button" that appears in the document, such that it can be selected to activate the jump.java.lang.Exception