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

Resize TextFrame Not Performing Correctly

Explorer ,
Dec 26, 2023 Dec 26, 2023

Hello, 

 

I have been resizing textframes of tables using the following code in UXP scripting: 

textFrame.fit(inDesign.FitOptions.FRAME_TO_CONTENT);


However, in the case that the table is outisde of the page bounds, like somewhere below the page for example, this code no longer works as expected. What is a good solution for resizing the textframe to fit its corresponding table bounds in these instances? 

TOPICS
Bug , How to , Scripting , UXP Scripting
643
Translate
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 2 Correct answers

Community Expert , Dec 27, 2023 Dec 27, 2023

Unfortunately not:

RobertTkaczyk_0-1703697184080.png

will fit correctly:

RobertTkaczyk_1-1703697217926.png

 

But when not all rows of the Table are visible:

RobertTkaczyk_2-1703697259024.png

will extend horizontally:

RobertTkaczyk_3-1703697272881.png

 

 

In this case - won't budge at all - all rows won't be visible anyway:

RobertTkaczyk_4-1703697350936.png

 

 

BUT, as long...

RobertTkaczyk_5-1703697418372.png

... as after 1st fit whole Table can fit:

RobertTkaczyk_6-1703697427167.png

2nd fit will do the job:

RobertTkaczyk_8-1703697454430.png

 

BUT - not a problem at all with Text only:

RobertTkaczyk_9-1703697558133.png

 

RobertTkaczyk_10-1703697566875.png

 

Translate
Community Expert , Dec 27, 2023 Dec 27, 2023

Aha. Good sleuthing. Well, the workaround stands: move the table's frame to the top left and resize it there.

Translate
Community Expert ,
Dec 26, 2023 Dec 26, 2023

What exactly is wrong? 

 

Can you post a screenshot? 

 

Translate
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
Explorer ,
Dec 27, 2023 Dec 27, 2023

So when I try and use the .fit function for a textframe on a table below the inDesign page, it does not fit around the table, and it just extends to infinite bounds.
forum.PNG

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

Can you share your document? 

 

Translate
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
Explorer ,
Dec 27, 2023 Dec 27, 2023

Sorry for confidentiality reasons I cannot, but the context is that when a table is loaded below a page, and the line of code is ran, it causes this issue. In the case where it is loaded on the page, it works perfectly well. 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

Looks like you've just found a bug??

 

I can confirm, that in ID 19.0.1 x64 on a PC - TextFrame won't fit properly to the contents.

 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

But only for Tables - and only in "specific" conditions.

 

Even when part of the TextFrame is part of the Page - it still won't fit properly.

 

Also, you may need to use Fit twice - first will fit vertically, then the second will fit horizontally.

 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

Same problem in InDesign 2023 / 18.5.1 x64 on PC.

 

Translate
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
Explorer ,
Dec 27, 2023 Dec 27, 2023

Yep I am actually fitting twice and still seeing this issue. 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

It's

textFrame.fit(FitOptions.FRAME_TO_CONTENT);
Translate
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
Explorer ,
Dec 27, 2023 Dec 27, 2023

I receive an error saying FitOptions is not defined. For context, one line before this I was using this: 

const inDesign = require("indesign")

which would provide me the option to use inDesign.FitOptions

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

Didn't read your post correctly.

The behaviour you see happens only when the bottom of the text frame extends below the bottom of the pasteboard. Clearly a bug. The workaround is to move the table up so that the whole frame is on the pasteboard (not necessarily the page).

 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

Not exactly - doesn't matter if TF is extending to the next Spread's Pasteboard or fits in the current Spread's Pasteboard or is on the side and not below of the Page or if part of the TF is on the page - it still won't fit propery.

 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

If the text frame is entirely on the pasteboerd it doesn't matter where it is relative to the page, it's always resized correctly. Only if the bottom of the frame extends beyond the bottom of the pasteboard does the fit() función not work correctly.

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

Unfortunately not:

RobertTkaczyk_0-1703697184080.png

will fit correctly:

RobertTkaczyk_1-1703697217926.png

 

But when not all rows of the Table are visible:

RobertTkaczyk_2-1703697259024.png

will extend horizontally:

RobertTkaczyk_3-1703697272881.png

 

 

In this case - won't budge at all - all rows won't be visible anyway:

RobertTkaczyk_4-1703697350936.png

 

 

BUT, as long...

RobertTkaczyk_5-1703697418372.png

... as after 1st fit whole Table can fit:

RobertTkaczyk_6-1703697427167.png

2nd fit will do the job:

RobertTkaczyk_8-1703697454430.png

 

BUT - not a problem at all with Text only:

RobertTkaczyk_9-1703697558133.png

 

RobertTkaczyk_10-1703697566875.png

 

Translate
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 ,
Dec 27, 2023 Dec 27, 2023
LATEST

Aha. Good sleuthing. Well, the workaround stands: move the table's frame to the top left and resize it there.

Translate
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 ,
Dec 27, 2023 Dec 27, 2023

I receive an error saying FitOptions is not defined.

 

You need to declare/define FitOptions:

 

const {app, FitOptions} = require("indesign");
app.selection[0].fit (FitOptions.FRAME_TO_CONTENT);
Translate
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