Created
November 23, 2012 05:32
-
-
Save amolok/4134141 to your computer and use it in GitHub Desktop.
AI: export all datasets from current layer to JPEG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************** | |
export to jpg with filename += dataSet.name | |
**********************************************************/ | |
// Main Code [Execution of script begins here] | |
// uncomment to suppress Illustrator warning dialogs | |
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; | |
// var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, jpgSaveOpts; | |
// Select the source folder. | |
// sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PDF', '~' ); | |
var d=app.activeDocument; | |
if (app.documents.length>0) { | |
var filePath = d.path; | |
var fileName= d.name.split('.', 1); | |
var exportOptions = getJPEGOptions(); | |
var type = ExportType.JPEG; | |
var newFileName = fileName+'_'+d.activeLayer.name; | |
// alert ('\nLayers: '+doc.layers.length+', DataSets: '+doc.dataSets.length,newFileName); | |
if (d.dataSets.length>0) { | |
for (i=0; i<d.dataSets.length; i++) { | |
d.dataSets[i].display(); | |
// alert(d.dataSets[i].name); | |
exportJPEG(newFileName+'_'+d.dataSets[i].name); | |
} | |
} else { | |
exportJPEG (newFileName); | |
} | |
} | |
function exportJPEG (newFileName) { | |
var fileExport = new File(filePath+'/'+newFileName); | |
return app.activeDocument.exportFile(fileExport, type, exportOptions); | |
} | |
/* | |
JPEG export options | |
*/ | |
function getJPEGOptions() | |
{ | |
var exportOptions = new ExportOptionsJPEG(); | |
exportOptions.antiAliasing = true; // the exported image should be anti-aliased | |
exportOptions.artBoardClipping = true; // the exported image should be clipped to the artboard. | |
exportOptions.blurAmount = 0.0; // The amount of blur to apply to the exported image. Range: 0.0 to 2.0 Default: 0.0 | |
exportOptions.horizontalScale = 200.0; // The horizontal scaling factor to apply to the exported image, where 100.0 is 100%. Default: 100.0 | |
exportOptions.verticalScale =200.0; // The vertical scaling factor to apply to the exported image. Range: 0.0 to 776.19 Default: 100.0 | |
exportOptions.matte = true; // the art board should be matted with a color. Default: true | |
exportOptions.optimization = true; // the exported image should be optimized for web viewing. Default: true | |
exportOptions.qualitySetting = 80 // The quality of the exported image. Range: 0 to 100 Default: 30 | |
exportOptions.saveAsHTML = false; // the exported image should NOT be saved with an accompanying HTML file. Default: false | |
// exportOptions.matteColor // RGBColor object The color to use when matting the art board. Default: white | |
// exportOptions.typename string Read-only. The class name of the referenced object. | |
return exportOptions; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment