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

Fit frame to content?

Community Beginner ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

I can't find a way to set up the Fit frame to content as an Object Style Option. If that's not possible to accomplish, is there a way somehow to automate this function via script?

 

I have to place multiple images in my document, and I use Object Styles which resizes frame and image 

Size and Position Options → Size → Adjust Width Only

Frame Fitting Options → Fitting → Fit Content Proportionally

but that leaves the frame overset above and below the image so I need to click Fit frame to content every time.

TOPICS
Scripting

Views

604

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

Community Expert , Apr 22, 2022 Apr 22, 2022

Hi @adamm.rs , you could script the application of the object style, followed by fit frame to content.

 

So after you place, and while the placed object’s frame is still selected, run this (change "YourFitStyleName" to the name of your style). You can assign a key command to a script.

 

 

 

var sn = "YourFitStyleName"
var s=app.activeDocument.selection[0];  
s.appliedObjectStyle = app.activeDocument.objectStyles.itemByName(sn)
s.fit(FitOptions.FRAME_TO_CONTENT);

 

 

Votes

Translate

Translate
Community Expert ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

Hi @adamm.rs , you could script the application of the object style, followed by fit frame to content.

 

So after you place, and while the placed object’s frame is still selected, run this (change "YourFitStyleName" to the name of your style). You can assign a key command to a script.

 

 

 

var sn = "YourFitStyleName"
var s=app.activeDocument.selection[0];  
s.appliedObjectStyle = app.activeDocument.objectStyles.itemByName(sn)
s.fit(FitOptions.FRAME_TO_CONTENT);

 

 

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 ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

Hi Rob, 
awesome, this works! 🙂 Thank you very much!

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
Engaged ,
May 15, 2024 May 15, 2024

Copy link to clipboard

Copied

LATEST

In the InDesign user interface,  double-click on the name the object style to open "Object Style Options". In "Basic Attributes", click on "Frame Fitting Options" and in "Content Fitting" make sure that "Fitting" is set to "Fit Content Proportionally"

 

In a script, use something like this:

myObjectStyle.enableFrameFittingOptions = true;
myObjectStyle.frameFittingOptions.fittingOnEmptyFrame = EmptyFrameFittingOptions.PROPORTIONALLY;

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