com.aspose.words

Interface IMailMergeCallback

  • public interface IMailMergeCallback 

Implement this interface if you want to receive notifications while mail merge is performed.

Example:

Shows how to define custom logic for handling events during mail merge.
Document document = new Document();
    document.getMailMerge().setUseNonMergeFields(true);

    MailMergeCallbackStub mailMergeCallbackStub = new MailMergeCallbackStub();
    document.getMailMerge().setMailMergeCallback(mailMergeCallbackStub);

    document.getMailMerge().execute(new String[0], new Object[0]);

    Assert.assertEquals(mailMergeCallbackStub.getTagsReplacedCounter(), 1);
}

private static class MailMergeCallbackStub implements IMailMergeCallback
{
    public void tagsReplaced()
    {
        mTagsReplacedCounter++;
    }

    public int getTagsReplacedCounter()
    {
        return mTagsReplacedCounter;
    }

    private int mTagsReplacedCounter;
}

Method Summary
abstract voidtagsReplaced()
Called when "mustache" text tags are replaced with MERGEFIELD fields.
 

    • Method Detail

      • tagsReplaced

        public abstract void tagsReplaced()
        Called when "mustache" text tags are replaced with MERGEFIELD fields.
        See Also:
        MailMerge.UseNonMergeFields

        Example:

        Shows how to define custom logic for handling events during mail merge.
        Document document = new Document();
            document.getMailMerge().setUseNonMergeFields(true);
        
            MailMergeCallbackStub mailMergeCallbackStub = new MailMergeCallbackStub();
            document.getMailMerge().setMailMergeCallback(mailMergeCallbackStub);
        
            document.getMailMerge().execute(new String[0], new Object[0]);
        
            Assert.assertEquals(mailMergeCallbackStub.getTagsReplacedCounter(), 1);
        }
        
        private static class MailMergeCallbackStub implements IMailMergeCallback
        {
            public void tagsReplaced()
            {
                mTagsReplacedCounter++;
            }
        
            public int getTagsReplacedCounter()
            {
                return mTagsReplacedCounter;
            }
        
            private int mTagsReplacedCounter;
        }