Hi all,
Was wondering if anyone can point me to the improvments to Data Merge in the newest version of InDesign (assuming there are some). We are specifically looking for a way to output single PDFs (500 page Data Merged InDesign Document saves as 500 PDF files for example) and each PDF being named using a column from the attached Excel file. I realise that it will be possible to have the javascripted, but was kind of hoping to avoid this with the newest InDesgn.
Thanks,
Graham
If you're getting 500 separate PDF files, you're doing something wrong. You should be able to save your Excel file (with graphic file references) in tab-delimited TXT format, attach it to your InDesign template through Merge function, complete your layout by dragging fields, then generate your catalog. Check the Indesign Help function. Columns should be your Field names.
Here you go. If you run the script, it will ask which csv file to use for the naming, and where its says 'PartnerHQ_Id' in my script, replace that with the column name you want to use. Let me know if anything is unclear; I am not really a Javascript kind of guy ...
/* Put script title here */
var CSV = function(data) {
var _data = data.split('\r\n');
for(var i in _data) {
if(_data[i].length > 0) {
console.println(i + ' ' + _data[i]);
_data[i] = _data[i].split(',');
}
}
var _head = _data.shift();
return {
length: function() {
return _data.length - 1;
},
getRow: function(row) {
return _data[row];
},
getRowAndColumn: function(row, col) {
if(typeof col !== 'string') {
return _data[row][col];
} else {
col = col.toLowerCase();
for(var i in _head) {
if(_head[i].toLowerCase() === col) {
return _data[row][i];
}
}
}
}
};
};
this.importDataObject("CSV Data");
var dataObject = this.getDataObjectContents("CSV Data");
var csvData = new CSV(util.stringFromStream(dataObject));
if(this.numPages != csvData.length()) {
app.alert("Number of pages & CSV row count inconsistent");
} else {
for(var i = 0; i < this.numPages; i++) {
this.extractPages({nStart: i, cPath: csvData.getRowAndColumn(i, 'PartnerHQ_Id') + '.pdf'});
}
}
Finally on cs6 and have retested GrahamHe's script. Still has the same error in InDesign, but that is because this is NOT and indesign script - it's an ACROBAT script! The script is applied using the action wizard.
So this doesn't behave the way I thought, such as running the script directly from indesign. The file is still merged to a single multi-page PDF file, and then the script is run via the action wizard.
Had trouble getting the script to work initially via acrobat but I did amend the second line to read
| var _data = data.split('\r'); |
and it worked a treat!
One warning: the names in the column selected to become the filenames need to be unique (such as a primary key) otherwise there is a risk of files overwriting each other.
colly
North America
Europe, Middle East and Africa
Asia Pacific