Skip to content

Instantly share code, notes, and snippets.

@narthur
Last active July 8, 2025 21:21
Show Gist options
  • Save narthur/ab7ae5fcc6a723e8bf6f to your computer and use it in GitHub Desktop.
Save narthur/ab7ae5fcc6a723e8bf6f to your computer and use it in GitHub Desktop.
InDesign JSX User Script to Adjust Table Widths Relative to Frame Width
// Inspiration:
// https://forums.adobe.com/message/2524327
// http://www.indiscripts.com/post/2009/10/work-around-the-width-height-gap
var myDoc = app.activeDocument;
function getWidth(/*PageItem*/obj, /*bool*/visible)
// return the [width,height] of <obj>
// according to its (geometric|visible)Bounds
{
var boundsProperty = ((visible)?'visible':'geometric')+'Bounds';
var b = obj[boundsProperty];
// width=right-left
return b[3]-b[1];
}
function adjustTableWidths(relWidths) {
for(var T=0; T < myDoc.textFrames.length; T++){
var frameWidth = getWidth(myDoc.textFrames[T], true);
for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
if(myDoc.textFrames[T].tables[i].columns.length == relWidths.length) {
for(var j=0; j < relWidths.length; j++){
var colWidth = frameWidth * (relWidths[j] / 100);
myDoc.textFrames[T].tables[i].columns[j].width = colWidth;
}
}
}
}
}
adjustTableWidths([50,50]);
adjustTableWidths([26,44,20]);
alert("Table widths updated successfully!");
@dj-sash
Copy link

dj-sash commented Jul 8, 2025

Hi. This is no more working on the new indesign version. Can you fix it for the indesign 2025 ?
Thanks

@narthur
Copy link
Author

narthur commented Jul 8, 2025

Sorry, I no longer have access to InDesign. Afraid you're on your own on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment