HasPageNumberSeparator
Contents
[
Hide
]FieldIndex.HasPageNumberSeparator property
Gets a value indicating whether a page number separator is overridden through the field’s code.
public bool HasPageNumberSeparator { get; }
Examples
Shows how to edit the page number separator in an INDEX field.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create an INDEX field which will display an entry for each XE field found in the document.
// Each entry will display the XE field's Text property value on the left side,
// and the number of the page that contains the XE field on the right.
// The INDEX entry will group XE fields with matching values in the "Text" property
// into one entry as opposed to making an entry for each XE field.
FieldIndex index = (FieldIndex)builder.InsertField(FieldType.FieldIndex, true);
// If our INDEX field has an entry for a group of XE fields,
// this entry will display the number of each page that contains an XE field that belongs to this group.
// We can set custom separators to customize the appearance of these page numbers.
index.PageNumberSeparator = ", on page(s) ";
index.PageNumberListSeparator = " & ";
Assert.AreEqual(" INDEX \\e \", on page(s) \" \\l \" & \"", index.GetFieldCode());
Assert.True(index.HasPageNumberSeparator);
// After we insert these XE fields, the INDEX field will display "First entry, on page(s) 2 & 3 & 4".
builder.InsertBreak(BreakType.PageBreak);
FieldXE indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "First entry";
Assert.AreEqual(" XE \"First entry\"", indexEntry.GetFieldCode());
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "First entry";
builder.InsertBreak(BreakType.PageBreak);
indexEntry = (FieldXE)builder.InsertField(FieldType.FieldIndexEntry, true);
indexEntry.Text = "First entry";
doc.UpdatePageLayout();
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.INDEX.XE.PageNumberList.docx");
See Also
- class FieldIndex
- namespace Aspose.Words.Fields
- assembly Aspose.Words