Can you do a two page mail merge in indesign

The classic question!

While InDesign is a powerful page design and layout application, it's not designed for mail merging in the classical sense. Mail merging typically involves combining a data source with a template to produce multiple documents with unique information.

However, you can achieve a similar effect in InDesign using a combination of scripting, data merging, and page design. Here's a two-page mail merge example:

Step 1: Prepare your data

Create a CSV (Comma Separated Values) file containing the data you want to merge. Each row should represent a single record, and each column should represent a field (e.g., name, address, phone number).

Step 2: Create a template

Design a two-page template in InDesign, using master pages and page layouts to define the structure. You can use placeholders for the data fields, such as text frames with a "merge" attribute.

Step 3: Use JavaScript to merge the data

Create a JavaScript file that reads the CSV data and merges it with the InDesign template. You can use the InDesign JavaScript API to access and manipulate the document, pages, and text frames.

Here's an example JavaScript code that merges the data:

// Load the CSV data
var csvData = csvToArray('data.csv');

// Loop through each record
for (var i = 0; i < csvData.length; i++) {
  // Get the current record
  var record = csvData[i];

  // Open the document
  var doc = app.documents[0];

  // Go to the first page
  var page = doc.pages[0];

  // Merge the data into the template
  page.textFrames[0].contents = record['name'];
  page.textFrames[1].contents = record['address'];
  page.textFrames[2].contents = record['phone'];

  // Go to the second page
  page = doc.pages[1];

  // Merge the data into the template
  page.textFrames[0].contents = record['email'];
  page.textFrames[1].contents = record['website'];

  // Save the document
  doc.save();
}

Step 4: Run the script

Open the JavaScript file in InDesign's Script Editor (File > Scripts > Other Scripts) and run the script. The script will merge the data with the template, creating a new document for each record.

Step 5: Review and refine

Review the output documents to ensure the data is merged correctly. You may need to refine the script or adjust the template to accommodate any formatting or layout issues.

While this approach requires more effort than a traditional mail merge, it allows you to leverage InDesign's powerful page design and layout capabilities to create customized documents.