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

Newbie in need of help CENTER_CONTENT

Community Beginner ,
Nov 04, 2012 Nov 04, 2012

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

TOPICS
Scripting

Views

922

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 1 Correct answer

Guru , Nov 04, 2012 Nov 04, 2012

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

Votes

Translate

Translate
Advisor ,
Nov 04, 2012 Nov 04, 2012

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}

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
Guru ,
Nov 05, 2012 Nov 05, 2012

Copy link to clipboard

Copied

Hi Vamital

I didn't see your answer when I wrote mine

Not that it matters!

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
Community Beginner ,
Nov 05, 2012 Nov 05, 2012

Copy link to clipboard

Copied

LATEST

Thanks Guys!!! I really appreciate the help

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
Guru ,
Nov 04, 2012 Nov 04, 2012

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

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