Try This: /*
_FRIdNGE-0766_ImageCaptionAlignment.jsx
Script written by FRIdNGE, Michel Allio [02/11/2024]
*/
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.FAST_ENTIRE_SCRIPT, 'Image And Caption Alignment');
function main() {
var myDoc = app.activeDocument;
var myRulerOrigin = myDoc.viewPreferences.rulerOrigin;
if ( app.selection.length != 2 ) {
alert( "Select 2 items!")
exit();
}
if ( app.selection.length === 2 ) {
myDoc.viewPreferences.rulerOrigin = RulerOrigin.SPREAD_ORIGIN;
if ( app.selection[0] instanceof Rectangle && app.selection[1] instanceof TextFrame ) {
var myGraphicFrame = app.selection[0];
var myTextFrame = app.selection[1];
} else if ( app.selection[1] instanceof Rectangle && app.selection[0] instanceof TextFrame ) {
var myGraphicFrame = app.selection[1];
var myTextFrame = app.selection[0];
} else {
alert( "Bad Selection!")
exit();
}
myTextFrame.geometricBounds = [ myGraphicFrame.geometricBounds[2], myGraphicFrame.geometricBounds[1], myGraphicFrame.geometricBounds[2] + myTextFrame.geometricBounds[2] - myTextFrame.geometricBounds[0], myGraphicFrame.geometricBounds[3] ];
myDoc.viewPreferences.rulerOrigin = myRulerOrigin;
}
} (^/)
... View more