FieldAdvance Class
Implements the ADVANCE field.
Inheritance Hierarchy
SystemObject
  Aspose.Words.FieldsField
    Aspose.Words.FieldsFieldAdvance

Namespace: Aspose.Words.Fields
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public class FieldAdvance : Field

The FieldAdvance type exposes the following members.

Constructors
  NameDescription
Public methodFieldAdvance
Initializes a new instance of the FieldAdvance class
Properties
  NameDescription
Public propertyCode exampleDisplayResult
Gets the text that represents the displayed field result.
(Inherited from Field.)
Public propertyCode exampleDownOffset
Gets or sets the number of points by which the text that follows the field should be moved down.
Public propertyCode exampleEnd
Gets the node that represents the field end.
(Inherited from Field.)
Public propertyCode exampleFormat
Gets a FieldFormat object that provides typed access to field's formatting.
(Inherited from Field.)
Public propertyCode exampleHorizontalPosition
Gets or 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.
Public propertyCode exampleIsDirty
Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
(Inherited from Field.)
Public propertyCode exampleIsLocked
Gets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field.)
Public propertyCode exampleLeftOffset
Gets or sets the number of points by which the text that follows the field should be moved left.
Public propertyCode exampleLocaleId
Gets or sets the LCID of the field.
(Inherited from Field.)
Public propertyCode exampleResult
Gets or sets text that is between the field separator and field end.
(Inherited from Field.)
Public propertyCode exampleRightOffset
Gets or sets the number of points by which the text that follows the field should be moved right.
Public propertyCode exampleSeparator
Gets the node that represents the field separator. Can be null.
(Inherited from Field.)
Public propertyCode exampleStart
Gets the node that represents the start of the field.
(Inherited from Field.)
Public propertyCode exampleType
Gets the Microsoft Word field type.
(Inherited from Field.)
Public propertyCode exampleUpOffset
Gets or sets the number of points by which the text that follows the field should be moved up.
Public propertyCode exampleVerticalPosition
Gets or sets the number of points by which the text that follows the field should be moved vertically from the top edge of the page.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetFieldCode
Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included.
(Inherited from Field.)
Public methodCode exampleGetFieldCode(Boolean)
Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodNeedStoreOldResultNodes (Inherited from Field.)
Public methodCode exampleRemove
Removes the field from the document. Returns a node right after the field. If the field's end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null.
(Inherited from Field.)
Public methodToString (Inherited from Object.)
Public methodCode exampleUnlink
Performs the field unlink.
(Inherited from Field.)
Public methodCode exampleUpdate
Performs the field update. Throws if the field is being updated already.
(Inherited from Field.)
Public methodCode exampleUpdate(Boolean)
Performs a field update. Throws if the field is being updated already.
(Inherited from Field.)
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.");
// Create an advance field using document builder
FieldAdvance field = (FieldAdvance)builder.InsertField(FieldType.FieldAdvance, true);

builder.Write("This text is moved up and to the right.");

Assert.AreEqual(FieldType.FieldAdvance, field.Type);
Assert.AreEqual(" ADVANCE ", field.GetFieldCode());
// The second text that the builder added will now be moved
field.RightOffset = "5";
field.UpOffset = "5";

Assert.AreEqual(" ADVANCE  \\r 5 \\u 5", field.GetFieldCode());
// If we want to move text in the other direction, and try do that by using negative values for the above field members, we will get an error in our document
// Instead, we need to specify a positive value for the opposite respective field directional variable
field = (FieldAdvance)builder.InsertField(FieldType.FieldAdvance, true);
field.DownOffset = "5";
field.LeftOffset = "100";

Assert.AreEqual(" ADVANCE  \\d 5 \\l 100", field.GetFieldCode());
// We are still on one paragraph
Assert.AreEqual(1, doc.FirstSection.Body.Paragraphs.Count);
// Since we're setting horizontal and vertical positions next, we need to end the paragraph so the previous line does not get moved with the next one
builder.Writeln("This text is moved down and to the left, overlapping the previous text.");
// This time we can also use negative values 
field = (FieldAdvance)builder.InsertField(FieldType.FieldAdvance, true);
field.HorizontalPosition = "-100";
field.VerticalPosition = "200";

Assert.AreEqual(" ADVANCE  \\x -100 \\y 200", field.GetFieldCode());

builder.Write("This text is in a custom position.");

doc.Save(ArtifactsDir + "Field.Advance.docx");
See Also