Free InDesign Scripts

Silicon Publishing is giving away 13 scripts written by Olav Martin Kvern. You can download them here. These range from utilities and examples of InDesign extensibility to graphic functions that generate art from parameters: some have been released in earlier versions, some have never been public before. Following are explanations of the scripts, along with references to further information.

Adding/removing items on InDesign menus

These scripts are an introduction to making changes to InDesign menus. The first one ("Add...") adds a “Path” submenu to the layout context menu – meaning that after you run the AddPathOperationsToLayoutMenu.jsx script, you can right-click on a selected item and use items on the “Path” submenu. Note that the “Add points” submenu item is best done after selecting the item with the Direct Select tool instead of the Pointer Tool. The "Remove..." script resets your menu back to normal.

Cool path art

This script applies fractal modifications to the path of a selected item. Here I turned the type to outlines, then ran the tool.

MysticRose.jsx

Draws a "mystic rose" geometric pattern, a type of construction also known as "string art". Remember the spirograph?

NOTE: Position the zero point where you want the center of your MysticRose or NINA prior to running either script.

NINA.jsx

More Spirograph-like fun. Experiment with different parameters. You can find out more about NINAs here or see a quick tutorial (in InDesign format, of course) here.

Aside from the fun artsy effects, these scripts are illuminating in how you can work with paths using a script. Plus there’s some useful code for making dialogs using the InDesign Dialog object.

Offset Path

OffsetPath.jsx

Have you ever wanted to create a new path in InDesign that follows an existing path, but is offset--inside or outside the original path--by a specified distance? Unless you're working with a path that is symmetrical around its center point, you can't use simple scaling to do this.

In Illustrator, you can use the path operation "Offset Path"--this creates a new version of a path that's offset by a given distance from the original path. InDesign doesn't have this feature. But there is an InDesign feature that we can use (abuse?) to accomplish the same task: text wrap.

When you apply a contour-type text wrap to an object, you're creating a path around that object—and you can specify an offset distance. The text wrap path is accessible via scripting. That means that we can apply a text wrap with a given offset, then capture the path and path points of that path, turn off text wrap, and then create a new path from those geometric coordinates. OffsetPath.jsx does just that.

Saving/restoring the selection state

SaveSelectionInDocument.jsxThis script remembers the current selection for re-selecting later.

SaveSelection.jsx This also saves the selection, but lets you name your selection and save more than one.

RestoreSelection.jsxThis is a companion to SaveSelection.jsx, letting you restore one or more saved selections.

Besides being useful, these scripts are instructive in some scripting practices such as the use of recursion, reverse iteration, and script labels. They store selection information inside the document itself, so using these will “dirty” the document (i.e., if you don’t save your document, the remembered selections won’t be available when you re-open the document later).

Extracting nested contents

CutContents.jsx

Cuts the contents of a selected frame and places the resulting objects in their original position on the page. This script can remove deeply-nested objects from a frame, and is much quicker than manually selecting, cutting, and pasting the contents. The script demonstrates useful techniques such as recursion, getting the “type” of a page item, reverse iteration, and application functions such as select(), cut(), and pasteInPlace().

Sizing one thing to another

SizeThingToPage.jsxResizes the current selection to the size of the page.

SizePageToThing.jsxResizes the page to the size of the current selection.

Besides being useful (for instance, you may want a page sized to an image you just placed), these scripts show how to use the resolve() and reframe() functions for getting and setting item sizes. These are better than the often-used approach of simply changing an item’s "geometricBounds" property.