Inspiring
October 12, 2023
Answered
StaticCaption for Image and Opacity settings in Object style
- October 12, 2023
- 2 replies
- 2387 views
Hi
I have an empty Objectstyle named "caption".
Here is the code to add a caption to a selected image.
var myDoc = app.activeDocument;
var myPhotos = app.selection[0];
var gb = myPhotos.geometricBounds;
// Frame for caption
var myCaption = myPhotos.parent.textFrames.add();
// Position and size of the caption
myCaption.geometricBounds = [gb[2]-1, gb[1]+1, gb[2]-6, gb[3]-1];
// apply existing object style to the caption
myCaption.applyObjectStyle (app.activeDocument.objectStyles.item("caption"));
// add caption contents
myCaption.contents = "group the picture and the caption";
// group the picture and the caption
//myPhotos.parent.groups.add([myPhotos, myCaption]);
var objStyle = myDoc.objectStyles.itemByName("caption");
objStyle.fillColor="white";
objStyle.fillTint=20;
I need three things which I am not able to achieve.
a. I am unable to set the opacity of the fill to 20 or 30%
b. I am unable to get the static caption
c. Create the objectstyle named "caption" on the fly
I searched this link for opacity settings:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#ObjectStyle.html
