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

Fit to frame with vertical justification options

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

TOPICS
Scripting

Views

1.4K

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 3 Correct answers

Community Expert , May 10, 2020 May 10, 2020

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

Votes

Translate

Translate
Community Expert , May 10, 2020 May 10, 2020

Try the following

 

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

 

tf here represents the textframe object

 

-Manan

Votes

Translate

Translate
Participant , May 11, 2020 May 11, 2020

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!

Votes

Translate

Translate
Community Expert ,
May 10, 2020 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

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
New Here ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

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

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 Expert ,
May 10, 2020 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

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
New Here ,
May 10, 2020 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

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 Expert ,
May 10, 2020 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

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 Expert ,
May 10, 2020 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

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
New Here ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

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

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 Expert ,
May 10, 2020 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

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
New Here ,
May 11, 2020 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.

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
Participant ,
May 11, 2020 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!

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 Expert ,
May 11, 2020 May 11, 2020

Copy link to clipboard

Copied

LATEST

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

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