Copy link to clipboard
Copied
Hi everyone,
Is it possible to create a script to turn on Auto-Size on all text frames that contain text with a specific Character Style applied to them? If so, please set AutoSizing as per below:
frame.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT;
frame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY;
Thanks in advance,
Rogerio
Hi @Rogerio5C09, how about this?
function main() {
var doc = app.activeDocument;
// reset grep prefs
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
// find criteria
app.findGrepPreferences.appliedCharacterStyle = 'MyCharStyle';
var found = doc.findGrep();
for (var i = 0; i < found.length; i++)
for (var j = 0; j < found[i].parentTextFrames.length; j++) {
var frame = found[i].parentTextFrame
...
Copy link to clipboard
Copied
Hi @Rogerio5C09, how about this?
function main() {
var doc = app.activeDocument;
// reset grep prefs
app.findGrepPreferences = NothingEnum.NOTHING;
app.changeGrepPreferences = NothingEnum.NOTHING;
// find criteria
app.findGrepPreferences.appliedCharacterStyle = 'MyCharStyle';
var found = doc.findGrep();
for (var i = 0; i < found.length; i++)
for (var j = 0; j < found[i].parentTextFrames.length; j++) {
var frame = found[i].parentTextFrames[j];
if (frame.isValid) {
frame.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT;
frame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY;
}
}
}; // end main
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Set Autosizing');
- Mark
Copy link to clipboard
Copied
It worked just as expected! Thank you so much š