How to export a sequence of layers in illustrator?


I often have to modify pdf files and show them in stages. Like this:


enter image description here


enter image description here


enter image description here

I'm currently doing it by separating each part of the plot into layers and then hiding some of them, and exporting them to as image files. Is there a more convenient way to do this? I don't want to duplicate objects into different layers because if further along I want to make changes, I'd have to them on every layer.

10/4/2015 5:49:00 PM

You can do this with scripting. Unfortunately your usecase dont really fit the suggested scripts. Also artboards will work very badly on account of the requirement of your only one copy of things. They could still be used as a basis for a custom script. The floor plan script i linked in my comment is very close to your usecase though.

This is quite trivial to script. But we might as well make something that is flexible for any future case. I wont bother with a super complicated GUI so you must bear with me. This is a programming scaffold delete the export options you dont need.

var outpath = "d:\\temp\\test";
var doc = app.activeDocument;

// array of layer names to export in each pass
// last name in array is file name. Modify to
// suit your need.

var layers_to_export = [
    ["ebola_k","ebola_gp_il6", "ebola_gp_rest", "all_layers"],
    ["ebola_k", "ebola_gp_il6", "two_layers"],
    ["ebola_k", "one_layer"]

var layers = doc.layers;
var state = Array();
for(var i=0;i<layers.length;i++){
    layers[i].visible = false;

for(var i=0; i < layers_to_export.length; i++){
    for(var j=0; j < layers_to_export[i].length-1; j++){
        layers.getByName(layers_to_export[i][j]).visible = true;
    var fname = outpath+layers_to_export[i][layers_to_export[i].length-1];

    // delete the export you dont want

    //save as ai
    var f = new File(fname+'.ai');
    doc.saveAs( f );

    //save as eps
    f = new File(fname+'.eps');
    var saveOpts = new EPSSaveOptions();
    saveOpts.cmykPostScript = true;
    doc.saveAs( f, saveOpts );

    var f = new File(fname+'.pdf');
    saveOpts = new PDFSaveOptions();
    saveOpts.compatibility = PDFCompatibility.ACROBAT5;
    saveOpts.generateThumbnails = true;
    saveOpts.preserveEditability = false;
    saveOpts.viewAfterSaving = false;
    doc.saveAs( f, saveOpts );

    var f = new File(fname+'.png');
    var exportOptions = new ExportOptionsPNG8(); // or PNG24
    exportOptions.colorCount = 200;
    exportOptions.transparency = false;
    app.activeDocument.exportFile( f, ExportType.PNG8, exportOptions );    

    for(var j=0; j < layers_to_export[i].length-1; j++){
        layers.getByName(layers_to_export[i][j]).visible = false;


for(var i=0;i<layers.length;i++){
    layers[i].visible = state[i];

I have to wonder though is your workflow optimal? What about using a graphing application? Like Mathematica, Matlab or some free alternative like Python/IPython + matplotlib/pylab, R, Octave, Open Modellica etc.

10/10/2015 10:13:00 AM