1
votes

I have an InDesign document with ~550 pages. On an every page, there are 4 frames, all the pages look the same (see image below). I'm using InDesign CS6 and JS.

I need a script that fulfills some rather basic functions, if possible:

1.

  • Target text frame (1)
  • Delete the text frame

2.

  • Target text frame (2)
  • Applying a given paragraph style

3.

  • Target image frame (4)
  • Fit Frame Proportionally
  • Do so on all pages

layout

I tried the following (see below). Somehow, ID tells me "myParagraph.applyParagraphStyle" and "myFrame.fit" is "not a function".

2.

var myDocument = app.activeDocument;
myParagraph = myDocument.pages.item(1);
myParagraphStyle  = myDocument.paragraphStyles.item('datum');
myParagraph.applyParagraphStyle(myParagraphStyle,true);

3.

var myDocument = app.activeDocument;
var myGraphic = myDocument.pages.item(3);
var myFrame = myGraphic.parent;
myFrame.fit(FitOptions.proportionally);
1

1 Answers

2
votes

You need to look at the DOM for InDesign. Have a look here:

http://jongware.mit.edu/idcs6js/

myParagraph = myDocument.pages.item(1);

Paragraphs are not child nodes of pages. Also, I would address one page at the time and loop through pages.

Try:

var myParagraph = myDocument.pages[0].textFrames[0].paragraphs[0];

Similar problem with graphics. You need to address the container which is graphic parent and then graphic it contains:

var myGraphic = myDocument.pages[0].rectangles[0].graphics[0];

or

var myGraphic = myDocument.pages[0].allGraphics[0].graphics[0];

Alternatively, you can use pageItems, instead of textFrames or rectangles