Export Illustrator Layers and/or Artboards as PNGs and PDFs

Over the last year or so, I’ve cobbled together a couple Illustrator scripts that export multiple artboards in an Illustrator document as PNG files, and export multiple layers as PNG files. (See my previous blog posts here and here.) I’d been meaning to merge them into one script, but had never quite gotten around to it until Khoi tweeted that he was looking for a script that did just that, but to PDF format.

So, a couple train rides later, I’ve finally combined the two scripts into a single one with a couple more added features: you can choose to export as PDFs in addition to PNGs, and you can also export the product of artboards and layers.

To use the script, download MultiExporter.jsx and put in your Illustrator scripts folder (usually in Applications/Adobe Illustrator/Presets/Scripts/). Restart Illustrator, and run the script by going to “File > Scripts > MultiExporter”.

A few notes:

  • You can choose whether you want to export all the artboards in the document with the currently visible layers showing, or if you want to export files for each of the layers in a document on the currently active artboard, or if you want to export a combination of all the artboards multiplied by all the layers.
  • Files are named based on their layer name. It only exports layers where their name has been changed from the default “Layer 1″, “Layer 2″ or “Artboard 1”, “Artboard 2”, etc.
  • If you put a minus sign (-) in front of a layer name or artboard name, it will skip that layer or artboard. (Useful for when you no longer decide you like a particular mockup, but don’t want to delete it from the master Illustrator document.)
  • For layers only: If you put a plus sign (+) in front of a layer name, that layer will always be visible. Useful for if you want to have a layer that always appears in the background of each exported image.
  • It stores its settings in a nonvisible, nonprinting layer named “nyt_exporter_info”
  • It has an option for transparency, and lets you choose between PNG8, PNG24 and PDF.

You can try it out on the sample file artboard-layer-test.ai.

The sample file contains artwork for buttons on three artboards — “Red”, “Blue” and “-Green” — and has seven layers.

  • If you run the script and choose “Export Artboards (with currently visible layers)” it will generate two files: Red.png and Blue.png that include whatever layers are currently showing at the time you run the script. (It skips the “-Green” artboard because the artboard name begins with a minus sign.
  • If you chose “Export Layers (on currently selected artboard)” it will generate two files: Play.png and Pause.png. The “+Button” and “+Gradient” layers will appear in the background of both exported files, and it will skip the “-Pause 2″ and “Layer 5″ layers.
  • And if you choose the “Artboard + Layers”, it will do a combination of the two other options and generate four files: Red-Play.png, Red-Pause.png, Blue-Play.png and Blue-Pause.png.

Try it out, and leave a note in the comments if you have any problems or suggestions.

337 comments on “Export Illustrator Layers and/or Artboards as PNGs and PDFs”

  1. Miriam

    Hi, This script is amazing , thank you! How do i set the quality of the .jpg export? I need .JPG format and it’s quality is not geart currently

  2. chad Bernier

    Hello. This script does not work correctly with two monitors, at least not on my computer. The dialog box shows up on the other monitor, which isn’t so bad on its own. It also shows up very thin, so most of the dialog box is not visible, and this is not re-sizable. Please consider fixing this if possible.

  3. Jonathan Riddering

    It only works with 3 of my 5 artboards. I renamed the artboards just like you say but only exports 1,2 and 5.

  4. Leo

    I found it in the feed of comments!

    Thanks!

    If you want to use a specific PDF Presets… Here is what you need to do.

    Open the Script with ExtendScript Toolkit and search for:

    } else if ( this.format == ‘PDF’ ) {
    options = new PDFSaveOptions();
    options.compatibility = PDFCompatibility.ACROBAT5;
    options.generateThumbnails = true;
    options.preserveEditability = false;

    Replace it with:

    } else if ( this.format == ‘PDF’ ) {
    options = new PDFSaveOptions();
    options.pDFPreset = ‘NameOfPreset’;

    Just edit the ‘NameOfPreset’ with the name of your save preset. in between the ‘

  5. karen

    Dear Matthew, I am surprised how simple it is to use this MultiExporter you’ve created. I randomly found your page, greatly appreciated!!

    Many hugs and thanks! ^_^//

  6. espurnes

    Awesome!
    Thank you. The functionality to export Artboards to a single page PDF named with Artboard names is so useful.

  7. Thanh Vân

    Cảm ơn rất nhiều, *Script* của bạn giúp tôi rất nhiều trong công việc. Thật tuyệt.

  8. Dave Gillaspie

    Love Love Love this. So very helpful.

    It works fine exporting Layers (on currently selected artboard). I’m having difficulty with exporting Artboards (with currently visible layers). This option doesn’t generate any output.

    When I select this option is states at the bottom “will export 0 of 1 artboard”
    The layers have unique names and don’t have a “-” sign in front. Not sure why this isn’t working??

    Am I doing something wrong?

    Thanks!!!

  9. Catherine

    I am a fairly novice user and was able to download and use this script to save myself a TON of work! I have to export multiple layer documents to PDF every month and it was taking FOREVER! Thank you for being a smart guy.

  10. Phil

    gah… This script sounds AMAZING… I’m so jealous of everyone who got it working!
    I’ve looked though a lot of comments and can’t find the solution for my problem:

    “Will export 0 of 141 layers”

    Background:
    I’m running CS6 on win10.

    I want to export my layers as transparent .pngs
    I have installed the script, restarted CS6, opened the file I want to export.
    I have all layers visible and unlocked.
    I have the only artboard selected and all the shapes are within that artboard’s boundaries.
    I have run the script, and the script’s dialog appears okay.
    At the “Export What” dropdown, I’ve selected “Layers (on currently selected artboard)”
    But the message at the bottom of the dialog says “Will export 0 of 141 layers”
    Of course, when I click export, exactly zero images are exported. True to it’s word.

    I’ve tried selecting all the layers first, and that doesn’t help.

    Guys and Gals, What am I missing?

  11. Phil

    Gah… Please ignore my previous post. I did find the answer eventually.
    (Forgot to rename layers and artboards to something other than the default names.)

    I’m very excited, I know this will be an outstanding timesaver for me! Thank you for your generosity! 😀

  12. Radim Paluš

    Hello, I just tried this script with Illustrator CS3 on Mac and I got error 21 “Undefined is not an object.”

    I don’t know if this script works with the CS3 version.

  13. Jaspin

    >Does not seem to work on AI CC ?

    Worked perfectly today exporting layers w/ AI 2017, many thanks Matthew!

  14. Dot

    Thank you! You’ve just saved hours of my time <3 It's so great that there are people like you who share their knowledge and skills!

  15. Kristen

    Love your script thank you so much. But is there a way I can tweak the script to export all the layers into one multi-page high resolution pdf? I am using CS6 on a PC.

  16. katie lapi

    I love this script – but it’s creating massive pdf files for me. I don’t know how I can reduce them. I’m wondering if the data on the other layers is still retained somehow and that’s making the large files. Thanks!
    The jpg and png options are too low resolution for me so I need to use pdf.

  17. Juné

    Hi, this script seems not to be working on Ai 2022, I’ve restarted Ai and loaded the script, it works fine up until the point where you have to click on export, then the dialogue box disappears.

  18. Shawnna

    Fantastic tool! Any chance of having a setting that could also output sublayers? I have some objects that have nested variants. This is still very usable, just means my file wouldn’t be as clean.

  19. Marc

    So wanted this to work — I have 1900 layers that need exporting, think it was just too much to ask it to do. Failed everytime

  20. Zulbat

    Amazing, It works great. Just trying to figure out how to target one of the two PDF Presets I currently use for Production vs Proofs.

Comments are closed.