Copy link to clipboard
Copied
Hello, I am in need of a script to help export pages of different web sizes to jpeg with the File name + websize name.
Examples: Job123_Email_600x300.Jpeg | Job123_web_1200x700.Jpeg
I have each page within indesign built according to the size of the web. I couldnt for the life of me figure out how to somehow specify within a script to name page 1 = email_600x300 and page 2 = web 1200x700 and so on.
I don't have any knowlege with scripting, I did however created a script 2 years ago from just trial and error and messing with example scripts to export pdf or jpeg with multiple variations ( layers on or off)
Sorry for the late reply, thanks Mike. However I figured it out and here is the script that I ended up with. It works quite well and it can export both PNG and JPG at the same time.
var myDoc = app.activeDocument;
for(var p = 0; p < app.documents[0].pages.length; p++) {
var frames = app.documents[0].pages[p].textFrames;
var jpg_name = null;
for(var i = 0; i < frames.length; i++) {
try {
if(frames[i].paragraphs[0].appliedParagraphStyle.name == 'title') {
jpg_
...
Copy link to clipboard
Copied
I don't know how to do it with scripting.
But you can do this with Bookmarks and PDF - then save to JPEG.
https://creativepro.com/data-merging-individual-records-separate-pdfs/
Copy link to clipboard
Copied
Hello @defaults0afwy5szys8,
Give the below script a try.
You'll need to set the jpg export preferences to your specific needs and build out the the rest of the sizes in the switch statement as I only did it with the two examples you provided.
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: 72,
// exportingSpread: true, // Uncomment if spreads
jpegColorSpace: JpegColorSpaceEnum.rgb,
jpegExportRange: ExportRangeOrAllPages.exportRange,
jpegQuality: JPEGOptionsQuality.maximum,
jpegRenderingStyle: JPEGOptionsFormat.baselineEncoding,
useDocumentBleeds: false,
simulateOverprint: false,
pageString: myPageName,
}
switch (myPageName) {
case '1':
var websize = 'email_600x300';
break;
case '2':
var websize = 'web_1200x700';
break;
}
doc.exportFile(ExportFormat.jpg,File(myFolder +"/"+ jpg_name + "_" + websize + ".jpg"),false);
}
alert("Done Exporting jpg's!");
Regards,
Mike
Copy link to clipboard
Copied
Sorry for the late reply, thanks Mike. However I figured it out and here is the script that I ended up with. It works quite well and it can export both PNG and JPG at the same time.
var myDoc = app.activeDocument;
for(var p = 0; p < app.documents[0].pages.length; p++) {
var frames = app.documents[0].pages[p].textFrames;
var jpg_name = null;
for(var i = 0; i < frames.length; i++) {
try {
if(frames[i].paragraphs[0].appliedParagraphStyle.name == 'title') {
jpg_name = frames[i].paragraphs[0].contents;
break;
}
}catch (e){
}
}
if(jpg_name != null) {
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH; // low medium high maximum
app.jpegExportPreferences.exportResolution = 72;
app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
app.jpegExportPreferences.pageString = app.documents[0].pages[p].name;
var myDocTitle = myDoc.name.replace(/\.indd$/i,"");
var myFilePath = myDoc.filePath + "/" + myDocTitle + jpg_name + ".jpg";
var myFile = new File(myFilePath);
myDoc.exportFile(ExportFormat.jpg, myFile, false);
}
if (jpg_name == null) {
}
}
for(var p = 0; p < app.documents[0].pages.length; p++) {
var frames = app.documents[0].pages[p].textFrames;
var png_name = null;
for(var i = 0; i < frames.length; i++) {
try {
if(frames[i].paragraphs[0].appliedParagraphStyle.name == 'title2') {
png_name = frames[i].paragraphs[0].contents;
break;
}
}catch (e){
}
}
if(png_name != null) {
app.pngExportPreferences.pngQuality = PNGQualityEnum.HIGH; // low medium high maximum
app.pngExportPreferences.exportResolution = 72;
app.pngExportPreferences.pngExportRange = PNGExportRangeEnum.EXPORT_RANGE;
app.pngExportPreferences.pageString = app.documents[0].pages[p].name;
var myDocTitle = myDoc.name.replace(/\.indd$/i,"");
var myFilePath = myDoc.filePath + "/" + myDocTitle + png_name + ".png";
var myFile = new File(myFilePath);
myDoc.exportFile(ExportFormat.pngFormat, myFile, false);
}
if (png_name == null) {
}
}
alert("Done Exporting!");
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I knew your name looked familiar! I've read through so many posts trying to see which script might work and it just happens to be that thread!
Copy link to clipboard
Copied
Hi, is there any chance you could explain how to operate this code? I save it as a .jsx , run it and i get a "Done Exporting" message.
However, i dont know how you designate a title for each page (for it to read) or where it exports to?
Cheers!
Copy link to clipboard
Copied
Hi, is there any chance you could explain how to operate this code? I save it as a .jsx , run it and i get a "Done Exporting" message.
However, i dont know how you designate a title for each page (for it to read) or where it exports to?By @Derrick37705576sgxq
The last version of the script - looks for TextFrames with "title" - for JPEG - and "title2" - for PNG - ParaStyle applied to the first paragraph inside.
Then uses contents of the paragraph as a suffix to the name of INDD file.
Copy link to clipboard
Copied
It only goes and works!
Brilliant! thanks
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now