Skip to main content
Participant
July 4, 2008
Question

Shrink Artboard to fit content

  • July 4, 2008
  • 19 replies
  • 69789 views
I've been searching everywhere for a script or plugin that will shrink the artboard to fit the content. Fireworks has a feature like that. Has anyone done this in Illustrator?
    This topic has been closed for replies.

    19 replies

    rcraighead
    Legend
    December 22, 2015

    I have not read every post in this thread. I routinely fit the artboard to the artwork by choosing "Edit Artboard" (Shift+O) and double-clicking the group or object I want to size the current artboard to. Works great (CS5). I'm sure this has already been discussed, just to lazy to read all the posts.

    Participant
    July 21, 2015

    CS6: Objects > Artboard > Fit to selected art

    Participant
    December 22, 2015

    CS5: select artboard > objects > Artboards > Fit to artwork bounds

    February 10, 2013

    I just tried the Artboard Tool. Shift-O, then double-click on the image. Save. Done.

    JETalmage
    Inspiring
    February 10, 2013

    ALWAYS state the version you are using.

    You are resurrecting a thread that started almost 5 years ago. In the current version (16), there is a command for fitting the artboard to artwork. That did not exist back then.

    JET

    Participant
    May 22, 2013

    The question wasn't about whether it's possible, it's about how to record that action into a script. When you record a script it does not record that step in CS5 or earlier. (Not sure if it does in later versions.) To do so you must choose (from Actions menu, as you're recording the script) Insert Menu Item and then choose from the menu Object [sorry I can't remember the name of the command and I don't have CS5 here] something like Fit to Artboard.

    Participant
    October 5, 2011

    Document setup - Edit Artboard - then double click on image.

    Participant
    May 3, 2011

    Me too, me too!!!!

    CarlosCanto
    Community Expert
    Community Expert
    May 4, 2011

    wow, such an old post, all the OP and others requests are now possible with CS5.

    here you go, for you and other CS4 users

    #target Illustrator

    //  script.name = shrinkABtoFitArt_CS4.jsx;

    //  script.description = resizes active artboard to fit the the Art (+ margins);

    //  script.required = one document with at least one piece of art;

    //  script.parent = carlos canto // 5/3/11;

    //  script.elegant = false;

    if (app.documents.length > 0)

        {

            //alert("more than 0");

              var idoc = app.activeDocument;

              var pageItemsCount = idoc.pageItems.length;

            if (pageItemsCount>=1)

                {

                        var msg = "Enter Artboard Margins \n";

                        msg += "\nEnter negative numbers to cancel";

                        

                        var margins = Number(Window.prompt (msg, 10, "CS4 Shrink Arboard to Fit"));

                        if (margins>=0)

                             {

                                  

                                  var activeABindex = idoc.artboards.getActiveArtboardIndex();

                                  var newAB = idoc.artboards[activeABindex];

                                  var iartBounds = idoc.visibleBounds;

                                  

                                  var ableft = iartBounds[0]-margins;

                                  var abtop = iartBounds[1]+margins;

                                  var abright = iartBounds[2]+margins;

                                  var abbottom = iartBounds[3]-margins;

                                  

                                  newAB.artboardRect = [ableft, abtop, abright, abbottom];

                                  

                                  var myZoom = idoc.activeView.zoom;

                                  idoc.activeView.zoom = myZoom+.01;

                                  idoc.activeView.zoom = myZoom;

                             }

                        else

                             {

                                  alert("nos vamos");

                             }

                 }

             else

                {

                    alert("there is no art in the active document");

                 }

         }

    else

        {

            alert ("there are no open documents");

        }

    Muppet_Mark-QAl63s
    Inspiring
    May 4, 2011

    I never had CS4 but Illustrator has options for opening files and handling artboards…

    convertCropAreaToArboard

    convertTilesToArboard

    createArtboardWithArtworkBoundingBox // This may be what you want?

    preserveLegacyArtboard

    You could batch script opening files… even script it to work from bridge as input… I don't use actions so I don't know it these options are available when recording some open file in AI?

    Participant
    March 5, 2009
    I understand how to re size the art board in AI CS4 (fit to art work bounds). I'd like to run an action on this art board feature.

    Basically I want to run a re size (say all images down to a constrained 5" width) on my image and bring the art board down with it using an action. Of course I have like 300 to do so I'd like to batch all the work.

    I can "action" a re size but it won't record my "action" of the art board "fit to art work bounds".

    Ideas?
    ficholasnorneris
    Participant
    May 29, 2009

    Right, yes there is this functionality in CS4 - what the OP, myself, and many others want is a way to make it more automatic - like a keyboard shortcut to snap the artboard to selected art, all art, or what have you. If it's in Fireworks, why not have it in Illustrator. At least, if nto a shortcut, a way to script it, or put it in an action would be nice.

    Participating Frequently
    October 25, 2008
    In AI CS4, artboards are movable and resizable; they can be forced to snap to artwork bounds or the bounds of just the selected art.
    JETalmage
    Inspiring
    October 22, 2008
    In CS3 and prior, Illustrator's Artboard is not moveable from the center of the pasteboard. So if your artwork is not centered, setting the Artboard size to the size of the content of your file would not likely do what you want.

    The scripting model does not provide access to the Artboard size. It is read-only. When scripters need to resize an Artboard, they resort to workarounds involving creation of a new document.

    JET
    Participating Frequently
    October 21, 2008
    Is that what they called it?
    October 21, 2008
    Is there even an artboard tool in CS3? Do you mean the crop tool, Wade?