Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Fit Options - frame to content - Extendscript

Community Beginner ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

I'm pretty familiar with using the FitOptions enums to, say, resize an image proportionally within its frame or snug a one-paragraph textFrame to its content by using FitOptions.FRAME_TO_CONTENT.

 

What I'm not sure how to do is: Given a textFrame with multiple paragraphs, how do I replicate the application behaviour of a user double clicking the bottom handle of that textFrame in ExtendScript? I guess any handle will do. It'd be all useful info.

 

Can it be done with inbuilt DOM methods or do I have to code it explicitly?

 

I understand FitOptions.FIT_FRAME_TO_CONTENT will snug a frame to the least possible X and Y values, given its content. But I only want to fit the frame to the content using its least possible Y values.

 

As an example, say, I've created a textFrame with geometricBounds of [2,2,7,4] in inches. If the parentStory.contents of that frame puts the bottom of the frame at four inches deep, how should I pull it up?

 

Thanks!

TOPICS
Scripting

Views

98

Likes

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 ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

There is a resize method for textFrames. Sorry folks, I should have read it fully before posting.

Likes

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
Enthusiast ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

Hi, I'm interested how you did it. I've never done it before and this is what I came up with:

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var tf = app.activeDocument.selection[0];
var bounds = tf.geometricBounds;
var lastLine = tf.texts[0].lines.lastItem();
bounds[2] = lastLine.baseline;
tf.geometricBounds = bounds;

Is there a simpler way, eg. by using FIT_FRAME_TO_CONTENT?

- Mark

Likes

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
Adobe Community Professional ,
Aug 15, 2021 Aug 15, 2021

Copy link to clipboard

Copied

This is good, but not quite the same as double-clicking the bottom of the frame, because double-clicking will also increase the height of the frame if there is overset text in it, and your code won't.

So if that's a concern, you'd just have to first increase the height of the frame and then run your function.

But the essentials are all there in your code. I don't think there's a better way of doing it.

(I don't think the code will work for rotated frames, though... so that would be another complication to deal with if necessary.)

Likes

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
Adobe Community Professional ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

LATEST

Hi Toques,

is this text frame part of a story with several text frames threaded?

 

If not you could do it with auto height from the text frame options:

var tf = app.selection[0];

var props = 
{
	autoSizingReferencePoint : AutoSizingReferenceEnum.TOP_CENTER_POINT ,
	autoSizingType : AutoSizingTypeEnum.HEIGHT_ONLY ,
	useNoLineBreaksForAutoSizing : false ,
	verticalJustification : VerticalJustification.TOP_ALIGN	
};

tf.textFramePreferences.properties = props;

 

InDesign CS6 to InDesign 2021.

 

Regards,
Uwe Laubender

( ACP )

Likes

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