Highlighted

Fit to frame with vertical justification options

New Here ,
May 10, 2020

Copy link to clipboard

Copied

Working with InDesign script I am using

TF.fit(FitOptions.frameToContent).  //TF as a textFrame

to fit the content into the text frame and remove the extra space

But when I have a condition for vertical justification options set to Align: Bottom I am not able to fit the content.

Assuming this to be my TextFrame

 

l6Whj

Here are the properties of the text frame

Kb63Z

When I do FitOptions.frameToContent I get this

piuaI

But when the text frame has the align property set to the bottom I want this to fit it like this(this was achieved by double-clicking on the top center alignment as shown in the red indicator below.

XPh1S

Cyf37

I tried all the available options at http://jongware.mit.edu/idcs4js/pe_FitOptions.html but I had no luck making it work. Please help me to achieve the same using scripting.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

As an alternative you could use the AutoResize property of the textframe to achieve what you need. See the screengrab below

https://www.dropbox.com/s/tgfyrwzdvb4zcbv/screen%20recording%202020-05-11%20at%2010.21.12%20am.mov?dl=0

 

-Manan

TOPICS
Scripting

Views

591

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

Fit to frame with vertical justification options

New Here ,
May 10, 2020

Copy link to clipboard

Copied

Working with InDesign script I am using

TF.fit(FitOptions.frameToContent).  //TF as a textFrame

to fit the content into the text frame and remove the extra space

But when I have a condition for vertical justification options set to Align: Bottom I am not able to fit the content.

Assuming this to be my TextFrame

 

l6Whj

Here are the properties of the text frame

Kb63Z

When I do FitOptions.frameToContent I get this

piuaI

But when the text frame has the align property set to the bottom I want this to fit it like this(this was achieved by double-clicking on the top center alignment as shown in the red indicator below.

XPh1S

Cyf37

I tried all the available options at http://jongware.mit.edu/idcs4js/pe_FitOptions.html but I had no luck making it work. Please help me to achieve the same using scripting.

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

As an alternative you could use the AutoResize property of the textframe to achieve what you need. See the screengrab below

https://www.dropbox.com/s/tgfyrwzdvb4zcbv/screen%20recording%202020-05-11%20at%2010.21.12%20am.mov?dl=0

 

-Manan

TOPICS
Scripting

Views

592

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
May 10, 2020 0
Adobe Community Professional ,
May 10, 2020

Copy link to clipboard

Copied

As an alternative you could use the AutoResize property of the textframe to achieve what you need. See the screengrab below

https://www.dropbox.com/s/tgfyrwzdvb4zcbv/screen%20recording%202020-05-11%20at%2010.21.12%20am.mov?d...

 

-Manan

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
Reply
Loading...
May 10, 2020 1
New Here ,
May 10, 2020

Copy link to clipboard

Copied

How do I achieve that through scripting? an example would be much appreciated.

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
Reply
Loading...
May 10, 2020 0
Adobe Community Professional ,
May 10, 2020

Copy link to clipboard

Copied

Try the following

 

tf.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.BOTTOM_CENTER_POINT
tf.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY

 

tf here represents the textframe object

 

-Manan

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
Reply
Loading...
May 10, 2020 0
New Here ,
May 10, 2020

Copy link to clipboard

Copied

tf.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.BOTTOM_CENTER_POINT
tf.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY
tf.fit(FitOptions.frameToContent)

I tried the above code and that doesn't seem to work in my case. Here are my text frame autosize properties.

Screenshot 2020-05-11 at 11.22.07 AM.png

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
Reply
Loading...
May 10, 2020 0
Adobe Community Professional ,
May 10, 2020

Copy link to clipboard

Copied

That seems to be right, i demonstrated it working on the sample screengrab. So you mean to say it works for you when you do it manually and not via script, or did you not even try it manually and anyways asked for a code sample?

 

-Manan

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
Reply
Loading...
May 10, 2020 0
Adobe Community Professional ,
May 10, 2020

Copy link to clipboard

Copied

Remove the call to the fit method just use the two lines that i sent as code sample and then try

 

-Manan

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
Reply
Loading...
May 10, 2020 0
New Here ,
May 10, 2020

Copy link to clipboard

Copied

It has no effect at all. it just remains the same.

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
Reply
Loading...
May 10, 2020 0
Adobe Community Professional ,
May 10, 2020

Copy link to clipboard

Copied

I also asked you some questions that you did not answer, do you expect us to just guess around on what maybe an issue causing things not working for you? I am stating the questions again

  • Did it work manually for you or not?
  • Did you try it on different frames or just one, maybe the textframe has some property that is causing the issue?

-Manan

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
Reply
Loading...
May 10, 2020 0
New Here ,
May 11, 2020

Copy link to clipboard

Copied

Yeah, So here are the answers

  • When I tried to double click on the top center point as mentioned in the question its working fine. 
  • Yes, I tried it on another text frame and it doesn't work.

Please do let me know if you need any further specific properties on the text frame I will share them. Thanks for helping me.

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
Reply
Loading...
May 11, 2020 0
Explorer ,
May 11, 2020

Copy link to clipboard

Copied

hi,
if textframe has a rotationAngle, you will have more problems ))

 

your way:
1. save textFramePreferences (inset, autosize, etc)

2. save geometricBounds (then move textframe to your alignment point)

3. reset to zero textFramePreferences

4. set FitOptions which you want

5. set saved textFramePreferences

6. move textframe

 

good luck!

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
Reply
Loading...
May 11, 2020 0
Adobe Community Professional ,
May 11, 2020

Copy link to clipboard

Copied

Upload a document with just a single textframe that has this issue. I can have a look. Use Dropbox or similiar service and paste the public url here

 

-Manan

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
Reply
Loading...
May 11, 2020 1