FieldXEPageNumberReplacement Property

Gets or sets text used in place of a page number.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0

Syntax

public string PageNumberReplacement { get; set; }

Property Value

Type: String

Examples

Shows how to define cross references in an INDEX field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create an INDEX field which will display the page locations of XE fields in the document body
FieldIndex index = (FieldIndex)builder.InsertField(FieldType.FieldIndex, true);

// Define a custom separator that is applied if an XE field contains a page number replacement
index.CrossReferenceSeparator = ", see: ";

Assert.AreEqual(" INDEX  \\k \", see: \"", index.GetFieldCode());

// Insert an XE field on page 2
// That page number, together with the field's Text attribute, will show up as a table of contents entry in the INDEX field,
builder.InsertBreak(BreakType.PageBreak);
FieldXE indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Apple";

Assert.AreEqual(" XE  Apple", indexEntry.GetFieldCode());

// Insert another XE field on page 3, and set a value for "PageNumberReplacement"
// In the INDEX field's table, this field will display the value of that attribute after the field's CrossReferenceSeparator instead of the page number
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "Banana";
indexEntry.PageNumberReplacement = "Tropical fruit";

Assert.AreEqual(" XE  Banana \\t \"Tropical fruit\"", indexEntry.GetFieldCode());

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.INDEX.XE.CrossReferenceSeparator.docx");

See Also