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. Dave Coleman

    You’re amazing! Such a simple and incredibly useful script. Thanks so much for releasing this to the world for free. A little preview or example of what a final filename would look like (i.e. “prefix_artboard_name_suffix.png”) would be super handy, just as a wee suggestion to improve it further!

  2. Peter Stone

    This is (still) brilliant.

    Would there be a way to edit it to export all the layers turned on named views instead of artboards or individual layers? Essentially create layer comps from photoshop in Illustrator

    For example:
    Named View1 has Layers 1,2, and 3 on, Artboard 1 activated
    Named View2 has Layers 3,4, and 5 on, Artboard 1 activated
    Named View3 has Layers 1,3, and 5 on, Artboard 2 activated

    Goal: Export 1 PNG/PDF etc with the 3 named view layer/artboard settings

    Thanks!

  3. tonia

    Thanks for this tool. I have a question. Is there a way to prevent your artwork from being exported with the bounding box of the stage?

  4. Jose

    Works great on Illustrator CS5, thanks you very much! after expending couple minutes I was able to export my multilayer ai file with same background for all!!!

    Awesome!

  5. april

    I am trying to use this but no matter what I select or what options I choose I get a message something like “Will export 0 out of XX” layers… Any tips?

  6. april

    Okay so I am now succeeding with export! Yes! One thing to make it perfect – is there a way to add “trim” to the transparency so that it is only as big as items on layer? Thanks!

  7. Roger

    Hey, thanks very much for this script it is helping wonders.

    However, I noticed exporting as a PNG via the File menu gives you a better quality export than the PNG option chosen via this script, can someone explain the difference in the export options used in the script? How can I make it higher quality like you would “File>Export”?

    Thanks guys, very helpful.

  8. Justin

    Hi, a little new to illustrator. When I try to click your link to download the MultiExporter.jsx script, all it does is take me a webpage that shows the script in text form. Is it supposed to be an actual file or am I doing something wrong?

  9. Cory

    I’m having the same issue as Sasha above. This script DID work at one point, but I’m not sure if it was an update that stopped it. Or if one day it just stopped.

    After the menu all I get is a new layer with some export text. Hate having to export and then split in Acrobat.

  10. Cory

    Yes! Thanks Riasta! Great stuff, and of course special thanks to Matthew!

    Changing the file names to something aside from the default worked! Script is kick ass again. Thanks everyone!

  11. Ryan

    Thank you for doing something that Adobe has been asked since at least 2009 to do and hasn’t.

    You are a huge time saver and it is appreciated.

  12. jereld

    Hi thanks for the useful script!!! Is there any way to export different pdf quality rather than the standard quality?

  13. Nathan Scovell

    Does anyone know how to use this but make it so the display window doesn’t pop up and it just runs the process?

    Nathan

  14. Younes

    Thank you very much, this works perfectly and it’s very well explained. That saved me a lot of time and mostly the dirty job. Thanks again !

  15. Trevor

    Works great in CC 2015, OSX 10.11.3.

    @sasha You have to rename your artboard from ‘Artboard 1’ to something else before it works.

  16. Eddie Potros

    I’m getting the same issue as Sasha here

    sasha
    November 15, 2013 at 1:32 pm
    hitting export the window disappears, nothing happens, and I all I get is a layer called ‘nyt_exporter_info’ (hidden by default) with the following text:

    ~/Desktop
    100
    true
    PNG 24
    artboards

    I’m running Win7 64bit Latest Illustrator cc2015

  17. Pingback: Exporting assets for iOS, iPads and iPhones – ProtoSketch

  18. Nathan Scovell

    Hello,

    Is there a way you can attach a color profile to the PDF save setting? I Assign a Color Profile in the AI but when I run the script my PDF’s won’t save with the profile.

  19. WRONG

    WRONG! There is nothing happened with me, the script appears ok! But, When I finish the settings, I click [Export].
    And What?! Nothing. Just hiding the layers and add a layer on the first named as nyt_exporter_info

  20. Narendra

    Matthew,

    Does this script work on Mac OS? tried but didn’t work.
    Let me know your suggestions.

  21. chris

    Since downloading the latest version of Illustrator, I now get an error: “Please delete the net_exporter_info layer and try again.” not sure what this means.

  22. Pingback: Why I Work Faster and Better with Adobe Illustrator | Other Media

  23. Wayne

    This is brilliant and thanks so much for sharing it. I installed it and it worked although is there a way to expert the layers all in one PDF rather than individual PDF files ?

  24. Scott Falkner

    This script will save me a lot of time. I have to generate assets for a university rebrand. 200 departments, four logo variations, seven colour options, and up to six export options (format and resolution) for each. Thousands of files.

    What would improve this script would be better control over the export and save options. I want to specify the PDF preset used and format of the EPS. I would also like the saved EPS files to be flattened. Finally, there should be an option to save .ai files as well.

  25. Adam

    Hi! I tried to use the script and got an error message that says:
    Error 1302: No such element
    Line:13
    -> var docRef =app.activeDocument;

    Any idea what that is?

  26. Florentin

    Thanks a lot! It worked almost perfect, after i got an error-massage that
    “drag_handle” is undefined, i just tried to delete these line in the code and it worked without any error-massages

Comments are closed.