Generating Mailing Labels- 12 per page

Maybe this question has already been answered somewhere, but I have a document (attached) which is an Avery template for mailing labels. It has 12 sections for the labels, 6x2. Each label has a series of merge fields. Is there an easy way to populate all the 12 labels with e.g. Name/Address variables in my Java code?

By the way, I’ve noticed that if I have several merge fields with an identical name, only the first gets populated. So I can’t just copy the fields onto every label, I have to give them different names.
Thanks a lot

Hi

Thanks for your request. You should just insert NEXT field before each record, except the first one. I think the example provided in the following thread could be useful for you:
https://forum.aspose.com/t/94886
Best regards.

Thanks, I’ll try that.

Hi

Thank you for additional information. In this case, the code and the template are much simpler. You should just copy/paste the same merge fields in the template and execute the following simple code:

// Open document
Document doc = new Document("C:\\Temp\\MailingLabels_example.doc");
// Create datasource
String[] names = {
    "NAME",
    "ADDRESS"
};
Object[] values = {
    "Alexey Noskov",
    "Here is my address"
};
// execute simple mail merge
doc.getMailMerge().execute(names, values);
// Save output document
doc.save("C:\\Temp\\out.doc");

I also attached the template and the output document produced by this code.
Hope this helps.
Best regards.