Copy link to clipboard
Copied
I am working in Enfocus Switch and have a simple command that I need to execute in indesign (java in CS 5.5) I need to center all object inside their rectangle frame. But I dont know how to select an object in indesign and center the content (using Java). here is my best guess;
>>> app.activeDocument.activeSpread.fit(FitOptions.CENTER_CONTENT(ALL)); <<<<<<
I understand I am probably way off, any help at all would be greatly appreciated!!!!
Thanks,
Paul Hough
Edit: I have figured out how to center the content inside of rectangles:
app.activeDocument.pages[0].rectangles[0].images[0].fit(FitOptions.CENTER_CONTENT);
But, I still dont know how to get a variable with the number of rectangles on a page/doc so I can create a loop.
Any tips or pointer are appreciated
Hi Paul
app.activeDocument.pages.everyItem().splineItems.everyItem().images.everyItem().fit(FitOptions.CENTER_CONTENT);
Will apply to all placed images outside groups
app.activeDocument.pages.everyItem().groups.everyItem().splineItems.everyItem().images.everyItem().fit(FitOptions.CENTER_CONTENT);
Will apply to all the items in groups
The above is in Java Script and not Java.
Trevor
Copy link to clipboard
Copied
try this:
app.activeDocument.pages.everyItem().rectangles.everyItem().images[0].fit(FitOptions.CEN TER_CONTENT);
assuming you have ony images in your doc.
otherwise, you can loop to the pages and rectangles collections (for this you can treat them like an array; for (var i=0; i<pages.length; i++){ myPage=pages; do something bla bla}
Copy link to clipboard
Copied
Hi Vamital
I didn't see your answer when I wrote mine
Not that it matters!
Copy link to clipboard
Copied
Thanks Guys!!! I really appreciate the help
Copy link to clipboard
Copied
Hi Paul
app.activeDocument.pages.everyItem().splineItems.everyItem().images.everyItem().fit(FitOptions.CENTER_CONTENT);
Will apply to all placed images outside groups
app.activeDocument.pages.everyItem().groups.everyItem().splineItems.everyItem().images.everyItem().fit(FitOptions.CENTER_CONTENT);
Will apply to all the items in groups
The above is in Java Script and not Java.
Trevor