Skip to main content
Participating Frequently
April 30, 2024
Question

InDesign Java Script to return Swatches used by object

  • April 30, 2024
  • 3 replies
  • 1294 views

Hello, beginning js / indesign user here. I have the following question:

 

Is there a way to get the swatches used by an object via js? I already know that objects don't usually have a swatches-property, however in indesign you can create a dynamic caption that will display these same swatches by putting their names in a text frame.

 

If the dynamic caption can display this, but objects do not have assigned swatches, where does it get the information necessary from? And can I use this to get a list/array/string or similar in js? I am specifically looking for a method or a partial script.

This topic has been closed for replies.

3 replies

Participating Frequently
May 1, 2024

Thank you for your answers, I should have clarified. The object is a rectangle, but it is not filled with a singel color, instead it is an actual picture. The reason why I need the swatches is that this page is to be printed, and in the method of printing we use we print the CMYK colors on top of each other until they come together to form the finished picture (not only cmyk of course, hence the swatches problem).

As you can see in the attached picture there is a setting for dynamic captions wherein the "swatches used" of the object the caption is linked to will be displayed as text. I need this information in script form. 

My only workauround so far is a little clunky, so I am trying to streamline my code.

Robert at ID-Tasker
Brainiac
May 1, 2024

@SquirrelsInASuit

 

Have you applied ObjectStyle to the caption's TextFrame?

 

I'm pretty sure, by default, "neutral" ObjectStyle is applied - "[Basic TextFrame]".

 

Then, there is a color specified in the ParaStyle. 

 

Can you maybe post an example screenshot - with indication of which exactly color you would like to get a reference to?

 

Participating Frequently
May 2, 2024

@SquirrelsInASuit

 

You can create Captions "on demand" - then delete them.

 

There was a thread about that. 

 

I'll try to find it. 

 


Thank you,  if you find it please let me know, all I found was generating static captions...

rob day
Community Expert
April 30, 2024

Hi @SquirrelsInASuit , If by object you mean pageItems or texts, they can have a fillColor and strokeColor property, which returns the color or swatch object used:

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PageItem.html

 

Robert at ID-Tasker
Brainiac
April 30, 2024

Object can have ObjectStyle applied. 

 

And are you looking for fill / stroke only or for all glows / shadows / etc. colors as well?