2

I am trying to do a data merge using Indesign Server. test.indd in the script below already has all the merge fields assigned. I only need this script to open the file, do the merge, and save the merged file. The file that gets saved is the original test.indd file, and not the merged file. I'm not sure how to access the merged file.

var myDocument = app.open(File("/C/inetpub/wwwroot/datamerge/test.indd"));

with (app.dataMergeOptions) { 
 linkImages = true; 
 removeBlankLines = false; 
 createNewDocument = true; 
 documentSize = 100; 
} // (end of dataMergeOptions) 

myDocument.dataMergeProperties.mergeRecords();
myDocument.save(new File("/C/inetpub/wwwroot/datamerge/mergedOutput.indd"));
myDocument.close ();

If someone can have a look and let me know what I'm missing. Or direct me in the direction I should be going.

Evan
  • 2,400
  • 1
  • 18
  • 34
nav
  • 21
  • 2

1 Answers1

1

Your dataMergeOptions tell the application to create a new document but you are saving the document in your myDocument variable which is your template. You need to either get a hold of the newly created document and save that or remove the createNewDocument option.

Anna Forrest
  • 1,711
  • 14
  • 21
  • Hi @Anna how can i get hold of newly created document (after merging)? – TheVillageIdiot Feb 09 '15 at 06:01
  • 1
    try using 'app.activeDocument.save' instead of 'myDocument.save' - I haven't played with the merge function much but it would make sense that your newly merged document would become the active one post merge. – Anna Forrest Feb 10 '15 at 01:55