Skip to main content
adamm.rs
Participating Frequently
April 22, 2022
Answered

Fit frame to content?

  • April 22, 2022
  • 2 replies
  • 1415 views

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.

This topic has been closed for replies.
Correct answer rob day

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);

 

 

2 replies

Jeremy bowmangraphics
Inspiring
May 15, 2024

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;

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
April 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);

 

 

adamm.rs
adamm.rsAuthor
Participating Frequently
April 22, 2022

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