Reputation: 73
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.
2.
3.
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);
Upvotes: 1
Views: 1524
Reputation: 1391
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
Upvotes: 2