Indentz
Cleanup | Layout | Align | Fit | Scale | Proxy | File | Export | View | Miscellaneous | Install | About
This is a collection of InDesign scripts for various simple and repetitive tasks.
As an artworker, I often have to perform repeated, tedious, or time-consuming operations. Working from home during the Covid lockdown, I used the extra time to learn a bit of the (now ancient) Extendscript 'art'.
The code was developed and tested in Adobe InDesign CC 2020–2022 on Mac (but I mostly used InDesign ExtendScript API 8.0 for compatibility with CS6). I'm a graphic designer, not a programmer, so do expect oversights and bugs (please create an issue if you encounter one, though).
Usage
Cleanup
Defaults and cleanup.
DefaultPrefs
Sets some preferences for the active document.
Details
Application:
Preferences ‣ General: Prevent Selection of Locked Objects
Preferences ‣ Display Performance: Preserve Object-Level Display Settings
Preferences ‣ File Handling: Always Save Preview Images with Documents
View ‣ Screen Mode: Normal
View ‣ Grids & Guides: Snap to Guides; Smart Guides
Windows ‣ Layers: Ungroup Remembers Layers; Paste Remembers Layers
Windows ‣ Objects & Layout ‣ Transform: Reference Point: Center; Adjust Stroke Weight when Scaling; Adjust Effects when Scaling
Windows ‣ Output ‣ Preflight: Off
Document:
Adjust Layout: Off
Document Intent: Print
Rulers: Zero Point: Reset
Preferences ‣ Type: Use Typographer's Quotes; Apply Leading to Entire Paragraphs
Preferences ‣ Units & Increments ‣ Keyboard Increments: Cursor Key: 0.2 mm; Size/Leading: 0.5 pt; Baseline Shift: 0.1 pt; Kerning/Tracking: 5/1000 em
Preferences ‣ Units & Increments ‣ Ruler Units: Origin: Spread; Units: Millimeters
Preferences ‣ Units & Increments ‣ Other Units: Stroke: Points
Preferences ‣ Grids: Baseline Grid Color: R=230 G=230 B=230
Preferences ‣ Guides & Pasteboard: Preview Background Color: Light Gray
Edit ‣ Transparency Blend Space: Document CMYK
Edit ‣ Color Settings ‣ Working Spaces: RGB Profile: sRGB IEC61966-2.1; CMYK Profile: ISO Coated v2 (ECI), fallback to Coated FOGRA39 (ISO 12647-2:2004)
View: Show Rulers
View ‣ Extras: Show Frame Edges
View ‣ Grids & Guides: Show Guides; Unlock Guides; Snap to Guides
Windows ‣ Color: Fill: None; Stroke: None
Windows ‣ Effects: Blending Mode: Normal; Opacity: 100%
Windows ‣ Output ‣ Attributes: Nonprinting: Off
Windows ‣ Pages: Allow Document Pages to Shuffle
Windows ‣ Type & Tables ‣ Paragraph: Shading: Off
DefaultLayers
Adds a set of layers defined in a TSV data file named layers.tsv
(sample) saved locally (meaning the active document folder or its parent), or as a global default (on the desktop, next to the script, or in Indentz
root); local files and those starting with _
take precedence:
Name | Color | Visible | Printable | Order | Variants |
---|---|---|---|---|---|
dielines | Magenta | yes | yes | above | cut*, decoupe, die, die*cut, stanz* |
text | Green | copy, headline*, hl, text*, txt, typ? | |||
bg | Red | below | back, *background*, bgg, fond, hg, hintergrund* | ||
template | Gray | no | no | below | |
... |
Name: Layer name
Color: Layer color (defaults toLight Blue
; seeUIColors.txt
for color names)
Visible:yes
orno
(defaults toyes
)
Printable:yes
orno
(defaults toyes
)
Order:above
orbelow
existing layers (defaults toabove
)
Variants: A list of layers that will be merged with the base layer; it's case insensitive and can take simple wildcards (?
and*
)
Additional features
A line may also contain a statement:
@includepath
reference/path
– defines a folder to which subsequent relative paths will refer;@include
path/to/other.tsv
– includes another TSV file at this position;path/to
may be an absolute path, one relative to the current data file, or a path relative toreference/path
if defined;@defaults
– includes the global data file;
There's also some non-standard stuff that will confuse Excel et al.:
- Blank lines and those starting with
#
(comments) are ignored; - The fields can be visually aligned with spaces that will be removed at processing (I use VS Code and Rainbow CSV);
- A very long line can be broken into multiple lines with a backslash (
\
) added at the end of each segment.
DefaultSwatches
Adds a set of swatches defined in a TSV data file named swatches.tsv
(sample) saved locally (meaning the active document folder or its parent), or as a global default (on the desktop, next to the script, or in Indentz
root); local files and those starting with _
take precedence:
Name | Color Model | Color Space | Values | Variants |
---|---|---|---|---|
Rich Black | process | cmyk | 60 40 40 100 | |
RGB Grey | process | rgb | 128 128 128 | |
Cut | spot | cmyk | 0 100 0 0 | couper, die*cut |
... |
Name: Swatch name
Color Model:process
orspot
(defaults toprocess
)
Color Space:cmyk
,rgb
orlab
(defaults tocmyk
)
Values: a list of numbers separated by space (), comma (
,
), pipe (|
) or slash (/
):
- 3 values in 0–255 range for RGB
- 4 values in 0–100 range for CMYK
- 3 values in 0–100 (L), –128–127 (A and B) range for Lab
Variants: a list of swatches that will be replaced by the base swatch; it's case insensitive and can take simple wildcards (
?
and*
)
You can use SwatchesSave
to save a tab delimited list of swatches from any document.
Additional features
A line may also contain a statement:
@includepath
reference/path
– defines a folder to which subsequent relative paths will refer;@include
path/to/other.tsv
– includes another TSV file at this position;path/to
may be an absolute path, one relative to the current data file, or a path relative toreference/path
if defined;@defaults
– includes the global data file;
There's also some non-standard stuff that will confuse Excel et al.:
- Blank lines and those starting with
#
(comments) are ignored; - The fields can be visually aligned with spaces that will be removed at processing (I use VS Code and Rainbow CSV);
- A very long line can be broken into multiple lines with a backslash (
\
) added at the end of each segment.
ReplaceFonts
Replaces document fonts using a TSV data file named fonts.tsv
(sample) saved locally (meaning the active document folder or its parent), or as a global default (on the desktop, next to the script, or in Indentz
root); local files and those starting with _
take precedence:
Old font family | Style | New font family | Style |
---|---|---|---|
Arial | Regular | Helvetica Neue | Regular |
Arial | Bold | Helvetica Neue | Bold |
... |
You can use ShowFonts
from Miscellaneous to get a tab delimited list of document fonts for copy-pasting.
Additional features
A line may also contain a statement:
@includepath
reference/path
– defines a folder to which subsequent relative paths will refer;@include
path/to/other.tsv
– includes another TSV file at this position;path/to
may be an absolute path, one relative to the current data file, or a path relative toreference/path
if defined;@defaults
– includes the global data file;
There's also some non-standard stuff that will confuse Excel et al.:
- Blank lines and those starting with
#
(comments) are ignored; - The fields can be visually aligned with spaces that will be removed at processing (I use VS Code and Rainbow CSV);
- A very long line can be broken into multiple lines with a backslash (
\
) added at the end of each segment.
ReplaceLinks
⌥F8
Replaces document links using a TSV data file named links.tsv
(sample) saved locally (meaning the active document folder or its parent), or as a global default (on the desktop, next to the script, or in Indentz
root); local files and those starting with _
take precedence:
Relink to | Document links |
---|---|
/absolute/path/to/img1.psd | img1_lowres.jpg, img1-rgb.* |
img2.psd | img2.* |
@includepath reference/path |
|
img3.psd | |
subfolder/img4.psd | |
... |
Relink to (also see Additional features below):
- An absolute path of the form
/absolute/path/to/img1.psd
;- A relative path which is:
- relative by default to the document
Links
folder (img2.psd
);- relative to
reference/path
defined by a previous@includepath
statement (img3.psd
andsubfolder/img4.psd
).Document links:
- If empty, the name from the first column will be used (so that if it's in the document, it will be replaced);
- One or more document link names; it's case insensitive and can take simple wildcards (
?
and*
).
Quoting the paths is not required.
Additional features
A line may also contain a statement:
@includepath
reference/path
– defines a folder to which subsequent relative paths will refer;@include
path/to/other.tsv
– includes another TSV file at this position;path/to
may be an absolute path, one relative to the current data file, or a path relative toreference/path
if defined;@defaults
– includes the global data file;
There's also some non-standard stuff that will confuse Excel et al.:
- Blank lines and those starting with
#
(comments) are ignored; - The fields can be visually aligned with spaces that will be removed at processing (I use VS Code and Rainbow CSV);
- A very long line can be broken into multiple lines with a backslash (
\
) added at the end of each segment.
ReplaceSnippets
⌥F6
Replaces a list of text snippets using a TSV data file named snippets.tsv
(sample) saved locally (meaning the active document folder or its parent), or as a global default (on the desktop, next to the script, or in Indentz
root); local files and those starting with _
take precedence:
Find what | Change to | Case sensitive | Whole word | Scope |
---|---|---|---|---|
English instructions | Deutsche anleitung | yes | yes | |
The sample is for free | Das Sample ist kostenlos | yes | yes | _DE$ |
The sample is for free | L'échantillon est gratuit | yes | yes | _FR$ |
12.06.22 | 13.11.2022 | |||
... |
Find what: Text to be replaced (you can use special characters)
Change to: The replacement text
Case sensitive:yes
orno
(defaults toyes
)
Whole word:yes
orno
(defaults toyes
)
Scope: Replacement will only be done if the document name matches the regular expression1 (case sensitive)
Additional features
A line may also contain a statement:
@includepath
reference/path
– defines a folder to which subsequent relative paths will refer;@include
path/to/other.tsv
– includes another TSV file at this position;path/to
may be an absolute path, one relative to the current data file, or a path relative toreference/path
if defined;@defaults
– includes the global data file;
There's also some non-standard stuff that will confuse Excel et al.:
- Blank lines and those starting with
#
(comments) are ignored; - The fields can be visually aligned with spaces that will be removed at processing (I use VS Code and Rainbow CSV);
- A very long line can be broken into multiple lines with a backslash (
\
) added at the end of each segment.
BreakLinkToStyles
Unnaplies paragraph/character/object styles from the selected objects or all objects in the document if nothing is selected.
DocCleanup
F2
It runs DefaultPrefs
; deletes unused swatches, layers and spreads; unlocks all objects and resets their scaling to 100%; optionally deletes hidden objects; resets default transparency effects; converts empty text frames to generic frames and empty frames to graphic frames; sets tight pasteboard margins.
SwatchesCleanup
⇧F2
Converts process RGB swatches to CMYK and renames them to 'C= M= Y= K=' format. It also deletes unused swatches and removes duplicates. Spot colors are not changed.
DumpLayers
Saves a TSV file (compatible with DefaultLayers
) containing the names and properties of the active document layers.
DumpSwatches
Saves a TSV file (compatible with DefaultSwatches
) containing the names and properties of the active document swatches.
Layout
Document setup – page size, margins & columns, guides.
PageSizeFromFilename
F3
Sets the size of the page and the margins/visible area, getting dimensions from the document name. It looks for pairs of numbers like 000x000
(where 000
means a group of at least one digit, followed or not by decimals, and optionally by mm
or cm
). If only one pair is found, it sets the size of the page. If two are found (e.g., 000x000_000x000
), the larger pair sets the page size, the smaller pair the visible area. If a one- or two-digit sequence follows, it sets the bleed. Example:
Filename | Total size | Visible area | Bleed |
---|---|---|---|
Document1_315x55.indd | 315×55 | – | – |
Document2_1400x400_700x137mm.indd | 1400×400 | 700×137 | – |
Document3_597x517_577x500.5_3mm V4.indd | 597×517 | 577×500.5 | 3 |
PageSizeFromMargins
Resizes the current page to its margins.
PageSizeFromSelection
⇧F3
Resizes the page to the selected objects.
PageMarginsFromSelection
⌥F3
Sets the page margins from the selected objects.
GuidesAdd
If any page objects are selected, it adds guides around them. If nothing is selected, it adds guids on page edges and in the middle of margins; a second run deletes them.
GuidesDelete
Deletes all guides from the document.
Align
Align page objects with ease using the numeric keypad.
ToggleAlignTo
Num0
Toggles Align To between selection, margins, page or spread (just run it repeatedly):
ResetAlignTo
⌃Num0
Resets Align To to default (Align to Selection).
AlignTo...
Use the numeric keypad to instantly align the selected object to the Align To selection, with a single keystroke.
Shortcuts
Left | Key | Center | Key | Right | Key |
---|---|---|---|---|---|
AlignToTL.jsx | Num7 | AlignToT.jsx | Num8 | AlignToTR.jsx | Num9 |
AlignToL.jsx | Num4 | AlignToC.jsx | Num5 | AlignToR.jsx | Num6 |
AlignToBL.jsx | Num1 | AlignToB.jsx | Num2 | AlignToBR.jsx | Num3 |
Fit
FitToPage...
/ FitToSpread...
These scripts reframe the selected objects to the page/spread or their margins/bleed by reducing the edges of objects or clipping frames that cross the target and extending ones that touch it or are very close (in a 1% snap zone).
Rectangular frames and orthogonal lines are simply resized; rotated objects, ovals, groups, etc. are inserted into a clipping frame that is resized.
FitTo...Forced
bluntly reframes an object to the target.
Shortcuts
Page | Key | Spread | Key |
---|---|---|---|
FitToPage.jsx | F11 | FitToSpread.jsx | F12 |
FitToPageMargins.jsx | ⌥F11 | FitToSpreadMargins.jsx | ⌥F12 |
FitToPageVisibleArea.jsx | ⌥⇧F11 | FitToSpreadVisibleArea.jsx | ⌥⇧F12 |
FitToPageBleed.jsx | ⇧F11 | FitToSpreadBleed.jsx | ⇧F12 |
FitToPageForced.jsx | ⌘F11 | FitToSpreadForced.jsx | ⌘F12 |
FitToPageMarginsForced.jsx | ⌥⌘F11 | FitToSpreadMarginsForced.jsx | ⌥⌘F12 |
FitToPageVisibleAreaForced.jsx | ⌥⇧⌘F11 | FitToSpreadVisibleAreaForced.jsx | ⌥⇧⌘F12 |
FitToPageBleedForced.jsx | ⇧⌘F11 | FitToSpreadBleedForced.jsx | ⇧⌘F12 |
Note: F11
page, F12
spread; ⌥
margins, ⌥⇧
visible area, ⇧
bleed; ⌘
forced.
TextAutosize
F6
Auto-sizes the selected text frames to their content. It's designed to be run repeatedly.
The level is increased from None to Height Only and from Height Only to Height and Width (single lines are always set Height and Width). The reference point is set by the first paragraph alignment and the text frame vertical justification:
Paragraph Alignment → ↓ Vertical Justification |
|||
---|---|---|---|
Note: A second run will preserve the current auto-sizing if only the alignment is different.
Scale
ScaleToPageSize
/ ScaleToPageMargins
/ ScaleToSpreadBleed
Scales the selected objects to the page size, page margins, or spread bleed. All objects are scaled together, as a group.
The ScaleTo...H
and ScaleTo...W
variants scale to the height or width of their target.
Shortcuts
Page | Key | Page margins | Key | Spread bleed | Key |
---|---|---|---|---|---|
ScaleToPageSize.jsx | F5 | ScaleToPageMargins.jsx | ⌥F5 | ScaleToSpreadBleed.jsx | ⇧F5 |
ScaleToPageSizeH.jsx | ⌃F5 | ScaleToPageMarginsH.jsx | ⌃⌥F5 | ScaleToSpreadBleedH.jsx | ⌃⇧F5 |
Proxy
SetRefPoint...
Use the numeric keypad to set the reference point used for transformations (similar to clicking the little proxy squares in the Control palette):
Shortcuts
Left | Key | Center | Key | Right | Key |
---|---|---|---|---|---|
SetRefPointTL.jsx | ⌃Num7 | SetRefPointT.jsx | ⌃Num8 | SetRefPointTR.jsx | ⌃Num9 |
SetRefPointL.jsx | ⌃Num4 | SetRefPointC.jsx | ⌃Num5 | SetRefPointR.jsx | ⌃Num6 |
SetRefPointBL.jsx | ⌃Num1 | SetRefPointB.jsx | ⌃Num2 | SetRefPointBR.jsx | ⌃Num3 |
File
FilesToSpreads
Combines the open documents, sorted alphabetically.
SpreadsToFiles
Saves each spread of the active document to a separate file.
If the document name ends with a separator (space/dot/underline/hyphen) followed by a sequence of digits or letters equal to the number of spreads, each saved spread will have the letter corresponding to its index appended to its name – e.g., a document with three spreads named Document_ABC.indd
will be split into Document_A.indd
/ Document_B.indd
/ Document_C.indd
. If not autodetected, the script will prompt the user for the list.
By default, the index will be appended at the end, but you can put a #
in the document name to place the index at that particular position.
LayersToSpreads
Moves all layers of the active document to separate spreads (the document must have a single spread).
You can use SpreadsToFiles
to save them in separate documents.
Export
QuickExport
⌃E
Exports to PDF all opened documents or, with nothing opened, all documents from a folder.
For convenience, some export options can be easily changed from the preset settings: resolution, export as pages/spreads, include crop marks, page information, slug area, and you can set a custom bleed.
There are two export presets that can be used simultaneously or one at a time:
The text from the Suffix field will be appended to the name of the exported file (everything in the preset name after the last _
will be autodetected as suffix).
If Sort files by suffix into subfolders is checked, subfolders will be created from the suffix (the text after +
is ignored2).
It can also run a JavaScript or AppleScript before exporting, e.g., one of the following:
MarkVisibleArea
Creates a frame the size of the page margins on the visible area layer. It will use the Visible area swatch, which will be created with the values R=255 G=180 B=0 if it doesn't exist.
PrepareForExport
Hides covered areas, visible area, safety margins, safe area, segmentation, guides, and all layers starting with either a dot or a hyphen; moves all page objects from varnish, uv, foil, silver and white to separate spreads.
ShowDNPLayers
/ HideDNPLayers
Shows or hides the following do-not-print layers: covered areas, visible area, *vi?ib*, vis?*, safety margins, safe area, segmentation, rahmen and sicht*, and all layers starting with either a dot or a hyphen.
View
TileAll
⇧F4
Invokes Window ‣ Arrange ‣ Tile All Vertically or Tile All Horizontally, depending on the current spread orientation.
ZoomToSelection
F4
It resembles Fit Selection in Window (⌥⌘=), but with some changes:
- Brings the selection a little closer3;
- If the cursor is in a text frame, zooms on the whole frame;
- Without anything selected zooms on the current spread.
ZoomToSpreads
⌥F4
Zooms on the first 3 spreads.
Miscellaneous
Clip
Num*
To handle some objects it is sometimes useful to temporarily insert them into a container (clipping frame). The script inserts the selected objects into a clipping frame or restores them if they are already clipped.
Note: It uses the clipboard, so make sure you don't lose anything important.
ClipUndo
⌃Num*
Releases one or several objects from their clipping frames (you can select any objects, it will only release the clipped ones). If nothing is selected, it will release all clipped objects.
EAN
⌥F9
This script is inspired by EAN Barcode Generator by Konstantin Smorodsky, modified to embed the code in a selected rectangle: if we have a page object (ideally a rectangle) selected, the script embeds an EAN code in it, scaled to width. If nothing is selected, it puts it in a new document.
Enter 8 or 13 digits for the code itself; if you have an add-on, add a hyphen and another 2 or 5 digits.
LabelPage
Adds a custom label on the current page slug, on the info layer (with Helvetica Regular 6 pt, Registration swatch):
LabelPageRatios
Adds a label with the page aspect ratio, on the slug of each page, on the info layer.
LabelsCleanup
Sometimes objects that have a script label attached are reused, which may create problems later. The script deletes the labels of the selected objects or all objects in the document if nothing is selected.
Offset Paths
This is a slightly modified version of OffsetPath by Olav Martin Kvern, that creates paths around selected objects at a custom offset distance:
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 could 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 the a new path from those geometric coordinates.
QR
F9
Adds a QR code on each spread of the active document (outside visible area, if possible) or to separate PDF files4:
On document | On file |
---|---|
If the document name ends with a separator (space/dot/underline/hyphen) followed by a sequence of digits or letters equal to the number of spreads, the letter corresponding to the spread index will be appended to each code/file – e.g., for a document with three spreads named Document_ABC.indd
, the script will generate Document_A_QR.pdf
, Document_B_QR.pdf
and Document_C_QR.pdf
.
You can insert |
for manually splitting the label into several lines.
QRBatch
⇧F9
Does the same thing as QR
but in a non-interactive way: retrieves a list of codes from a TSV data file named qr.tsv
(sample) and adds them to existing documents or creates separate files (the suffix thing applies here as well):
Filename | Code | On doc |
---|---|---|
Document 1 | Code 1 | + |
Document 2_ABC | Code 2 | + |
Document 3_AC | Code 3 | |
... |
Filename: document name
Code: any string
On doc: any string: on existing document; empty or missing: on separate file
The TSV file must be saved locally (in the active document folder); files starting with _
take precedence. Blank lines and those starting with #
are ignored (this will confuse Excel).
You can insert |
for manually splitting the label into several lines.
ShowFonts
Shows all fonts used in the active document.
ShowProfiles
Shows all color profiles available to InDesign.
ShowProperties
F1
Shows properties and methods of a selected object.
Install
- Clone or download from Code ‣ Download ZIP. The repository uses dynamically linked libraries from
lib/
, so the folder structure should be preserved; if you prefer stand-alone scripts, download the latest release, where they are statically linked. - Open Window ‣ Utilities ‣ Scripts.
- Right-click on folder User and select Reveal in Finder/Explorer.
- Copy Indentz to this folder.
About
All scripts are created by me unless otherwise noted.
© 2020-2022 Paul Chiorean <jpeg AT basement.ro>.
The code is released under the MIT License (see LICENSE.txt).
The code in this project would not have been possible without the InDesign ExtendScript API by Theunis de Jong and Gregor Fellenz, Mozilla's MDN Web Docs, and also blog posts, forum posts, tutorials or code by Marc Autret, Dave Saunders, Peter Kahrel, Gregor Fellenz, Marijan Tompa, Richard Harrington and many others.
Last updated: November 10, 2022
Footnotes
-
For example, in
Document_DE.indd
'The sample is for free' will be replaced with 'Das Sample ist kostenlos', and forDocument_FR.indd
with 'L'échantillon est gratuit'.↩ -
For example, if the suffix is
print+diecut
, the document will be saved asDocument_print+diecut.pdf
in a subfolder namedprint
.↩ -
The variable
Z
from line 42 must be set to fit a square page at 90% of Fit Page in Window.↩ -
The codes are used by a customer who needs to manage POS posters in multiple locations and languages.
↩