UserInformation Class

Specifies information about the user.

Inheritance Hierarchy

SystemObject
  Aspose.Words.FieldsUserInformation

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

Syntax

public class UserInformation

The UserInformation type exposes the following members.

Constructors

  NameDescription
Public methodUserInformation
Initializes a new instance of the UserInformation class

Properties

  NameDescription
Public propertyCode exampleAddress
Gets or sets the user's postal address.
Public propertyStatic memberCode exampleDefaultUser
Default user information.
Public propertyCode exampleInitials
Gets or sets the user's initials.
Public propertyCode exampleName
Gets or sets the user's name.

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 set user details and display them with fields.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Set user information
UserInformation userInformation = new UserInformation();
userInformation.Name = "John Doe";
userInformation.Initials = "J. D.";
userInformation.Address = "123 Main Street";
doc.FieldOptions.CurrentUser = userInformation;

// Insert fields that reference our user information
Assert.AreEqual(userInformation.Name, builder.InsertField(" USERNAME ").Result);
Assert.AreEqual(userInformation.Initials, builder.InsertField(" USERINITIALS ").Result);
Assert.AreEqual(userInformation.Address, builder.InsertField(" USERADDRESS ").Result);

// The field options object also has a static default user value that fields from many documents can refer to
UserInformation.DefaultUser.Name = "Default User";
UserInformation.DefaultUser.Initials = "D. U.";
UserInformation.DefaultUser.Address = "One Microsoft Way";
doc.FieldOptions.CurrentUser = UserInformation.DefaultUser;

Assert.AreEqual("Default User", builder.InsertField(" USERNAME ").Result);
Assert.AreEqual("D. U.", builder.InsertField(" USERINITIALS ").Result);
Assert.AreEqual("One Microsoft Way", builder.InsertField(" USERADDRESS ").Result);

doc.UpdateFields();
doc.Save(ArtifactsDir + "FieldOptions.FieldOptionsCurrentUser.docx");

See Also