Copy link to clipboard
Copied
Hello:
I’m new to scripting, and I’m having trouble getting a text wrap around a photo cutline once I have the script create a static caption.
It brings in the caption, but I’m doing something wrong and I can’t figure it out.
I would appreciate any help.
- Again, I’m new to scripting, so I’m flying blind.
Thanks in advance for any help or guidance.
Here is what I’ve go so far.
var allPgs = app.activeDocument.pages; for(var pCnt = 0; pCnt < allPgs.length; pCnt++) var pg = allPgs[pCnt]; var masItms = pg.masterPageItems;app.menuActions.itemByName('Generate Static Caption').invoke();var frame = app.selection[0]; frame.textWrapPreferences.textWrapOffset = [0, "0.0139 in", "0.125 in", "0.0139 in"];
1 Correct answer
Larry -- Use the below code. Select the rectangle that holds the image and run the script.
if (app.selection.length && app.selection[0] instanceof Rectangle) {
app.selection[0].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;
app.selection[0].textWrapPreferences.textWrapOffset = [0, "0.0139 in", "0.125 in", "0.0139 in"];
app.menuActions.itemByName('Generate Static Caption').invoke();
}
You'll have to set the caption to ignore text wrap, and probably you want to set the im
...Copy link to clipboard
Copied
Your post moved from InDesign forum to InDesign Scripting forum.
Ten
Copy link to clipboard
Copied
Hi Larry,
without testing anything of your code:
Look into textWrapPreferences and first invoke text wrap before defining an offset.
The first property I see is textWrapMode that could be set to TextWrapModes.NONE by default.
Adobe InDesign CS6 (8.0) Object Model JS: TextWrapPreference
Regards,
Uwe
Copy link to clipboard
Copied
Thanks for the help, Uwe:
I found this script online....and it works...but it wraps everything on the document, and I only want to selected text box, the caption created to have a text wrap on it.
I would greatly appreciate any help in how to adjust this one.
I keep getting an error message if I change it to...var =app.selection
or anything else for that matter.
Not sure how to do it.
Change this line to only the caption created, or selected text box...
var txfms = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();
for(var i =0;i<txfms.length;i++)
Thanks for your help and kindness.
Larry
var allPgs = app.activeDocument.pages;
for(var pCnt = 0; pCnt < allPgs.length; pCnt++)
var pg = allPgs[pCnt];
var masItms = pg.masterPageItems;
app.menuActions.itemByName('Generate Static Caption').invoke();
var txfms = app.activeDocument.pages.everyItem().textFrames.everyItem().getElements();
for(var i =0;i<txfms.length;i++)
{
txfms.textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;
txfms.textWrapPreferences.textWrapOffset = [0, "0.0139 in", "0.125 in", "0.0139 in"];
}
Copy link to clipboard
Copied
Larry -- Use the below code. Select the rectangle that holds the image and run the script.
if (app.selection.length && app.selection[0] instanceof Rectangle) {
app.selection[0].textWrapPreferences.textWrapMode = TextWrapModes.BOUNDING_BOX_TEXT_WRAP;
app.selection[0].textWrapPreferences.textWrapOffset = [0, "0.0139 in", "0.125 in", "0.0139 in"];
app.menuActions.itemByName('Generate Static Caption').invoke();
}
You'll have to set the caption to ignore text wrap, and probably you want to set the image's bottom wrap to a higher value.
(Seems odd that you can't set up the captions to apply an object style.)
P.
Copy link to clipboard
Copied
Thanks for your help, Peter.
I think my problem is that it makes the Static Caption, but then places the Text Wrap around the photo...not the caption.
I may not have been clear with my intentions.
It makes the Static Caption, but how do I get the script to selection the caption to make the text wrap around it.
Hope that makes sense.
This is all new to me...so I'm not sure what I'm doing.
Sorry if I am confusing.
Here is breakdown of what I'm trying to get done.
I can make it apply the Static Caption....but I can't grab that text box to do the text wrap.
Place a photo.
Create Static Caption.
Text wrap the static caption.
Thanks for any help you can offer.
Larry

