Copy link to clipboard
Copied
Hi, I'm looking for what I assume is a pretty simple script to export an indesign page to a jpeg.
I want it to be set to 144dpi maxiumum quality. Would someone be able to advise the code for this? I found the below code on the forum which is good, but it saves it straight to the desktop with a temp filename, which is not really what I want. I would ideally like it to be saved with the same name as the indesign file and ask me where I want to save it (or just save directly to whatever folder the indesign file is in).
Any help with this would be greatly appreciated, thanks.
var doc = app.activeDocument; // Set JPEG export preferences app.jpegExportPreferences.properties = { antiAlias: true, embedColorProfile: true, exportResolution: 150, // exportingSpread: true, // Uncomment if spreads jpegColorSpace: JpegColorSpaceEnum.rgb, jpegExportRange: ExportRangeOrAllPages.exportRange, jpegQuality: JPEGOptionsQuality.maximum, jpegRenderingStyle: JPEGOptionsFormat.baselineEncoding, useDocumentBleeds: false, simulateOverprint: false, pageString: "1" // Page(s) to export, must be a string } // Make a temporary file var tempFile = File("~/Desktop/temp11111.jpg"); // Export an image of the page to disk doc.exportFile(ExportFormat.jpg, tempFile);
Hi Daniel,
Give this a Go....
var doc = app.activeDocument;
var myFolder = doc.filePath;
var jpg_name = doc.name.replace(/.indd$/i, "");
for(var p = 0; p < doc.pages.length; p++) {
var myPageName = doc.pages[p].name;
// Set JPEG export preferences
app.jpegExportPreferences.properties = {
antiAlias: true,
embedColorProfile: true,
exportResolution: 144,
// exportingSpread: true, // Uncomment if spreads
jpegColorSpace: JpegColorSpaceEnum.rgb,
jpegExportRange: ExportRangeOrAll
...
Copy link to clipboard
Copied
Hello Daniel,
Give this a try....
var doc = app.activeDocument;
var myFolder = doc.filePath;
var jpg_name = doc.name.replace(/.indd$/i, "");
// Set JPEG export preferences
app.jpegExportPreferences.properties = {
antiAlias: true,
embedColorProfile: true,
exportResolution: 144,
// exportingSpread: true, // Uncomment if spreads
jpegColorSpace: JpegColorSpaceEnum.rgb,
jpegExportRange: ExportRangeOrAllPages.exportRange,
jpegQuality: JPEGOptionsQuality.maximum,
jpegRenderingStyle: JPEGOptionsFormat.baselineEncoding,
useDocumentBleeds: false,
simulateOverprint: false,
pageString: "1" // Page(s) to export, must be a string
}
doc.exportFile(ExportFormat.jpg, File(myFolder +"/"+ jpg_name + ".jpg"), false);
alert("Done Exporting jpg's!");
Regards,
Mike
Copy link to clipboard
Copied
Thanks so much Mike! That worked really well but there's an issue I didn't anticipate. It only works for a document with 1 page. I tried updating the code with 20 for the page string to be safe but it gives an error if the indesign file isn't exactly 20 pages. Is there any way of easily adjusting the code so that it exports all pages? e.g if i had a 12 page indd file. Thanks again.
Copy link to clipboard
Copied
Hi Daniel,
Give this a Go....
var doc = app.activeDocument;
var myFolder = doc.filePath;
var jpg_name = doc.name.replace(/.indd$/i, "");
for(var p = 0; p < doc.pages.length; p++) {
var myPageName = doc.pages[p].name;
// Set JPEG export preferences
app.jpegExportPreferences.properties = {
antiAlias: true,
embedColorProfile: true,
exportResolution: 144,
// exportingSpread: true, // Uncomment if spreads
jpegColorSpace: JpegColorSpaceEnum.rgb,
jpegExportRange: ExportRangeOrAllPages.exportRange,
jpegQuality: JPEGOptionsQuality.maximum,
jpegRenderingStyle: JPEGOptionsFormat.baselineEncoding,
useDocumentBleeds: false,
simulateOverprint: false,
pageString: myPageName,
}
doc.exportFile(ExportFormat.jpg, File(myFolder +"/"+ jpg_name +"_"+myPageName+ ".jpg"), false);
}
alert("Done Exporting jpg's!");
Regards,
Mike
Copy link to clipboard
Copied
Thank you! Absolute lifesaver, works perfectly.