SizeLabels

SizeLabels.jsx

The download link for this free script is further below, near the end of this web page, under the heading Installation.

Check the version history to see what’s changed compared to previous versions.

What is it?

SizeLabels is a script for Adobe InDesign. As far as we know it works with InDesign CS5 and above, and there is a good chance it’ll work with older versions too – we’ve not tested it, so we cannot say for sure. Give it a go and let us know!

SizeLabels is a one-trick pony. It looks at all the frames in your document, adds a small text frame next to each frame it finds, and sets the content of the added text frame to the size of the associated frame.

I’ll show you how to install and customize the script a bit later. Let’s have a look at what it does first.

Suppose you have created a document and you have some very precise specifications for the sizes for the individual frames. You can print a proof of the document, and then someone could sit down and verify each printed frame with a ruler to make sure the size is correct – but why not let InDesign do the work?

So here is our document:

I have already installed SizeLabels on my computer. When I bring up the Scripts palette (via the Window – Utilities – Scripts menu):

I can see the SizeLabels script sitting on the Scripts palette. (It could reside under either the Application or the User entry; in my example here it’s under Application).

I now double-click the SizeLabels.jsx script on the palette to set things in motion.

A few seconds later, my layout looks like this:

As you can see, a small text frame has been added in the top left corner of every frame. In the small text frame you can see the width and height of the corresponding frame.

In the default configuration, the frame size is expressed in inches.

If you move one or more frames, the associated size labels won’t auto-adjust or stay attached to their associated frame. Instead, you double-click the script on the Scripts palette again. The script will then adjust and reposition the labels as needed.

In other words: each time you modify the layout you can re-run the script to update the labels.

Now, if you don’t want inches – don’t despair! I’ll explain how to configure the script to use another measurement unit later.

Of course, after you’ve printed this schematic layout, you’ll want to remove those added text frames. To make that easy, the script has put all these additional text frames on a separate layer, named SizeLabels. To delete all the added labels in one go, simply delete the layer.

Bring up the Layers palette via the Window – Layers menu:

Select the SizeLabels layer, then click the little trash can icon:

InDesign will show an alert – proceed by clicking OK.

All the size labels will disappear. Is that cool or what?

Now, I can hear you say: “Yes, but…”.  “Yes, but I want the size labels to use a different font or font size”. “Yes, but I’d like a different fill color in the size labels”. “Yes, but I don’t want the size in inches, I want it in centimeters”.

Did I mention SizeLabels.jsx was a one-trick pony? Luckily, we can teach the pony a number of slightly different tricks.

Let’s tackle each of the above objections one by one, shall we?

Using a different text style

Changing the text style in the size labels is easy. SizeLabels.jsx will try and find a paragraph style SizeLabelStyle in the document, and when it finds a style by that name, it will apply it to the text in the size labels as it creates them.

If you don’t have a paragraph style by that name, SizeLabels.jsx will use whatever is the default in your document.

Let’s create a style that makes those labels use Comic Sans, 12 pt.

I love using Comic Sans, because I know it grates anyone with some sense of design style. Having no such sense, it does not bother me – to me it’s just a font.

Bring up the Paragraph Style palette via the Type – Paragraph Styles menu.

On the Paragraph Style palette, click the Create new style button at the bottom:

A new paragraph style will appear. The name can vary – in my case, it’s called Paragraph Style 1; that might be slightly different in your case (e.g. it could be Paragraph Style 12 or so).

Double-click the palette on the line that contains Paragraph Style 1. Make sure to not click within the actual name Paragraph Style 1 – click somewhere beside the name. Look at the position of my mouse in the screen shot to see where I clicked.

The Paragraph Style Options dialog will appear. First, select the paragraph style name.

Change it to SizeLabelStyle. Don’t add any spaces – it has to be exactly right. Then click the entry Basic Character Formats:

In the Basic Character Formats, select Comic Sans MS and set the size to 12. (Alright, alright, you may pick some other font if you really hate Comic Sans).

You can adjust any style setting you like in this dialog; for example, you could pick a different character color if you wanted, or you could have the text centered instead of left-aligned. Feel free to experiment. Click OK when you’re done.

Now re-run the script, exactly as shown before (i.e. double-click the SizeLabel.jsx on the Scripts palette).

