Copy link to clipboard
Copied
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?
Unfortunately not:
will fit correctly:
But when not all rows of the Table are visible:
will extend horizontally:
In this case - won't budge at all - all rows won't be visible anyway:
BUT, as long...
... as after 1st fit whole Table can fit:
2nd fit will do the job:
BUT - not a problem at all with Text only:
Aha. Good sleuthing. Well, the workaround stands: move the table's frame to the top left and resize it there.
Copy link to clipboard
Copied
What exactly is wrong?
Can you post a screenshot?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Can you share your document?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Same problem in InDesign 2023 / 18.5.1 x64 on PC.
Copy link to clipboard
Copied
Yep I am actually fitting twice and still seeing this issue.
Copy link to clipboard
Copied
It's
textFrame.fit(FitOptions.FRAME_TO_CONTENT);
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Unfortunately not:
will fit correctly:
But when not all rows of the Table are visible:
will extend horizontally:
In this case - won't budge at all - all rows won't be visible anyway:
BUT, as long...
... as after 1st fit whole Table can fit:
2nd fit will do the job:
BUT - not a problem at all with Text only:
Copy link to clipboard
Copied
Aha. Good sleuthing. Well, the workaround stands: move the table's frame to the top left and resize it there.
Copy link to clipboard
Copied
> 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);