32 Replies Latest reply: May 21, 2013 9:00 PM by findapennny RSS

    Shrink Artboard to fit content

    Community Member
      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?
        • 1. Re: Shrink Artboard to fit content
          Nini Tjäder Community Member
          Why would you want to shrink the artboard? Are you sure you don't mean the pagesize?
          • 2. Re: Shrink Artboard to fit content
            Community Member
            I think Artboard and Pagesize is the same thing.

            In the [View] menu there is a [Show/Hide Artboard] command, that's the one I want to shrink/resize. Right now I do it manually. First I select all the objects in the document. Then I go to [File>Document Setup...] and change the width and hight under 'Artboard Setup' by copying the values from the Transform panel. I'm trying to automate this process with a 'Shrink to Fit' command, but couldn't find one.

            The reason I want to do this, is so the file thumbnails/previews in Adobe Bridge and other Viewers show only the content without all the white space around it which makes the content very small to see sometimes.
            • 3. Re: Shrink Artboard to fit content
              Nini Tjäder Community Member
              From the Help files for Illustrator CS3:

              The printable area is bounded by the innermost dotted lines and represents the portion of the page on which the selected printer can print. Many printers cannot print to the edge of the paper.

              The nonprintable area is between the two sets of dotted lines representing any nonprintable margin of the page.

              The page edge is indicated by the outermost set of dotted lines.

              The artboard is bounded by solid lines and represents the maximum printable area. To hide the artboard boundaries, choose View > Hide Artboard.

              The scratch area is the area outside the artboard that extends to the edge of the 227‑inch square window. The scratch area represents a space on which you can create, edit, and store elements of artwork before moving them onto the artboard. Objects placed onto the scratch area are visible on‑screen, but they do not print.

              ----

              From that follows that if you change the pagesize you also change the size of the artboard. Semantics maybe, but if you make a huge artboard you can actually tile multiple pages - sizes of which are set by those of your paper size for printing - inside that artboard. You can also make an artboard that is smaller than the papersize if you so choose and by moving the page-outline with the pagetool decide what part of the page to print.
              • 4. Re: Shrink Artboard to fit content
                Community Member
                Nini, you're missing the point here. What Hakoon wants, and myself also, is a plugin or script with which you can have illustrator automatically snap the size of the artboard to the bounding box of the artwork you load.
                I would like something like this very much too, since I have to import and then edit loads and loads of technical drawings, that are sent to me as WMF's. (since wmf is the only fileformat we found that the 3D-designers software can output and that I can import in illustrator without problems, we tried all other options, please don't suggest I try another format, thx)
                The ONLY problem is, that when I open such a WMF, the artboard is always set to240x120mm...
                So, I have to manually set the artboard to the bounding-box size of the artwork... A tool that would automate this would be VERY helpful!
                • 5. Re: Shrink Artboard to fit content
                  JETalmage Community Member
                  > What Hakoon wants, and myself also, is a plugin or script with which you can have illustrator automatically snap the size of the artboard to the bounding box of the artwork...

                  As for scripting: The AI scripting model provides read-only access to the current document Artboard size.

                  JET
                  • 6. Re: Shrink Artboard to fit content
                    Community Member
                    I see what the first poster is talking about. Viewing AI files in Bridge really sucks because none of the scratch area shows up in Bridge's thumbnail preview. If either there was a way to change the artboard size to match the document objects boundary, or a way in Bridge to customize the viewing extents of the thumbnails to include the scratch areas of AI files, then that would be awesome.

                    As it stands, you can do neither. Viewing scratch areas in the thumbnails in Bridge would make Bridge immensely more useful.

                    -Peter
                    • 7. Re: Shrink Artboard to fit content
                      Steve Fairbairn Community Member
                      An automatic shrink (or snap) artboard to fit content would be extremely useful.

                      With the advent of AI 10, Illy suddenly got fussy about the artboard size. Prior to that it didn't make much difference what the size of the artboard was. But now that output is controlled via Print, making a cropped pdf straight from Illy requires the artboard size to be exactly right, so a shortcut would be most welcome.

                      Saving Illy files as EPS and then using Distiller alleviates the problem but that artboard thing is still a nuisance.
                      • 8. Re: Shrink Artboard to fit content
                        CupertinoFruit Community Member
                        You have this feature in AI CS4 - fit an artboard to artwork bounds or to selected art.
                        • 9. Re: Shrink Artboard to fit content
                          Wade S Zimmerman Community Member
                          Yu do I thought it was in CS 3 as well I guess that is not so.

                          Did anyone double click the artboard tool to see if there is this option in CS3?
                          • 10. Re: Shrink Artboard to fit content
                            Doug Katz Community Member
                            Is there even an artboard tool in CS3? Do you mean the crop tool, Wade?
                            • 11. Re: Shrink Artboard to fit content
                              Wade S Zimmerman Community Member
                              Is that what they called it?
                              • 12. Re: Shrink Artboard to fit content
                                JETalmage Community Member
                                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
                                • 13. Re: Shrink Artboard to fit content
                                  Community Member
                                  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.
                                  • 14. Re: Shrink Artboard to fit content
                                    Community Member
                                    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?
                                    • 15. Re: Shrink Artboard to fit content
                                      ficholasnorneris Community Member

                                      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.

                                      • 16. Re: Shrink Artboard to fit content
                                        dnewmanSFBR Community Member

                                        Me too, me too!!!!

                                        • 17. Re: Shrink Artboard to fit content
                                          CarlosCanto MVP

                                          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");
                                              }
                                          

                                          • 18. Re: Shrink Artboard to fit content
                                            Muppet Mark-QAl63s Community Member

                                            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?

                                            • 19. Re: Shrink Artboard to fit content
                                              dnewmanSFBR Community Member

                                              Out of the blue!!!  Thank you! I'll bug my boss about upgrading to CS5.

                                              • 20. Re: Shrink Artboard to fit content
                                                dnewmanSFBR Community Member

                                                Thanks for the suggestions, I'll look into these.

                                                • 21. Re: Shrink Artboard to fit content
                                                  CarlosCanto MVP

                                                  you're welcome

                                                  • 22. Re: Shrink Artboard to fit content
                                                    Rhiannon Miller Community Member

                                                    CarlosCanto wrote:

                                                     

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

                                                     

                                                     

                                                    Sorry Carlos, I have CS5 (and CS5.1) and I'm still unable to record the changing of the artboard size as an Illustrator action.  Could you explain how to do this in CS5 please?

                                                    • 23. Re: Shrink Artboard to fit content
                                                      PrepressPro1 Community Member

                                                      #target illustrator

                                                      function fitArtboards() {
                                                          
                                                           if (app.documents.length == 0) {
                                                               
                                                                alert('Open a document before running this script');
                                                               
                                                                     return;
                                                                    
                                                           } else {
                                                               
                                                                for (var i = 0; i < documents.length; i++ ) {
                                                                    
                                                                     app.activeDocument = documents[i];
                                                                    
                                                                     app.activeDocument.artboards[0].artboardRect = app.activeDocument.geometricBounds;
                                                                    
                                                                     redraw();
                                                                    
                                                                }
                                                           }
                                                      }

                                                      fitArtboards();

                                                      • 24. Re: Shrink Artboard to fit content
                                                        CarlosCanto MVP

                                                        Rhiannon Miller wrote:

                                                         

                                                        CarlosCanto wrote:

                                                         

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

                                                         

                                                         

                                                        Sorry Carlos, I have CS5 (and CS5.1) and I'm still unable to record the changing of the artboard size as an Illustrator action.  Could you explain how to do this in CS5 please?

                                                         

                                                        Hi Rhiannon, sorry for the confusion, I didn't mean you could record an action in CS5, I meant you could do it manually in CS5.

                                                         

                                                        I'll give it try tomorrow, I have CS5 at work. I'll let you know.

                                                        • 25. Re: Shrink Artboard to fit content
                                                          obeacon Community Member

                                                          Hi, I've been following this thread and have a similar issue.  I'm working in CS4.  I believe I have the right script to shrink the artboard to fit my content--thanks, everyone!--but now I'd like to automate the whole thing so that it will open, run the script and save.  I've got a few hundred very similar images here and obvs running the script on each individually is overwhelming.  I'm not clear why running a script cannot be a recordable action, but so it goes. 

                                                           

                                                          Can someone please explain the basics of getting a code to do this?  I don't even know--would I run it in Script Editor?

                                                          Advice?

                                                           

                                                          Thanks!

                                                          Trevor

                                                          • 26. Re: Shrink Artboard to fit content
                                                            Muppet Mark Community Member

                                                            Script Editor is Apple's AppleScript utility… The above code is JavaScript and its best to use the Adobe ExtendScript Toolkit to edit and save…

                                                            • 27. Re: Shrink Artboard to fit content
                                                              obeacon Community Member

                                                              Hi Mark,

                                                              I'm a dummy compared to this forum--So If I drop the code above into ExtendScript and run it, that will perform the task of the script I've identified...?

                                                              Thanks so much.        Trevor    

                                                              • 28. Re: Shrink Artboard to fit content
                                                                Muppet Mark Community Member

                                                                You can C&P from the post above… If you use the sample by Prepress then it should work with all open documents… Paste into a new document window in the ESTK from there you can test/run with Illustrator as the selected target… or you could save to file what ever you want to call it and file extension '.jsx' drop that in your Illustrator scripts and restart the app… I would have used visibleBounds over geometricBounds myself but hey ho each to their own…

                                                                • 29. Re: Shrink Artboard to fit content
                                                                  vendenberg Community Member

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

                                                                  • 30. Re: Shrink Artboard to fit content
                                                                    tynmanout Community Member

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

                                                                    • 31. Re: Shrink Artboard to fit content
                                                                      JETalmage Community Member

                                                                      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

                                                                      • 32. Re: Shrink Artboard to fit content
                                                                        findapennny Community Member

                                                                        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.