Is it possible to add items in a list to mailmerge

Basically I have a Array list in java and now I need to send that list to mailmerge doc to create a repeated data.

The data in the list is not going to be in a table , it will b paragraph and other formatting texts
Hi Spencer,

Thanks for your inquiry. We suggest you please implement IMailMergeDataSource interface to allow mail merge from a custom data source, such as a list of objects.

When a data source is created, it should be initialized to point to BOF (before the first record). The Aspose.Words mail merge engine will invoke moveNext() to advance to next record and then invoke getValue(java.lang.String,java.lang.Object[]) for every merge field it encounters in the document or the current mail merge region.

Please check the following code example. We have attached the template document with this post for your kind reference. Hope this helps you.

ArrayList items = new ArrayList();
for(int i=1; i<5; i++)
{
items.add("List Item " + i);
}

// Open tempalte
Document doc = new Document(MyDir + "in.docx");
// Create a datasource.
MailMergeDataSource data = new MailMergeDataSource(items, "items");
// Execute mail merge with regions.
doc.getMailMerge().executeWithRegions(data);
// Save output.
doc.save(MyDir + "Out.docx");
--------------------------------------------------
class MailMergeDataSource implements IMailMergeDataSource{

public MailMergeDataSource(ArrayList items, String tableName)
{
mItems = items;
mTableName = tableName;
// When the data source is initialized, it must be positioned before the first record.
mRecordIndex= -1;
}

///
/// The name of the data source. Used by Aspose.Words only when executing mail merge with repeatable regions.
///

public String getTableName()
{
return mTableName;
}

///
/// Aspose.Words call this to get a value for every data field.
///

public boolean getValue(String fieldName, Object[] fieldValue)
{
fieldValue[0] = mItems.get(mRecordIndex);
return fieldValue[0] != null;
}

public IMailMergeDataSource getChildDataSource(String childName) throws Exception {

return null;
}

///
/// A standard implementation for moving to a next record in a collection.
///

public boolean moveNext()
{
if (isEof())
return false;

mRecordIndex++;

return (!isEof());
}

private boolean isEof()
{
return (mRecordIndex >= mItems.size());
}

private ArrayList mItems;
private int mRecordIndex;
private String mTableName;
}