MailMergeCleanupOptions
Inheritance: java.lang.Object
public class MailMergeCleanupOptions
Specifies options that determine what items are removed during mail merge.
Examples:
Shows how to automatically remove unmerged merge fields during mail merge.
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
Shows how to make sure empty paragraphs that result from merging fields with no data are removed from the document.
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS);
Shows how to instruct the mail merge engine to remove any containing fields from around a merge field during mail merge.
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS);
Shows how to remove whole empty table during mail merge.
DataTable tableCustomers = new DataTable("A");
tableCustomers.getColumns().add("CustomerID");
tableCustomers.getColumns().add("CustomerName");
tableCustomers.getRows().add(new Object[] { 1, "John Doe" });
tableCustomers.getRows().add(new Object[] { 2, "Jane Doe" });
DataSet ds = new DataSet();
ds.getTables().add(tableCustomers);
Document doc = new Document(getMyDir() + "Mail merge tables.docx");
Assert.assertEquals(2, doc.getChildNodes(NodeType.TABLE, true).getCount());
doc.getMailMerge().setMergeDuplicateRegions(false);
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_EMPTY_TABLES | MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS);
doc.getMailMerge().executeWithRegions(ds.getTables().get("A"));
doc.save(getArtifactsDir() + "MailMerge.RemoveEmptyTables.docx");
doc = new Document(getArtifactsDir() + "MailMerge.RemoveEmptyTables.docx");
Assert.assertEquals(1, doc.getChildNodes(NodeType.TABLE, true).getCount());
Fields
Field | Description |
---|---|
NONE | Specifies a default value. |
REMOVE_CONTAINING_FIELDS | Specifies whether fields that contain merge fields (for example, IFs) should be removed from the document if the nested merge fields are removed. |
REMOVE_EMPTY_PARAGRAPHS | Specifies whether paragraphs that contained mail merge fields with no data should be removed from the document. |
REMOVE_EMPTY_TABLES | Specifies whether to remove from the document tables that contain mail merge regions that were removed using either the REMOVE_UNUSED_REGIONS or the REMOVE_EMPTY_TABLE_ROWS option. |
REMOVE_EMPTY_TABLE_ROWS | Specifies whether empty rows that contain mail merge regions should be removed from the document. |
REMOVE_STATIC_FIELDS | Specifies whether static fields should be removed from the document. |
REMOVE_UNUSED_FIELDS | Specifies whether unused merge fields should be removed from the document. |
REMOVE_UNUSED_REGIONS | Specifies whether unused mail merge regions should be removed from the document. |
length |
Methods
NONE
public static int NONE
Specifies a default value.
REMOVE_CONTAINING_FIELDS
public static int REMOVE_CONTAINING_FIELDS
Specifies whether fields that contain merge fields (for example, IFs) should be removed from the document if the nested merge fields are removed.
REMOVE_EMPTY_PARAGRAPHS
public static int REMOVE_EMPTY_PARAGRAPHS
Specifies whether paragraphs that contained mail merge fields with no data should be removed from the document. When this option is set, paragraphs which contain region start and end merge fields which are otherwise empty are also removed.
REMOVE_EMPTY_TABLES
public static int REMOVE_EMPTY_TABLES
Specifies whether to remove from the document tables that contain mail merge regions that were removed using either the REMOVE_UNUSED_REGIONS or the REMOVE_EMPTY_TABLE_ROWS option.
Remarks:
This option applies only to mail merge with regions.
REMOVE_EMPTY_TABLE_ROWS
public static int REMOVE_EMPTY_TABLE_ROWS
Specifies whether empty rows that contain mail merge regions should be removed from the document.
Remarks:
This option applies only to mail merge with regions.
REMOVE_STATIC_FIELDS
public static int REMOVE_STATIC_FIELDS
Specifies whether static fields should be removed from the document. Static fields are fields, which results remain the same upon any document change. Fields, which do not store their results in a document and are calculated on the fly (like FieldType.FIELD_LIST_NUM, FieldType.FIELD_SYMBOL, etc.) are not considered to be static.
Remarks:
Here is the full list of field types, which are not considered to be static:
- FieldType.FIELD_ADVANCE
- FieldType.FIELD_AUTO_NUM
- FieldType.FIELD_AUTO_NUM_LEGAL
- FieldType.FIELD_AUTO_NUM_OUTLINE
- FieldType.FIELD_BARCODE
- FieldType.FIELD_BIDI_OUTLINE
- FieldType.FIELD_DATE
- FieldType.FIELD_DISPLAY_BARCODE
- FieldType.FIELD_MERGE_BARCODE
- FieldType.FIELD_FORM_CHECK_BOX
- FieldType.FIELD_FORM_DROP_DOWN
- FieldType.FIELD_FORMULA
- FieldType.FIELD_GO_TO_BUTTON
- FieldType.FIELD_HYPERLINK
- FieldType.FIELD_INCLUDE_TEXT
- FieldType.FIELD_INDEX_ENTRY
- FieldType.FIELD_LINK
- FieldType.FIELD_LIST_NUM
- FieldType.FIELD_MACRO_BUTTON
- FieldType.FIELD_NOTE_REF
- FieldType.FIELD_NUM_PAGES
- FieldType.FIELD_PAGE
- FieldType.FIELD_PAGE_REF
- FieldType.FIELD_PRINT
- FieldType.FIELD_PRINT_DATE
- FieldType.FIELD_PRIVATE
- FieldType.FIELD_REF_DOC
- FieldType.FIELD_SECTION
- FieldType.FIELD_SECTION_PAGES
- FieldType.FIELD_SYMBOL
- FieldType.FIELD_TIME
- FieldType.FIELD_TOA_ENTRY
- FieldType.FIELD_TOC_ENTRY
REMOVE_UNUSED_FIELDS
public static int REMOVE_UNUSED_FIELDS
Specifies whether unused merge fields should be removed from the document.
REMOVE_UNUSED_REGIONS
public static int REMOVE_UNUSED_REGIONS
Specifies whether unused mail merge regions should be removed from the document.
Remarks:
This option applies only to mail merge with regions.
length
public static int length
fromName(String mailMergeCleanupOptionsName)
public static int fromName(String mailMergeCleanupOptionsName)
Parameters:
Parameter | Type | Description |
---|---|---|
mailMergeCleanupOptionsName | java.lang.String |
Returns: int
fromNames(Set mailMergeCleanupOptionsNames)
public static int fromNames(Set mailMergeCleanupOptionsNames)
Parameters:
Parameter | Type | Description |
---|---|---|
mailMergeCleanupOptionsNames | java.util.Set |
Returns: int
getName(int mailMergeCleanupOptions)
public static String getName(int mailMergeCleanupOptions)
Parameters:
Parameter | Type | Description |
---|---|---|
mailMergeCleanupOptions | int |
Returns: java.lang.String
getNames(int mailMergeCleanupOptions)
public static Set getNames(int mailMergeCleanupOptions)
Parameters:
Parameter | Type | Description |
---|---|---|
mailMergeCleanupOptions | int |
Returns: java.util.Set
getValues()
public static int[] getValues()
Returns: int[]
toString(int mailMergeCleanupOptions)
public static String toString(int mailMergeCleanupOptions)
Parameters:
Parameter | Type | Description |
---|---|---|
mailMergeCleanupOptions | int |
Returns: java.lang.String
toStringSet(int attr)
public static String toStringSet(int attr)
Parameters:
Parameter | Type | Description |
---|---|---|
attr | int |
Returns: java.lang.String