Skip to main content
frameexpert
Community Expert
Community Expert
May 16, 2024
Answered

Autofit Rotated Table Cells

  • May 16, 2024
  • 2 replies
  • 457 views

Hi All,

I have some InDesign tables with rotated heading rows. Is there a way to automatically expand the row height to accomodate overset cells? I am open to a scripting solution if necessary. Thank you.

Rick

This topic has been closed for replies.
Correct answer cronban

Sorry, I wasn't clear.  The header was not resizing to the longest content. Instead it was resizing to seemingly random hights. BUT, weirdly, I cannot reproduce it, and now it's working perfectly!
I'd like to add that I'm inmensely thankful to you, Peter Krahel. You've helped me so much over the years! Cheers!

 

2 replies

Peter Kahrel
Community Expert
Community Expert
May 20, 2024

@cronban :

the math for the resizing part is not working for me...  it resizes to strange measures

In what way does it not work, and what are 'starnge measures'?

Maybe show one of your tables.

cronbanCorrect answer
Participant
May 20, 2024

Sorry, I wasn't clear.  The header was not resizing to the longest content. Instead it was resizing to seemingly random hights. BUT, weirdly, I cannot reproduce it, and now it's working perfectly!
I'd like to add that I'm inmensely thankful to you, Peter Krahel. You've helped me so much over the years! Cheers!

 

Peter Kahrel
Community Expert
Community Expert
May 19, 2024

You can use something like this:

row = myTable.rows[0];

if (row.cells.everyItem().overflows.join('').indexOf('true') < 0) {
  // No overset cells
  exit();
}

// Expose all cell content
row.height = '5cm'

// Then size the row to the longest content
top = Math.min.apply (null, row.cells.everyItem().lines.everyItem().insertionPoints[-1].baseline);
row.height = row.cells[0].topInset + row.cells[0].bottomInset + top;

 

Participant
May 20, 2024

Thank you very much!

I've tested with dummy tables, but the math for the resizing part is not working for me...  it resizes to strange measures depending on the amount of text, and sometimes it gives me the error "Error String: The property is not applicable in the current state."

Thank you again