Members Only

An Introduction to Scripting in InDesign

A quick look at InDesign’s scariest feature, scripts

In the Harry Potter series of young adult novels, the villain, the dark wizard Voldemort, is so evil that the characters will not speak his name. They refer to him as “You Know Who.” This reminds me of one of my favorite features in InDesign: “You Know What.” Unlike Voldemort, this feature isn’t evil. It’s just misunderstood. You Know What is a great feature, and it can make virtually everything about working with InDesign easier, faster, and better. In fact, InDesign comes with a set of useful features implemented using You Know What that you probably don’t even know you have, already there and waiting for you to use them. You don’t even have to know anything about You Know What to start using these features—once you know where to find them, they work much like any other feature in InDesign. You Know What, of course, is InDesign scripts. If you learn one thing from this article, it should be: You do not need to know how to write scripts to be able to run scripts. This misunderstanding prevents many people from even trying to work with existing scripts, even though they might save them enormous amounts of time and trouble. You can find hundreds of InDesign scripts online—most are available for download for free—and it’s easy to install them. For that matter, chances are quite good that you can find someone who will write scripts for you and would be willing to do so for the occasional expression of admiration or a small fee.

Great Features You May Have Missed

Want to draw crop marks around the selected objects on a page? Or convert an oval to a rectangle? Run a bunch of find/change operations all at once? Select all of the image frames on a page or

spread? Sort a list of paragraphs alphabetically? All of these things, and more, can be done using the example scripts that are automatically installed with InDesign. To start using them, go to Window > Utilities > Scripts to show the Scripts panel (Figure 1). There, you’ll see a directory tree with folders and files. In the Application folder, click the Samples folder to find a collection of 20 scripts, more or less, showing how to automate the same tasks using the programming languages that you can use with your platform. Note: Scripting is one of the few cases where the capabilities of InDesign vary across platforms. Figure 1: Scripts panel with scripts installed on macOS (left) and Windows (right) Scripts written in JavaScript (JS or JSX), or the updated version of the language, UXPScript (IDJS), can be used in InDesign, no matter what platform you’re using. If you’re using macOS, you can also use AppleScript; if you’re using Windows, you can also use VBScript (VBS). Tip: The redundancy is a feature, not a bug. These sample scripts are designed to help you learn how to program scripts for InDesign by providing you with the code in multiple programming languages. You should try to do so if you’re curious! But if you just want to use these scripts, just know that you have multiple ways to do exactly the same thing.

What the Sample Scripts Do

Following is a brief description of each of the sample scripts that come installed with InDesign. You will find that most, but not all, of these scripts are available in all the programming languages (Figure 2). Figure 2: The sample scripts included with InDesign programmed in Applescript, JavaScript, UXP, and VBScript.

  • Add Guides draws guides around the selected object or objects.
  • Add Points adds additional editable points to the paths of the selected objects.
  • Add QR Code (JavaScript and UXPScript) adds a QR code to your document.
  • Adjust Page Items moves the content of even/odd pages by specified amounts to move objects back into the correct position after a parent page margin change and/or page insertion.
  • Align to Page aligns the items in the selection to the specified location on the page.
  • Animation Encyclopedia creates a six-page sample document demonstrating the InDesign Animation feature.
  • Break Frame removes the selected text frame (or text frames) from the story containing the text frame and removes the text contained by the text frame from the story.
  • Corner Effects applies corner effects to the selected object.
  • Create Character Style: When you create a character style in InDesign, only the properties of the selected text that differ from the default formatting of the text surrounding it are added to the character style. This script creates a complete character style based on all the formatting of the selected text.
  • Crop Marks draws crop marks and/or registration marks around the selected object or objects.
  • Export All Stories exports all of the stories in a document to a specified folder as individual files in plain text or InDesign Tagged Text (TXT) or RTF files.
  • Find Change by List (AppleScript and JavaScript only) lets you create a text file with a series of tab-delimited strings and then automatically performs Find/Change operations in sequence.
  • Image Catalog creates an image catalog from the graphic files in a selected folder, similar to a contact sheet.
  • Make Grid divides the selected frame (or frames) into grid(s) of frames.
  • Neon creates a glow-like effect around the selected paths, resulting in something like a blend in Illustrator.
  • Path Effects changes the shape of the paths of the selected objects, replicating some popular Illustrator effects (Bloat, Twirl, and Punk) and more sophisticated variants (PunkBloat, BloatPunk, and AntiTwirl).
  • Place Multipage PDF places all pages of a multipage PDF into an existing document or, if you wish, a new document it builds as it’s placing each page.
  • Select Objects selects all objects of a given type or types (rectangles, ellipses, polygons, lines, text frames, groups, images, PDFs, EPSes) on the active spread.
  • Sort Paragraphs sorts the paragraphs in the selection alphabetically.
  • Split Story takes text that’s threaded in multiple text frames and breaks it into individual stories in unlinked text frames.
  • Tab Utilities sets a tab or an indent at the current cursor position, or sets a right tab exactly at the right edge of the text column.

Community Scripts Add Functionality

In 2020, Adobe introduced a new folder of cross-platform scripts to InDesign. These Community Scripts are created by members of the InDesign community and maintained as open-source projects on GitHub. By default, InDesign installs the following:

  • Break Text Thread (by Ariel Walden) makes breaking the thread between text frames easy.
  • Clear Style Overrides (by Gregor Fellenz) removes all paragraph, character format ,table and object format overrides.
  • Insert Typographer Quote (by Stefan Rakete) lets you select text and insert the proper typographic quotation marks before and after the selection. You have multiple versions of the script to use for quotes in different languages.
  • Snap Margins to text frame (by Ariel Walden) redefines your document’s margins to the size of the selected text frame.
  • Unicode Injector (by Kris Coppieters) lets you easily define sequences of Unicode characters simply by duplicating and renaming the file.

You can see the full collection of Community Scripts, and download additional scripts, from the GitHub repository.

What Else Can Scripts Do?

Scripts can do just about anything that you can do using InDesign’s user interface, and a few things that you can’t do. Don’t think about scripting only in terms of automating tedious, repetitive tasks. Scripting’s good for that, but you can also use it to speed up the smaller tasks that drive you crazy during the day. When you take a common task that involves some number of actions and replace it with a simple double-click or keystroke (all it takes to run a script), you reduce the difficulty and complexity of your work. To install new scripts:

  1. Highlight the Application folder in the Scripts panel (to make the script available to all users on your computer) or the User folder (to make the script available only to you).
  2. Control-click/right-click the folder icon and select the Reveal in Finder/Reveal in Explorer command to automatically open the correct folder.
  3. Copy the script into the folder.

You can find plenty of amazing scripts, showing the depth and breadth of what can be automated, on CreativePro.com, along with more comprehensive instructions and tutorials for installing and maintaining your collection.

Bookmark
Please login to bookmark Close

Not a member yet?

Get unlimited access to articles and member-only resources with a CreativePro membership.

Become a Member

Comments (0)