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.
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);
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);
Copy link to clipboard
Copied
Hi Rob,
awesome, this works! 🙂 Thank you very much!
Copy link to clipboard
Copied
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;