com.aspose.words

Class UserInformation

  • java.lang.Object
    • com.aspose.words.UserInformation
public class UserInformation 
extends java.lang.Object

Specifies information about the user.

Example:

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.setName("John Doe");
userInformation.setInitials("J. D.");
userInformation.setAddress("123 Main Street");
doc.getFieldOptions().setCurrentUser(userInformation);

// Insert fields that reference our user information
Assert.assertEquals(userInformation.getName(), builder.insertField(" USERNAME ").getResult());
Assert.assertEquals(userInformation.getInitials(), builder.insertField(" USERINITIALS ").getResult());
Assert.assertEquals(userInformation.getAddress(), builder.insertField(" USERADDRESS ").getResult());

// The field options object also has a static default user value that fields from many documents can refer to
UserInformation.getDefaultUser().setName("Default User");
UserInformation.getDefaultUser().setInitials("D. U.");
UserInformation.getDefaultUser().setAddress("One Microsoft Way");
doc.getFieldOptions().setCurrentUser(UserInformation.getDefaultUser());

Assert.assertEquals(builder.insertField(" USERNAME ").getResult(), "Default User");
Assert.assertEquals(builder.insertField(" USERINITIALS ").getResult(), "D. U.");
Assert.assertEquals(builder.insertField(" USERADDRESS ").getResult(), "One Microsoft Way");

Constructor Summary
 
Property Getters/Setters Summary
java.lang.StringgetAddress()
void
setAddress(java.lang.Stringvalue)
           Gets or sets the user's postal address.
static UserInformationgetDefaultUser()
Default user information.
java.lang.StringgetInitials()
void
setInitials(java.lang.Stringvalue)
           Gets or sets the user's initials.
java.lang.StringgetName()
void
setName(java.lang.Stringvalue)
           Gets or sets the user's name.
 

    • Constructor Detail

      • UserInformation

        public UserInformation()
    • Property Getters/Setters Detail

      • getAddress/setAddress

        public java.lang.String getAddress() / public void setAddress(java.lang.String value)
        
        Gets or sets the user's postal address.

        Example:

        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.setName("John Doe");
        userInformation.setInitials("J. D.");
        userInformation.setAddress("123 Main Street");
        doc.getFieldOptions().setCurrentUser(userInformation);
        
        // Insert fields that reference our user information
        Assert.assertEquals(userInformation.getName(), builder.insertField(" USERNAME ").getResult());
        Assert.assertEquals(userInformation.getInitials(), builder.insertField(" USERINITIALS ").getResult());
        Assert.assertEquals(userInformation.getAddress(), builder.insertField(" USERADDRESS ").getResult());
        
        // The field options object also has a static default user value that fields from many documents can refer to
        UserInformation.getDefaultUser().setName("Default User");
        UserInformation.getDefaultUser().setInitials("D. U.");
        UserInformation.getDefaultUser().setAddress("One Microsoft Way");
        doc.getFieldOptions().setCurrentUser(UserInformation.getDefaultUser());
        
        Assert.assertEquals(builder.insertField(" USERNAME ").getResult(), "Default User");
        Assert.assertEquals(builder.insertField(" USERINITIALS ").getResult(), "D. U.");
        Assert.assertEquals(builder.insertField(" USERADDRESS ").getResult(), "One Microsoft Way");
      • getDefaultUser

        public static UserInformation getDefaultUser()
        
        Default user information. Use the FieldOptions.CurrentUser property to specify user information for single document.

        Example:

        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.setName("John Doe");
        userInformation.setInitials("J. D.");
        userInformation.setAddress("123 Main Street");
        doc.getFieldOptions().setCurrentUser(userInformation);
        
        // Insert fields that reference our user information
        Assert.assertEquals(userInformation.getName(), builder.insertField(" USERNAME ").getResult());
        Assert.assertEquals(userInformation.getInitials(), builder.insertField(" USERINITIALS ").getResult());
        Assert.assertEquals(userInformation.getAddress(), builder.insertField(" USERADDRESS ").getResult());
        
        // The field options object also has a static default user value that fields from many documents can refer to
        UserInformation.getDefaultUser().setName("Default User");
        UserInformation.getDefaultUser().setInitials("D. U.");
        UserInformation.getDefaultUser().setAddress("One Microsoft Way");
        doc.getFieldOptions().setCurrentUser(UserInformation.getDefaultUser());
        
        Assert.assertEquals(builder.insertField(" USERNAME ").getResult(), "Default User");
        Assert.assertEquals(builder.insertField(" USERINITIALS ").getResult(), "D. U.");
        Assert.assertEquals(builder.insertField(" USERADDRESS ").getResult(), "One Microsoft Way");
      • getInitials/setInitials

        public java.lang.String getInitials() / public void setInitials(java.lang.String value)
        
        Gets or sets the user's initials.

        Example:

        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.setName("John Doe");
        userInformation.setInitials("J. D.");
        userInformation.setAddress("123 Main Street");
        doc.getFieldOptions().setCurrentUser(userInformation);
        
        // Insert fields that reference our user information
        Assert.assertEquals(userInformation.getName(), builder.insertField(" USERNAME ").getResult());
        Assert.assertEquals(userInformation.getInitials(), builder.insertField(" USERINITIALS ").getResult());
        Assert.assertEquals(userInformation.getAddress(), builder.insertField(" USERADDRESS ").getResult());
        
        // The field options object also has a static default user value that fields from many documents can refer to
        UserInformation.getDefaultUser().setName("Default User");
        UserInformation.getDefaultUser().setInitials("D. U.");
        UserInformation.getDefaultUser().setAddress("One Microsoft Way");
        doc.getFieldOptions().setCurrentUser(UserInformation.getDefaultUser());
        
        Assert.assertEquals(builder.insertField(" USERNAME ").getResult(), "Default User");
        Assert.assertEquals(builder.insertField(" USERINITIALS ").getResult(), "D. U.");
        Assert.assertEquals(builder.insertField(" USERADDRESS ").getResult(), "One Microsoft Way");
      • getName/setName

        public java.lang.String getName() / public void setName(java.lang.String value)
        
        Gets or sets the user's name.

        Example:

        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.setName("John Doe");
        userInformation.setInitials("J. D.");
        userInformation.setAddress("123 Main Street");
        doc.getFieldOptions().setCurrentUser(userInformation);
        
        // Insert fields that reference our user information
        Assert.assertEquals(userInformation.getName(), builder.insertField(" USERNAME ").getResult());
        Assert.assertEquals(userInformation.getInitials(), builder.insertField(" USERINITIALS ").getResult());
        Assert.assertEquals(userInformation.getAddress(), builder.insertField(" USERADDRESS ").getResult());
        
        // The field options object also has a static default user value that fields from many documents can refer to
        UserInformation.getDefaultUser().setName("Default User");
        UserInformation.getDefaultUser().setInitials("D. U.");
        UserInformation.getDefaultUser().setAddress("One Microsoft Way");
        doc.getFieldOptions().setCurrentUser(UserInformation.getDefaultUser());
        
        Assert.assertEquals(builder.insertField(" USERNAME ").getResult(), "Default User");
        Assert.assertEquals(builder.insertField(" USERINITIALS ").getResult(), "D. U.");
        Assert.assertEquals(builder.insertField(" USERADDRESS ").getResult(), "One Microsoft Way");