Skip to main content
Known Participant
July 27, 2020
Answered

table textframe not fit to frame

  • July 27, 2020
  • 1 reply
  • 349 views

Hi Everyone,

After updating the content in my table the table content overflows and it need not fit with frame.

See the below code :

 

var table = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements()
for(c=0; c<table.length; c++){
if(table[c].contents.match(/LINKED IMAGES:/)){//Update the Linked Images
table[c+3].contents = "Link Names: \r" + Links;
 
}
table.parentTextFrames.fit(FitOptions.FRAME_TO_CONTENT)
}
This topic has been closed for replies.
Correct answer Sunil Yadav

Try this code snippet:

for(var s = 0; s < app.activeDocument.stories.length; s++){
    var tempStory = app.activeDocument.stories[s];
    for(var t = 0; t < tempStory.tables.length; t++){
        var tempTable = tempStory.tables[t];
        var tempTableFrame = tempTable.cells[0].insertionPoints[0].parentTextFrames[0];
        var cells = tempTable.cells;
        for(var c=0; c < cells.length; c++){
            if(cells[c].contents.match(/LINKED IMAGES:/)){
                cells[c].contents = "Link Names: \r" + Links;
                }
            tempTableFrame.fit(FitOptions.FRAME_TO_CONTENT);
            }
        }
    }

Best

Sunil

1 reply

Sunil Yadav
Sunil YadavCorrect answer
Legend
October 10, 2020

Try this code snippet:

for(var s = 0; s < app.activeDocument.stories.length; s++){
    var tempStory = app.activeDocument.stories[s];
    for(var t = 0; t < tempStory.tables.length; t++){
        var tempTable = tempStory.tables[t];
        var tempTableFrame = tempTable.cells[0].insertionPoints[0].parentTextFrames[0];
        var cells = tempTable.cells;
        for(var c=0; c < cells.length; c++){
            if(cells[c].contents.match(/LINKED IMAGES:/)){
                cells[c].contents = "Link Names: \r" + Links;
                }
            tempTableFrame.fit(FitOptions.FRAME_TO_CONTENT);
            }
        }
    }

Best

Sunil