FieldOptions Class

Represents options to control field handling in a document.
Inheritance Hierarchy
SystemObject
  Aspose.Words.FieldsFieldOptions

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.5
Syntax
public class FieldOptions

The FieldOptions type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleBarcodeGenerator
Gets or set custom barcode generator.
Public propertyCode exampleBuiltInTemplatesPaths
Gets or sets paths of MS Word built-in templates.
Public propertyCode exampleCurrentUser
Gets or sets the current user information.
Public propertyCode exampleCustomTocStyleSeparator
Gets or sets custom style separator for the \t switch in TOC field.
Public propertyCode exampleDefaultDocumentAuthor
Gets or sets default document author's name. If author's name is already specified in built-in document properties, this option is not considered.
Public propertyCode exampleFieldUpdateCultureProvider
Gets or sets a provider that returns a culture object specific for each particular field.
Public propertyCode exampleFieldUpdateCultureSource
Specifies what culture to use to format the field result.
Public propertyCode exampleFileName
Gets or sets the file name of the document.
Public propertyCode exampleIsBidiTextSupportedOnUpdate
Gets or sets the value indicating whether bidirectional text is fully supported during field update or not.
Public propertyCode exampleLegacyNumberFormat
Gets or sets the value indicating whether legacy (early than AW 13.10) number format for fields is enabled or not.
Public propertyCode examplePreProcessCulture
Gets or sets the culture to preprocess field values.
Public propertyCode exampleResultFormatter
Allows to control how the field result is formatted.
Public propertyCode exampleToaCategories
Gets or sets the table of authorities categories.
Public propertyCode exampleUseInvariantCultureNumberFormat
Gets or sets the value indicating that number format is parsed using invariant culture or not
Public propertyCode exampleUserPromptRespondent
Gets or sets the respondent to user prompts during field update.
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to specify where the culture used for date formatting during field update and mail merge is chosen from.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert two merge fields with German locale
builder.Font.LocaleId = 1031;
builder.InsertField("MERGEFIELD Date1 \\@ \"dddd, d MMMM yyyy\"");
builder.Write(" - ");
builder.InsertField("MERGEFIELD Date2 \\@ \"dddd, d MMMM yyyy\"");

// Store the current culture in a variable and explicitly set it to US English
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

// Execute a mail merge for the first MERGEFIELD using the current culture (US English) for date formatting
doc.MailMerge.Execute(new[] { "Date1" }, new object[] { new DateTime(2020, 1, 01) });

// Execute a mail merge for the second MERGEFIELD using the field's culture (German) for date formatting
doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
doc.MailMerge.Execute(new[] { "Date2" }, new object[] { new DateTime(2020, 1, 01) });

// The first MERGEFIELD has received a date formatted in English, while the second one is in German
Assert.AreEqual("Wednesday, 1 January 2020 - Mittwoch, 1 Januar 2020", doc.Range.Text.Trim());

// Restore the original culture
Thread.CurrentThread.CurrentCulture = currentCulture;
See Also