Skip to content

Instantly share code, notes, and snippets.

@osima
Created June 3, 2011 09:00
Show Gist options
  • Select an option

  • Save osima/1006079 to your computer and use it in GitHub Desktop.

Select an option

Save osima/1006079 to your computer and use it in GitHub Desktop.
export page as jpeg and return filename list as json
(function(){
var exportPageAsJpeg = function( myDocument, myPage, myFilePath ){
app.jpegExportPreferences.pageString = myPage.name;
myDocument.exportFile(ExportFormat.JPG, File(myFilePath), false);
};
//var basePath = '${basePath}';
var basePath = Folder.desktop;
var prefix = 'foo-';
var json = '';
json = json + '{jpgFilePathList:[';
var myDocument = app.activeDocument;
for(var myPageCounter=0; myPageCounter<myDocument.pages.length; myPageCounter++){
var myPage = myDocument.pages.item(myPageCounter);
var myFilePath = basePath + '/' + prefix + myPageCounter + '.jpg';
exportPageAsJpeg( myDocument, myPage, myFilePath );
json = json + '"' + myFilePath + '",';
}
json = json + ']}';
return json;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment