public class FieldAdvance extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Moves the starting point at which the text that lexically follows the field is displayed to the right or left, up or down, or to a specific horizontal or vertical position.
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDownOffset()
Gets the number of points by which the text that follows the field should be moved down.
|
java.lang.String |
getHorizontalPosition()
Gets the number of points by which the text that follows the field should be moved horizontally from the left edge of the column, frame, or text box.
|
java.lang.String |
getLeftOffset()
Gets the number of points by which the text that follows the field should be moved left.
|
java.lang.String |
getRightOffset()
Gets the number of points by which the text that follows the field should be moved right.
|
int |
getSwitchType(java.lang.String switchName) |
java.lang.String |
getUpOffset()
Gets the number of points by which the text that follows the field should be moved up.
|
java.lang.String |
getVerticalPosition()
Gets the number of points by which the text that follows the field should be moved vertically from the top edge of the page.
|
void |
setDownOffset(java.lang.String value)
Sets the number of points by which the text that follows the field should be moved down.
|
void |
setHorizontalPosition(java.lang.String value)
Sets the number of points by which the text that follows the field should be moved horizontally from the left edge of the column, frame, or text box.
|
void |
setLeftOffset(java.lang.String value)
Sets the number of points by which the text that follows the field should be moved left.
|
void |
setRightOffset(java.lang.String value)
Sets the number of points by which the text that follows the field should be moved right.
|
void |
setUpOffset(java.lang.String value)
Sets the number of points by which the text that follows the field should be moved up.
|
void |
setVerticalPosition(java.lang.String value)
Sets the number of points by which the text that follows the field should be moved vertically from the top edge of the page.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getDownOffset()
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
public void setDownOffset(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
value - The number of points by which the text that follows the field should be moved down.java.lang.Exceptionpublic java.lang.String getLeftOffset()
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
public void setLeftOffset(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
value - The number of points by which the text that follows the field should be moved left.java.lang.Exceptionpublic java.lang.String getRightOffset()
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
public void setRightOffset(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
value - The number of points by which the text that follows the field should be moved right.java.lang.Exceptionpublic java.lang.String getUpOffset()
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
public void setUpOffset(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
value - The number of points by which the text that follows the field should be moved up.java.lang.Exceptionpublic java.lang.String getHorizontalPosition()
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
public void setHorizontalPosition(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
value - The number of points by which the text that follows the field should be moved horizontally from the left edge of the column, frame, or text box.java.lang.Exceptionpublic java.lang.String getVerticalPosition()
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
public void setVerticalPosition(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to insert an ADVANCE field, and edit its properties.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This text is in its normal place.");
// Below are two ways of using the ADVANCE field to adjust the position of text that follows it.
// The effects of an ADVANCE field continue to be applied until the paragraph ends,
// or another ADVANCE field updates the offset/coordinate values.
// 1 - Specify a directional offset:
FieldAdvance field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setRightOffset("5");
field.setUpOffset("5");
Assert.assertEquals(" ADVANCE \\r 5 \\u 5", field.getFieldCode());
builder.write("This text will be moved up and to the right.");
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setDownOffset("5");
field.setLeftOffset("100");
Assert.assertEquals(" ADVANCE \\d 5 \\l 100", field.getFieldCode());
builder.writeln("This text is moved down and to the left, overlapping the previous text.");
// 2 - Move text to a position specified by coordinates:
field = (FieldAdvance) builder.insertField(FieldType.FIELD_ADVANCE, true);
field.setHorizontalPosition("-100");
field.setVerticalPosition("200");
Assert.assertEquals(field.getFieldCode(), " ADVANCE \\x -100 \\y 200");
builder.write("This text is in a custom position.");
doc.save(getArtifactsDir() + "Field.ADVANCE.docx");
value - The number of points by which the text that follows the field should be moved vertically from the top edge of the page.java.lang.Exceptionpublic int getSwitchType(java.lang.String switchName)