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.

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

  1. Rick Moore

    Maybe I am missing something extra, but you can also do this without the script. Select “File –> Save As…” and choose PDF as the file type and you can choose which artboards you’d like to save as PDF. Alternatively, choosing “File–>Export” will let you export any combo or all artboards to JPG, PNG, or other various file formats.

  2. Michael

    This script would’ve helped me over the last month produce, quite literally hundreds of PNG files we were producing as template layers for a Flash-based UI.

    Can it be modified to work with CS4?

  3. mericson Post author

    @Rick: I wanted to have a script where I had more control over exactly which set of artboards got exported — I’ll often have an Illustrator document with mockups of dozens of artboards for a particular project, including a number of variations of the same page. As I narrow in on final designs, I want to be able to flag which artboards shouldn’t be exported — which you can do by putting a “-” in front of the artboard name — so that I could export a complete set of just those PNGs to a folder that I can then put on one of our internal Web servers.

    If I use the built in export, each time I have to sort through which PNGs I want to share with the rest of the world and delete those files, plus all the blank artboard files. Plus, I wanted to have a little more control over the file naming — the Illustrator export does a combination of document name plus artboard name.

  4. LGFN

    Wow! Just what i was looking for! Thanks sooo much, Matthew!

    May I add my two cents? Is it possible to add an option to have all layers exported as one PDF in separate pages, instead of separate PDFs?

    Whatever the case, this is a true time saver, I solute you!

  5. Rick Moore

    “I wanted to have a script where I had more control over exactly which set of artboards got exported”…

    I work the same way. You can do this in the export dialog by specifying which artboards you want exported. For example, If I had a doc with 25 artboards and I only wanted certain sets exported, I’d just put something like, “2-5,8,11-12,21-24” (with no spaces between the commas) in the range input. It’ll skip all the others.

    You do have a good thing on the filename control, though. I usually just give the doc a concise name and name my artboards really well. Seems to work fine for my brain.

    Thanks for contributing to the Illustrator community! We need more designers to share how they make AI work for them rather than the other way around. :^)

  6. Rick

    I’m trying to find a script that will turn each artboard into a symbol (to bring into flash). Could I make a script request – unfortunately, this code/script side of things is like chinese to me.


  7. Garrett DeRossett

    Hey there,

    This script is awesome. However, I’ve used this and a few others like it to slice up images for a iOS app we’re building at my company, and every script includes these random artifacts in the slices– they’re small lines running through separate layers and I can’t for the life of me figure out what’s up.

    I would greatly, greatly appreciate it if you would shoot me an email and maybe talk through this issue with me. I’ve got a a few hundred complex Illustrator files to use this script on in the next year or so and if this issue could get fixed, that would save me so much time.


  8. ksimply

    hi to every one..the script is too good but i m looking something else

    when i export the Art board i need to keep the same name wht it is the name of the art board …but its not like that its saving as the file name plz help how to keep the name art board or the Linked images names to saving as Jpacks or PNGs somethings….plz

    file name is Trackbacks
    Art Board name is Kh1 or Kh 2 or Kh3
    Linked Images Name is Pic 1 or Pic2 or Pic 3

    i wanted to save the same ART BOARD NAME or
    LINKED IMAGE name which is in the file.
    who is the expert please help….send me at Ksimply@gmail.com
    Thanks in advance…

  9. Ageman20XX

    Hi there. I just wanted to say a really big THANK YOU for making this script. You just saved me staying at work late for several hours manually splitting PDFs into separate files. It’s programmers like you that make the world a better place. 🙂

    – Adrian

  10. Egon

    Oh, what a nice stuff!
    How many hours I spent with the stupid Export panel, with the dumb Artboard-set-back-radio-button. Eight years ago…

    Many thanks!


  11. Marco

    Hi. I came across this script and think it’s great!

    I have one request.

    I am creating UI elements for an android device and have come across the need to output png’s at different resolutions for different screen sizes. All of my assets are on multiple artboards with unique names in one file. If I use the current “Export” and then select png, I am able to select the ppi and it will save my file as the desired ppi. The only downside is that the png’s aren’t unique names. If I could have the ability to export artboards with unique names at different ppi’s that would be killer.


  12. TomoMajca

    Hi. First of all I want to say thank you! It is really great to be to find out that someone took his knowladge and time to help others in creating what is needed 😉

    I would just like to control the settings of the PDFs that are being created. How do I do that?



  13. Arizona

    Hi, quick question. Should this script work for CS3? When I try and run the script I get:

    Error 21: undefined is not an object
    Line: 41
    -> this.num_artboards = docRef.artboards.length;

    I’m assuming this is because CS3 doesn’t support artboards? Is there anyway I could change the code to ignore art boards since I only want to export each layer to a PNG?


  14. Tess

    It would be fantastic if we had control over the actual settings for the different file types before exporting. But otherwise, really useful script!

  15. Tess

    Also, would be nice if it only exported the visible layer to each file. Instead of having all the layers in each file….

  16. Matt

    Really awesome script … just have one Q. What is the quality of the exported pdf and can it be changed? Is the exported pdf ready for print?

  17. val

    I don’t understand what I am doing wrong, but no matter how I use this plugin it is always “exporting 0 of xx Layers” I am selecting my artwork, not selecting my artwork… and it I can not get it to export…

  18. tiziana

    this is awesome: thank you. I only wish you would be able to export multiple layers together based on visibility. Let’s say layer 4, 6 and 8 but not the rest on the same artboard. I was not able to do so. Not a big deal. I am very grateful for the script. I will make sure to pass it along. (-:

  19. elaine w

    for those folks who are trying to make this work with cs4 and just want to export artboards, the issue is that the script assumes that the artboard has names. unfortunately, cs4 doesn’t support artboard names but the fix is very simple. you need to modify two lines in the script to make this work:

    Change 1: this just makes the name be the artboard number and doesn’t lookup the name (which would result in an error)
    var artboardName = docRef.artboards[i].name;
    Change To:
    var artboardName = i.toString();

    Change 2: this script checks to see whether artboard names are prefaced with a minus symbol and then excludes them from the export. however, in cs4, there are no names so this check is unnecessary – we can assume that all artboards should be exported/printed.
    var num_artboards = docRef.artboards.length;
    return docRef.artboards.length;

    make sure you preserve the indentation when you make these changes. the only other quirk i encountered was that the output file has to be specified as a path – the folder chooser did not work for me and ended up trying to save to a non-existent folder in Application/AdobeIllustratorCS4/. however, if i typed in “~/Desktop/mysaves/” everything worked fine. hope this helps & good luck!

  20. Alan Luckow

    I have one major complaint about this script, that is: THAT I ONLY JUST FOUND IT NOW!

    This could have saved me so many hours of aggrivation with past projects. Thanks so much for making it available to all of us.

  21. Dozza

    I’m trying to use this to convert a CS5.5 multi layer .eps or .ai into a continuous multi-page, single layered pdf file, but having problems. Can this script do this? It never seems to see and export the correct number of layers. It also puts them out to separate files.

  22. fx1

    Hi !

    Great and thank you.
    The artboard-layer-test.ai file works but when dealing with my files or simply a blank new testing file with 3 layers (Artboard1, Artboard2, Artboard3) “Arboards (with currently visible layers)” option says it will export 0 art boards on 3.
    Also how would you make a droplet from your script to be able to drag and drop bunch of ai file on it ?

  23. mericson Post author

    Hi @fx1: You need to name your artboards something other than Artboard 1, Artboard 2 and Artboard 3. It skips artboards that have those default names, figuring that if you haven’t given the artboard an explicit name, it’s not worth exporting.

  24. fx1

    Thank you mericson for your prompt reply !

    My last request would be to have an option for batch exporting bunch of files from a folder or making a droplet from your script. What do you think ?

  25. Firas

    Sorry guys,
    this is the first time for me working with scripts, but I really need this so bad.
    but do I have to run the script by itself or run it from illustrator?
    I really dont know what to do here.
    thanks 🙂

  26. Abhishek

    I want to export all the art boards from my illustrator file into a single multipage PDF file.
    Can anyone please help me?

    For e.g. if I have 20 art boards in my illustrator file, I want all the art boards to be published into one PDF file with 20 pages.


  27. Ryan

    Great Script!!

    Any change of allowing users to select the quality of the pdf export and whether to include printing marks in the same way as the “File–>Save A Copy–>Save As Type:PDF” command does?


  28. Pingback: MultiExporter Script for Illustrator | Vectips

  29. Pingback: MultiExporter Script | Cheap Website

  30. Pingback: Graphic Design Blog » Blog Archive » MultiExporter Script

  31. Riki Yamashita

    Having a bit of an issue with the EPS file naming during export (Layers). My layer file names are numerical like 01:360 (100). When it exports, it becomes something like AI113577.tmp. When I change the extension from .tmp to .eps, it opens and features the selected visible layer in the sequence. The file still contains all the hidden layers. If I select export to PNG, the file would be named 360-(100) – missing the first two digits and the “:”.

    Could you kindly assist me in this? What do I need to tweak in the script. Thank you.

  32. Riki Yamashita

    Thanks for this script. It has been great time saver. Managed to do a work-around for the file naming by sticking to convention. Works for all now for me, except PNG24 with transparency. It has nothing to do with the script, just exceeds Illustrator’s limits. The Save for Web method states there is not enough memory to perform that operation.

  33. Pingback: About that plan… | OutUnderYourFeet Games

  34. Rebecca

    Love this script its just what Ive been looking for.

    Is there any way that is can include layers where the layer name has not been changed. I have hundreds of layers with the default name and it would take so long to rename them all.

    Unless someone knows a good batch rename script for illustrator?! Thanks

  35. Brian P

    Hey, thank you! I really love this script, but there is one crucial thing I would love as an option. A checkbox or something that would allow the exported PNGs to be trimmed to the content of a layer or use an artboard. For my purposes I have changed to false. I can try to figure out your script and add that checkbox and send you the result, but that would take me a while, can you do it easily?

    That would be awesome!


  36. Leo Lou

    Thanks for the nice script.
    is it possible to work with nested layers?
    for example
    – Blue
    – Pause
    – Play
    – Red
    – Pause
    – Play

    p.s. I am working on mascot artworks with replaceable parts.

    any help appreciated

  37. Pingback: Illustrator iOS Template (including iPad 3) - Line In Web Design

  38. Leanne

    This is not working for me at all. When I select “export layors on selected artboard” It either exports a bunch of empty image files (like, 20 for each layer) or nothing at all. Any ideas? Using CS5 on a Mac.

Leave a Reply

Your email address will not be published. Required fields are marked *