Tadaa! Beautiful Comic Sans in the size labels!

And thanks to the power of paragraph styles, you can continue to modify the paragraph style SizeLabelStyle to your liking. All size labels will immediately pick up those changes, without needing to re-run the script.

Using a different text frame style

If you wanted to make the size label background cyan and apply a small text inset, you can do that by means of an object style.

Just like the SizeLabelStyle paragraph style, the SizeLabels.jsx script will also look for an object style by the name SizeLabelObjectStyle. If that style exists, the script will apply that object style to all the size labels.

We’ll create the object style first. Bring up the Object Style palette via the Window – Styles – Object Styles menu.

Then create a new object style by clicking the Create new style button.

This creates a new object style – in my case it’s called Object Style 1, but that might be slightly different for you (e.g. it could be Object Style 20).

Just like with the paragraph styles, double-click the line with the new object style somewhere next to the object style name, and do not click in the object style name.

Rename the style to SizeLabelObjectStyle, and change any other style attributes you desire – I’ve changed the fill color to cyan, for example. Once you’re done, click OK.

You’ll notice that nothing happens to the existing size labels. This is because we only created the object style after running the script, and the script is unable to attach the not-yet-existent object style to the frames.

Not to worry – simply double-click the SizeLabels.jsx script on the scripts palette, and re-run the script.

The script will automatically remove the existing size labels, and create new ones, and this time around it will take into account the object style.

There is no need to remove the old labels when you want to re-run the script.

Afterwards, when you adjust the SizeLabelObjectStyle object style or the SizeLabelStyle paragraph style, any changes will take effect immediately. No need to re-run the script in those cases.

For example, below I’ve added a small text top inset to the object style, and changed the paragraph style to be centered and the character color to Paper:

Using different units

Now, you would prefer centimeters instead of inches? That’s possible too.

In order to achieve that we need to modify the script. That is a lot easier than it sounds; here at Rorohiko, we put great effort into creating scripts that are easy to modify and adjust, even for people without any scripting experience.

Follow along, and you’ll see it’s a piece of cake.

Bring up your Scripts palette, and right-click (or option-click on Mac) the SizeLabels.jsx script to bring up the contextual menu. Select the option Edit Script from the contextual menu.

This should activate the ExtendScript Toolkit and show you the contents of the script file.

Script files with a .js or a .jsx file name extension are nothing more than text files which can be viewed and edited with any old text editor.

You should see a whole lot of human-readable info – the script starts out with a whole section of text. This introductory text is ignored by InDesign when the script is run. It is all meant for human eyes, and explains what the script does and how to install it.

Scroll down until you see a few lines of which one mentions kUnitToUse:

The line says:

const kUnitToUse = MeasurementUnits.INCHES;

Now retype part of the line so it reads:

const kUnitToUse = MeasurementUnits.CENTIMETERS;

If you want any other unit, consult the list provided in the script introduction. You can pick any of the following:

MeasurementUnits.CENTIMETERS
MeasurementUnits.CICERO
MeasurementUnits.INCHES
MeasurementUnits.MILLIMETERS
MeasurementUnits.PICAS
MeasurementUnits.PIXELS
MeasurementUnits.POINTS

What you type has to be exactly right – scripts break if you use any poetic license. Don’t add or remove any spaces, don’t change lowercase letters into uppercase, don’t omit or add any other characters. Typing CENTIETERS instead of CENTIMETERS will break the script.

We also need to adjust the label height and width. In the original script the labels are 0.3 x 2.0 inch in size.

When we change the unit in the script from inch to centimeters, that would be interpreted as 0.3 x 2.0 cm instead of the original 0.3 x 2.0 inch. That is way too small.

So, we also change the sizes to 0.75 x 5.0 cm. The end-result looks like this:

Ok, we’re done!  We’ve changed INCHES into CENTIMETERS, and we’ve adjusted the width and height of the labels.

I know, this all might seem a bit scary, but it is not.

If you make a mistake, the script won’t work any more, big deal. If that happens, throw away the SizeLabel.jsx file from your scripts folder, and re-extract a clean copy from the SizeLabel.zip that you downloaded off our web site. Install the clean copy and then start over.

