public class MailMergeCleanupOptions
extends java.lang.Object
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());
| Modifier and Type | Field and Description |
|---|---|
static int |
length |
static int |
NONE
Specifies a default value.
|
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.
|
static int |
REMOVE_EMPTY_PARAGRAPHS
Specifies whether paragraphs that contained mail merge fields with no data should be removed from the document.
|
static int |
REMOVE_EMPTY_TABLE_ROWS
Specifies whether empty rows that contain mail merge regions should be removed from the document.
|
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. |
static int |
REMOVE_STATIC_FIELDS
Specifies whether static fields should be removed from the document.
|
static int |
REMOVE_UNUSED_FIELDS
Specifies whether unused merge fields should be removed from the document.
|
static int |
REMOVE_UNUSED_REGIONS
Specifies whether unused mail merge regions should be removed from the document.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String mailMergeCleanupOptionsName) |
static int |
fromNames(java.util.Set mailMergeCleanupOptionsNames) |
static java.lang.String |
getName(int mailMergeCleanupOptions) |
static java.util.Set |
getNames(int mailMergeCleanupOptions) |
static int[] |
getValues() |
static java.lang.String |
toString(int mailMergeCleanupOptions) |
static java.lang.String |
toStringSet(int attr) |
public static int NONE
public static int REMOVE_EMPTY_PARAGRAPHS
public static int REMOVE_UNUSED_REGIONS
Remarks:
This option applies only to mail merge with regions.
public static int REMOVE_UNUSED_FIELDS
public static int REMOVE_CONTAINING_FIELDS
public static int REMOVE_STATIC_FIELDS
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
public static int REMOVE_EMPTY_TABLE_ROWS
Remarks:
This option applies only to mail merge with regions.
public static int REMOVE_EMPTY_TABLES
REMOVE_UNUSED_REGIONS or the REMOVE_EMPTY_TABLE_ROWS option.
Remarks:
This option applies only to mail merge with regions.
public static int length
public static java.lang.String getName(int mailMergeCleanupOptions)
public static java.util.Set getNames(int mailMergeCleanupOptions)
public static java.lang.String toString(int mailMergeCleanupOptions)
public static java.lang.String toStringSet(int attr)
public static int fromName(java.lang.String mailMergeCleanupOptionsName)
public static int fromNames(java.util.Set mailMergeCleanupOptionsNames)
public static int[] getValues()