Is there a script to export illustrator image as multiple file types, colours, sizes?


I have 6 different logos to each be individually saved as

  • Black >> CMYK / RGB >> JPG / TIFF / EPS
  • Colour >> CMYK / RGB >> JPG / TIFF / EPS
  • White >> CMYK / RGB >> JPG / TIFF / EPS

Is there a script that can do this or do I have to do it manually?

11/4/2015 3:27:00 PM

Accepted Answer

Maybe this isn't the perfect answer, but comments simply didn't have enough room for this.

To start with scripting, the first place you want to look is probably the Illustrator scripting reference site. In there, if you open the reference pdf for javascript. You'll find a list of methods and some sample scripts.

If you search for: "exporting to" and cyrcle through the search results, you'll find script samples for exporting the current document to different formats. The other two search terms would be "saving to" and "saving with". These sample scripts will get you pretty close to what you're after.

You can find the export and save properties above these example scripts.

Also, this is a good resource and sometimes way better than the "official" reference. This can be difficult to navigate through, so what I usually do is just google stuff like "jongware illustrator document" or "jongware illustrator pdfsaveoptions". @Jongware, you're my hero <3

Now, getting back to setting up the script

If you get one of those example scripts from the reference file for javascript and stick that in a .jsx file and run it, nothing will happen. You need to call the function like this:

Here's the saveFileToPDF function, that you can find there

I just added this first line below. Obviously you need to use your own path.


// Saves the current document as PDF to dest with specified options
// dest contains the full path and file name to save to
function saveFileToPDF(dest) {
    var doc = app.activeDocument;
    if ( app.documents.length > 0 ) {
        var saveName = new File ( dest );
        saveOpts = new PDFSaveOptions();
        saveOpts.compatibility = PDFCompatibility.ACROBAT5;
        saveOpts.generateThumbnails = true;
        saveOpts.preserveEditability = true;
        doc.saveAs( saveName, saveOpts );

With this, the script will save your current document as pdf file with each artboard as a separate page.

Now if you get the example scripts for each file format you want to save and call the functions as shown above, you'll quickly have a script that saves the current document to how ever many formats you want.

JPG and PNG formats can complicate things a bit, if you want to do something like what I explained in my comment: Manually create the different color options into different artboards and then run the script. Well, neither of these formats support the property artboardRange, when exporting. Meaning that it only saves one file with all the content in the document. You can get around it though:

I basically wrapped the "exportFile" method in a for loop, modified the file naming and removed "fileSpec" variable. I also added "artBoardClipping" property. With these modifications the script should save file1.jpg, file2.jpg and file3.jpg assuming you have 3 artboards.


// Exports current document to dest as a JPEG file with specified
// options, dest contains the full path including the file name
function exportFileToJPEG (dest) {
    if ( app.documents.length > 0 ) {
        var exportOptions = new ExportOptionsJPEG();
        var type = ExportType.JPEG;
        // var fileSpec = new File(dest);
        exportOptions.artBoardClipping = true; // If true, the exported image should be clipped to the artboard.
        exportOptions.antiAliasing = true;
        exportOptions.qualitySetting = 100;

        // Gets the length (amount) of artboards in the current document.
        var artboard_length = app.activeDocument.artboards.length;
        // Loop that runs the code as many times as there are artboards...
        for (var i = 0; i < artboard_length; i++ ) {
            // Set the active artboard based on the loop number
            // Exports the current artboard as a jpeg file
            app.activeDocument.exportFile( new File( dest + (i+1) + ".jpg" ), type, exportOptions );


Now let's say you wanted to use the current document name as the base for the file names, you could use a variable like this at the top of the document:

var docName ='.')[0];

...and then you could use it like this:

exportFileToJPEG("/Users/joonas/Desktop/" + docName );
11/4/2015 8:27:00 PM