• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to Match Object Sizes and Align Captions in InDesign

Advocate ,
Oct 25, 2024 Oct 25, 2024

Copy link to clipboard

Copied

Can there be a script that makes object A the same size as object B?


Here are two scenarios:
The first, being a graphical object, lets A be equal in size to the target B.
The second, if A is a picture and B is its caption, let B and A have two widths.


The second is the most desirable, because very often the caption needs to be re-widened after the picture size is changed. It's a pain in the ass when you have a lot of them.
If you choose an image and a static caption, you can have the caption quickly aligned to the image, including position and width. It would save a lot of work.

6868.jpg

 

 

<Tiitle renamed by MOD>

TOPICS
Bug , Feature request , How to , Scripting

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Guide , Oct 25, 2024 Oct 25, 2024
var myGraphicFrame = app.selection[0];
var myTextFrame = app.selection[1];
myTextFrame.geometricBounds = [ myGraphicFrame.geometricBounds[2], myGraphicFrame.geometricBounds[1], myTextFrame.geometricBounds[2], myGraphicFrame.geometricBounds[3] ];

 

(^/)

Votes

Translate

Translate
Community Expert , Oct 25, 2024 Oct 25, 2024

 

myTextFrame.geometricBounds = [ myGraphicFrame.geometricBounds[2], myGraphicFrame.geometricBounds[1], myGraphicFrame.geometricBounds[2]+(myTextFrame.geometricBounds[2] -myTextFrame.geometricBounds[0]), myGraphicFrame.geometricBounds[3] ];

 

Votes

Translate

Translate
Guide , Nov 02, 2024 Nov 02, 2024

Take this one:

 

/*
    _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();
        
    } else {

        if ( app.selection[0]
...

Votes

Translate

Translate
Guide ,
Nov 02, 2024 Nov 02, 2024

Copy link to clipboard

Copied

Thé script checks itself the type of frame. So no need.

 

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 02, 2024 Nov 02, 2024

Copy link to clipboard

Copied

LATEST

How to make the error box disappear automatically after 1 second.

Thank you very much.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines