public class UserInformation
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a UserInformation object and set it as the data source for fields that display user information.
UserInformation userInformation = new UserInformation();
userInformation.setName("John Doe");
userInformation.setInitials("J. D.");
userInformation.setAddress("123 Main Street");
doc.getFieldOptions().setCurrentUser(userInformation);
// Insert USERNAME, USERINITIALS, and USERADDRESS fields, which display values of
// the respective properties of the UserInformation object that we have created above.
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 that fields from all 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("Default User", builder.insertField(" USERNAME ").getResult());
Assert.assertEquals("D. U.", builder.insertField(" USERINITIALS ").getResult());
Assert.assertEquals("One Microsoft Way", builder.insertField(" USERADDRESS ").getResult());
doc.updateFields();
doc.save(getArtifactsDir() + "FieldOptions.CurrentUser.docx");
Constructor Summary |
---|
Property Getters/Setters Summary | ||
---|---|---|
java.lang.String | getAddress() | |
void | setAddress(java.lang.Stringvalue) | |
Gets or sets the user's postal address. | ||
static UserInformation | getDefaultUser() | |
Default user information.
|
||
java.lang.String | getInitials() | |
void | setInitials(java.lang.Stringvalue) | |
Gets or sets the user's initials. | ||
java.lang.String | getName() | |
void | setName(java.lang.Stringvalue) | |
Gets or sets the user's name. |
public java.lang.String getAddress() / public void setAddress(java.lang.String value)
Example:
Shows how to set user details, and display them using fields.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a UserInformation object and set it as the data source for fields that display user information. UserInformation userInformation = new UserInformation(); userInformation.setName("John Doe"); userInformation.setInitials("J. D."); userInformation.setAddress("123 Main Street"); doc.getFieldOptions().setCurrentUser(userInformation); // Insert USERNAME, USERINITIALS, and USERADDRESS fields, which display values of // the respective properties of the UserInformation object that we have created above. 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 that fields from all 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("Default User", builder.insertField(" USERNAME ").getResult()); Assert.assertEquals("D. U.", builder.insertField(" USERINITIALS ").getResult()); Assert.assertEquals("One Microsoft Way", builder.insertField(" USERADDRESS ").getResult()); doc.updateFields(); doc.save(getArtifactsDir() + "FieldOptions.CurrentUser.docx");
public static UserInformation getDefaultUser()
Example:
Shows how to set user details, and display them using fields.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a UserInformation object and set it as the data source for fields that display user information. UserInformation userInformation = new UserInformation(); userInformation.setName("John Doe"); userInformation.setInitials("J. D."); userInformation.setAddress("123 Main Street"); doc.getFieldOptions().setCurrentUser(userInformation); // Insert USERNAME, USERINITIALS, and USERADDRESS fields, which display values of // the respective properties of the UserInformation object that we have created above. 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 that fields from all 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("Default User", builder.insertField(" USERNAME ").getResult()); Assert.assertEquals("D. U.", builder.insertField(" USERINITIALS ").getResult()); Assert.assertEquals("One Microsoft Way", builder.insertField(" USERADDRESS ").getResult()); doc.updateFields(); doc.save(getArtifactsDir() + "FieldOptions.CurrentUser.docx");
public java.lang.String getInitials() / public void setInitials(java.lang.String value)
Example:
Shows how to set user details, and display them using fields.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a UserInformation object and set it as the data source for fields that display user information. UserInformation userInformation = new UserInformation(); userInformation.setName("John Doe"); userInformation.setInitials("J. D."); userInformation.setAddress("123 Main Street"); doc.getFieldOptions().setCurrentUser(userInformation); // Insert USERNAME, USERINITIALS, and USERADDRESS fields, which display values of // the respective properties of the UserInformation object that we have created above. 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 that fields from all 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("Default User", builder.insertField(" USERNAME ").getResult()); Assert.assertEquals("D. U.", builder.insertField(" USERINITIALS ").getResult()); Assert.assertEquals("One Microsoft Way", builder.insertField(" USERADDRESS ").getResult()); doc.updateFields(); doc.save(getArtifactsDir() + "FieldOptions.CurrentUser.docx");
public java.lang.String getName() / public void setName(java.lang.String value)
Example:
Shows how to set user details, and display them using fields.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Create a UserInformation object and set it as the data source for fields that display user information. UserInformation userInformation = new UserInformation(); userInformation.setName("John Doe"); userInformation.setInitials("J. D."); userInformation.setAddress("123 Main Street"); doc.getFieldOptions().setCurrentUser(userInformation); // Insert USERNAME, USERINITIALS, and USERADDRESS fields, which display values of // the respective properties of the UserInformation object that we have created above. 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 that fields from all 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("Default User", builder.insertField(" USERNAME ").getResult()); Assert.assertEquals("D. U.", builder.insertField(" USERINITIALS ").getResult()); Assert.assertEquals("One Microsoft Way", builder.insertField(" USERADDRESS ").getResult()); doc.updateFields(); doc.save(getArtifactsDir() + "FieldOptions.CurrentUser.docx");