Scripts that perform 2D bin packing on Adobe Illustrator artboards and Adobe Indesign pages, automating the process of arranging selected page items into artboards or pages, with the aim of achieve a reasonably tight packing.
Update 2024-10-23: showing new Allow Any Rotation
capability:
If this project will save you time, please consider supporting me:
Download script files (zipped):
The repository contains the following script files:
Bin Packing--Artboards.js
(for Adobe Illustrator)Bin Packing--Pages.js
(for Adobe InDesign)Packer.js
(required helper script)packer-blocks.js
(required helper script)
Note: Ensure that
Packer.js
andpacker-blocks.js
are located in the same directory as the main script you want to run.
Move the downloaded files to your Adobe application's ExtendScript folder.
See How To Install Scripts in Adobe Illustrator and How To Install Scripts in Adobe Indesign.
- Open your Adobe Illustrator or InDesign application.
- Add artboards or pages as needed. The script will try to pack the items into these "bins". If you do not have enough bins, the script may not find a solution.
- Select the items you want to pack.
- Open the
Scripts
panel fromWindow > Utilities > Scripts
(InDesign) or from theFile > Scripts
menu (Illustrator). - Choose either
Bin Packing--Artboards.js
orBin Packing--Pages.js
to execute the script.
-
Prepare your document: Open an Adobe InDesign document and select the items you wish to pack.
-
Run the script: Execute the script, which will pack your selected items onto the available pages.
-
Options:
- Space between items: The space between packed items.
- Margin: The space between packed items and the bin's outer edges.
- Divide Bins at Guides: (Indesign only) Whether to use guides in the document to split pages into multiple bins.
- Maximum attempts: The number of attempts to make before giving up. Note: the script will only reach this maximum if no packing has been successful, or if
Try harder
is enabled. - Try Harder: Whether to continue testing new attempts even after all items are successfully packed. Do this if you are looking for a better packing result.
- Random Packing: Perform a single random-shuffle packing for an aesthetic or experimental result.
- Custom Scoring: Choose to prefer either packing more items or maximizing the packed area.
- Allow 90° rotation Allow items to be rotated by 90° during packing.
- Allow any rotation Allow items to be rotated so that they fit best into a rectangle. This will generally achieve tighter packing, but will rotate the items by arbitrary amount between 0 and 90°.
Created by Mark Bean ("m1b"), inspired by this community discussion. The scripts rely on the 2D bin packing algorithm shared by Trentium (see acknowledgements below).
The 2D bin packing algorithm is by Stackoverflow user trentium published here and for which I am very grateful.
I also acknowledge Adobe community forum user "MarioRossiGD" for support the development of the Indesign version of the original script.
This project is open-source and available under the MIT License. See the LICENSE file for details.