Skip to main content
any2cards
Known Participant
February 17, 2020
Answered

How to change a specific objects settings across all pages

  • February 17, 2020
  • 2 replies
  • 1259 views

I am using inDesign 15.0.1. I have an indd file which contains 100 pages.  Each individual page has a layout of a card that will be used for a board game.

 

For discussion sake, let's assume that each card has a text object on it and is called NAME.

 

NAME is located at X: 13 mm, Y: 9mm, W: 31 mm, H: 3 mm

 

Further, let's assume that the underlying PNG file which represents the card has gone through a change. This change requires that the NAME field on each page be changed to X: 16 mm.

 

Is there a way to do this programmtically or automatically within features of inDesign, as opposed to having to go into each and every page and change the X: value manually?

 

I have simplified the above example so as to make any proposed solutions simple.  There are actually 4 different objects that I have to change positions for, and I really, really do not want to have to do this manually.  Also, please assume for the sake of this argument that master pages cannot be used to solve this issue.

 

Thanks in advance for any solutions provided.

Correct answer Sunil Yadav

Take this updated code for your reference : 

/////////////////////////////////////////////////////
/// Here you can declare all those information like x, y axis value height & width and how much you want to move horizontally & vertically
var x = 13;
var y = 9;
var ht = 3;
var wd = 31;
var toMoveHorizontally = 3;
var toMoveVertically = 0;
/////////////////////////////////////////////////////
var myDoc = app.documents[0];
for(var p = 0; p < myDoc.pages.length; p++){
    var found = false;
    for(var t = 0; t < myDoc.pages[p].textFrames.length; t++){
        var frameGB = myDoc.pages[p].textFrames[t].geometricBounds;
        var height = parseFloat(frameGB[2]).toFixed(2)-parseFloat(frameGB[0]).toFixed(2);
        var width = parseFloat(frameGB[3]).toFixed(2)-parseFloat(frameGB[1]).toFixed(2);
        if(parseFloat(frameGB[0]).toFixed(2) == parseFloat(y).toFixed(2) && parseFloat(frameGB[1]).toFixed(2) == parseFloat(x).toFixed(2) && parseFloat(height).toFixed(2) == parseFloat(ht).toFixed(2) && parseFloat(width).toFixed(2) == parseFloat(wd).toFixed(2)){
            myDoc.pages[p].textFrames[t].move([frameGB[1]+toMoveHorizontally, frameGB[0]+toMoveVertically]);
            myDoc.recompose();
            }
        }
    }
/////////////////////////////////////////////////////

 

Best

Sunil

2 replies

Willi Adelberger
Community Expert
February 17, 2020

The simpliest way is to use object styles, you can specifiy position and size of any object. User that.

 

The master has also frame borders, where text frame aligned will be repositioned if those change. That’s why it is very important to align frames to these border lines. Changes of these borders will be reflected to object repostion.

 

>BTW Don't use PNG, there are much better file types: AI, PDF/X-4 or PSD.

Sunil Yadav
Brainiac
February 17, 2020

Hi try this code for your reference:

/////////////////////////////////////////////////////
/// Here you can declare all those information like x, y axis value height & width and how much you want to move horizontally & vertically
var x = 13;
var y = 9;
var ht = 3;
var wd = 31;
var toMoveHorizontally = 3;
var toMoveVertically = 0;
/////////////////////////////////////////////////////
var myDoc = app.documents[0];
for(var p = 0; p < myDoc.pages.length; p++){
    var found = false;
    for(var t = 0; t < myDoc.pages[p].textFrames.length; t++){
        var frameGB = myDoc.pages[p].textFrames[t].geometricBounds;
        var height = frameGB[2]-frameGB[0];
        var width = frameGB[3]-frameGB[1];
        if(parseFloat(frameGB[0]) == parseFloat(y) && parseFloat(frameGB[1]) == parseFloat(x) && parseFloat(height) == parseFloat(ht) && parseFloat(width) == parseFloat(wd)){
            myDoc.pages[p].textFrames[t].move([frameGB[1]+toMove, frameGB[0]+toMoveVertically]);
            }
        }
    }
/////////////////////////////////////////////////////

Best

Sunil

Sunil Yadav
Brainiac
February 17, 2020

Copy this code into text file and save it as anyfilename.jsx

Copy that file in Scripts -- > Scripts Panel folder.

After pasting that file you can see that file in this script panel, from there you can double click that menu and code will be executed.

Best

Sunil

any2cards
any2cardsAuthor
Known Participant
February 17, 2020

Once again, thank you for all of your help.  I look forward to this simplifying my life immensely !