Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Help!I have a script to export layers to jpg one by one, but I need to access the "use artboard" option

$
0
0

I want the exported pictures to use the artboard's size. Thanks in advance.

 

var folder = Folder.selectDialog();
var document = app.activeDocument;
if(document && folder)
{       var options = new ExportOptionsJPEG();    options.antiAliasing = true;     options.qualitySetting = 100;       options.optimization = true;    options.croppingMaskClipping = true;            //scale to 500dpi    options.verticalScale = 500;    options.horizontalScale = 500;        var n = document.layers.length;    for(var i=0; i<n; ++i) {        hideAllLayers();        var layer = document.layers[i];        layer.visible = true;        var file = new File(folder.fsName+"/"+layer.name+".jpg");        document.exportFile(file,ExportType.JPEG,options);    }    //to show all layers visible when done:    showAllLayers();
}

function hideAllLayers()
{
    forEach(document.layers, function(layer) {         /**         if there is one or more layers called 'ABC' in the .ai file, it will always be part of the export.        */        if( layer.name != "ABC"){            layer.visible = false;        }    });
}



function showAllLayers()
{
    forEach(document.layers, function(layer) {            layer.visible = true;     });       
}


function forEach(collection, fn)
{
    var n = collection.length;    for(var i=0; i<n; ++i)    {        fn(collection[i]);    }
}

Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>