Open FIle dialog and Export file dialog in Indesign
Hi
I am using data merge in InDesign for a Report Card and I will end up using approx 70 pages.
The report card has student name and marks obtained and a graph.
I wil then export these 70 pages in jpg in a specific folder. Each jpg file will be saved with student's name.
I have copied the student's name from the excel file used in datamerge and saved it in a text file named "names.txt".
The script which I have written will read this names.txt file and export the jpg file using the names and save it to some folder.
Currently I have hardcoded the location of names.txt file and also the place where I want to export the jpg file.
How do I give option to open the "names.txt" file and also the locaiton where to export the jpg files.
Thank you.
Here is the code which I have written:
var doc = app.activeDocument;
var pagesCount = doc.pages.length;
//Read the source file with page to be named
var masterContentFile = File("d:/names.txt");
//Open the file in read mode
masterContentFile.open('r');
//Split the contents with newline as delimiter
var masterContent = masterContentFile.read().split("\n");
//Get the document path
var myFolder = doc.filePath;
for(i = 0; i < pagesCount; i++)
{
exportJPG();
}
function exportJPG(){
app.jpegExportPreferences.antiAlias = true;
app.jpegExportPreferences.jpegColorSpace = JpegColorSpaceEnum.RGB; //other options JpegColorSpaceEnum.GRAY, JpegColorSpaceEnum.CMYK
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM; //other options JPEGOptionsQuality.LOW, JPEGOptionsQuality.HIGH, JPEGOptionsQuality.MEDIUM
app.jpegExportPreferences.exportResolution = 300; // Range from 1-2400
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE; //ExportRangeOrAllPages.EXPORT_ALL;
app.jpegExportPreferences.pageString = app.documents[0].pages[i].name;
doc.exportFile(ExportFormat.jpg, File(myFolder +"/"+ masterContent[i] + ".jpg"), false);
}
Sample data of the names.txt file is single word currently :
Shahid
Zafar
Rakesh
...
...
Shakir
John
Doe
