I have run into this on occasion as well. There doesn't seem to be a clean way to do this in data merge, as it really only knows one page-one record or one page-multiple records. It can't backtrack in the data file and repeat records. The only way to get data merge to do this is to create the spreadsheet with the duplicate numbers in the correct order (1,2,1,2,3,4,3,4,5,6,5,6…).
What I usually end up doing is doing the mail merge once, then using the pages panel, duplicating each page manually. It is tedious, but unless you have more than a hundred pages to do, or you do this so regularly that it is too time consuming, it is likely the easiest way.
Certainly, you could write a script that does the page duplication for you. This is a pretty straightforward script. You could even have it handle three-part forms as well.
This is the code I wrote a few months ago to do a similar function and swap two colums of items across center. You would not need the “Select all items” section at the bottom.
/* Duplicate page and swap nametag elements across vertical center. By Jake Overton
Assumptions:
Inches is the default measurement
US Letter sized paper in portrait mode
2 columns of 4″ wide name tags centered on the page and .25″ margins (common border at 4.25″)
Document is open (error if not) and all nametags are ready for print (text wrap and overset is done)
*/
main()
function main(){
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if (app.documents.length == 0){
alert(“Please open a document, and try again.”);
}
duplicate();
}
function duplicate(){
// Start with last page, duplicate then move back one page. Repeat until at beginning.
var myDocument = app.activeDocument;
var myWindow = app.activeWindow;
var myPages = myDocument.pages;
for (pageCounter=myPages.length; pageCounter > 0; pageCounter–) {
myWindow.activePage = myPages[pageCounter-1];
// Duplicate all items
var myDuplicate = myWindow.activePage;
myWindow.activePage.duplicate(LocationOptions.AFTER, myDuplicate);
// Select all items
var mySelection = myDuplicate.allPageItems;
// Swap items based on location of left edge
// (assume 4″ is dividing line, as some text frames may extend beyond paper center).
for (i=0; i<=mySelection.length-1; i++){
//~ $.writeln(“i= “, i,” Type= “, mySelection[i]);
//~ $.writeln(mySelection[i].geometricBounds);
if (mySelection[i].constructor.name != “Image”){
if (mySelection[i].geometricBounds[1] >= 4)
mySelection[i].move(undefined, [-4,0]);
else
mySelection[i].move(undefined, [4,0]);
}
}
}
}