Onwards; close the script.

Allow ExtendScript Toolkit to save; i.e. click Save:

Then switch back to InDesign.

In InDesign, we re-run the script by double-clicking the line SizeLabels.jsx on the Scripts palette. The result now becomes:

Conclusion

Even though the SizeLabel.jsx script is a one-trick pony you can still customize its behavior to a great extent.

It should also demonstrate that you should not be scared to open a script in a text editor.

Many script authors (Rorohiko included) go to great lengths to make their scripts easy to read and modify, even for people who have little or no scripting knowledge.

Installation

First of all, download the .zip file with the script from our web site. Current version is 0.0.4:

https://www.rorohiko.com/downloads/SizeLabels.0.0.4.zip

Check the version history to see what’s changed compared to previous versions.

Put the downloaded file on your desktop first.

Then extract the contents of the .zip file.

On Macs, the file might auto-decompress, or if not, you simply double-click the SizeLabels.x.x.x.zip file (where x.x.x stands for the version number of the script).

On most Windows installations, you can right-click SizeLabels.x.x.x.zip and select Extract All… from the contextual menu.

You then need to locate a file called SizeLabels.jsx – it might reside in a folder called SizeLabels or SizeLabels.x.x.x. Depending on how your workstation is configured, you might or might not see the .jsx file name extension.

In short: you might need to poke around a bit to find the file.

Once you’ve located the SizeLabels.jsx file, you can start InDesign, and bring up the Scripts palette via the Window – Utilities – Scripts menu item. Right-click (or option-click on Mac) the User entry on the palette to bring up the contextual menu.

If you have sufficient administrative privileges on your computer, you could just as well select the Application entry. If you’re unsure, pick User instead; that should work for everyone.

Select the contextual menu item Reveal in Explorer (Windows) or Reveal in Finder (Mac).

A folder should open in Explorer or the Finder. Double-click the folder named Scripts Panel to open it.

Once you have the Scripts Panel folder open, you can drag the SizeLabels.jsx file from wherever you found it into this Scripts Panel folder.

Close the windows afterwards.

Switch back to InDesign. If you did it right, the script should now appear on the Scripts palette, under the entry you picked (either User or Application). You might need to click the disclosure triangle to open it up:

That’s it! The script is now installed and ready for use! Have fun!

What’s next?

There is a lot that this script does not do. You might want some different info in the labels. You might want more than one label. You might want the labels to be positioned differently in relation to the frames.

What we’re planning to do is create a much enhanced version of this script, and bundle it with our FrameReporter tool.

https://www.rorohiko.com/FrameReporter

FrameReporter is similar in that it adds labels to frames, but the FrameReporter labels are non-printing: they are only meant to assist while editing the InDesign layout.

This script would then allow a user to get that same information in printable labels.

Rationale

We want this script to serve as a glimpse of the kind of work we do for a living here at Rorohiko.

We automate the Creative Suite, in projects both large and small. We also have a solid track record in teaching other people how to build stable, dependable, yet flexible solutions.

If you have a need for automation or need some fast-tracking, contact us. We’ve been building solutions around the Creative Suite and InDesign Server for many years now.

Our motto is: “If you only have a hammer, everything looks like a nail”. What sets us apart is a very wide experience, so we can pick the right tool for the task at hand.

To name just a few of the environments we use on a regular basis: ExtendScript, ActionScript, Flex/Flash Builder, InDesign, Acrobat, XML, GWT, Java, jQuery, PHP, C++,  HTML, CSS, SOAP, Eclipse, REALbasic, SharePoint, Visual Basic, Mac, Windows, Linux, Tomcat, SOAP, SVN, TRAC.

Version history

Version 0.0.4: July 25th, 2012:
– Added support for EPS files

Version 0.0.3: July 24th, 2012:
– Added option to include image file name in labels.
– Fixed possible conflict with a character style inadvertently overriding the SizeLabelStyle.
– Made label separators configurable (default separators are ” – ” and ” x “, e.g. “MyImage.jpg – 12.02 x 4.23”)

Version 0.0.2: June 23rd, 2012:
– Version 0.0.1 did not handle anchored or inline frames correctly. Now fixed.

Version 0.0.1: June 3rd, 2012:
– Initial release