Question
InDesign Script for Batch Creation
Hi there,
I'm looking to create a script that helps me to create blank InDesign documents based on a CSV file.
The data I would like to change is as follows:
- File name
- Height
- Width
Then, I would like to add an IF to the script that if larger than 5486.4 mm it will scale it down 50%, both Height and Width.
I got this far but I'm a bit stuck:
var file = File.openDialog("Document", undefined, false);
var folder = Folder.selectDialog("Document");
file.open("r");
var content = file.read().split("\n");
for (var i = 0; i < content.length - 1; i++) {
var curLine = content[i].split("\t");
var h = curLine[0];
var w = curLine[1];
var mar = curLine[2];
var n = curLine[3];
docName = n + "_" + h + "×" + w;
try {
var newDoc = app.documents.add(false);
newDoc.documentPreferences.pageHeight = h;
newDoc.documentPreferences.pageWidth = w;
newDoc.marginPreferences.properties = {top: mar,left: mar,right: mar,bottom: mar};
newDoc.save(new File(folder + "/" + docName + " .indd"));
newDoc.close(SaveOptions.no)
} catch(myError){}
}