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

is .overflows property not working?

Explorer ,
Jul 16, 2024 Jul 16, 2024

Copy link to clipboard

Copied

I am trying to determine if text frames or cells in a table have overset text using .overflows. I was under the impression that a table overflow could be determined using table.overflow, but it seems to give me unexpected results. Is it possible that this property is no longer reliable, or perhaps it is not capable of checking overflow in the celluar level? I am using UXP with the InDesign DOM.

TOPICS
Bug , UXP Scripting

Views

652

Translate

Translate

Report

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 , Jul 17, 2024 Jul 17, 2024

I think I was under the impression that I could use textframe.overflows to determine if a table had overset text.

 

I can‘t help with UXP, but with JS, the cell itself can have an overflow, or it can contain a textframe with an overflow. Here‘s a JS example:

 

var c = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements()

var s = "Overflows:\r"
for (var i = 0; i < c.length; i++){
    //true if the cell itself has a text overflow
    if (c[i].overflows) {
      
...

Votes

Translate

Translate
Explorer , Jul 17, 2024 Jul 17, 2024

Gotcha, okay so it seems that there is no way to check if any cell on a table has overflow without checking each cell's overflow property. Otherwise, you are checking the overflow of the text frame, which is not quite the same scenario. Alright, that makes sense. Thank you for clarifying. 

Votes

Translate

Translate
Community Expert ,
Jul 16, 2024 Jul 16, 2024

Copy link to clipboard

Copied

What do you see in the InDesign

 

Votes

Translate

Translate

Report

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
Contributor ,
Jul 16, 2024 Jul 16, 2024

Copy link to clipboard

Copied

Sometimes it helps to check with “properties”, e.g.

 

Cell.properites.overflows

 

or using

Cell.recompose() 

 

Votes

Translate

Translate

Report

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Hi @MahmoodTheDoom , Are you sure there are no text frames nested in the cells? With JavaScript the first cell in this table returns .overflows as true, but the 2nd cell returns false because the overflow is in a textframe pasted into the cell, not the cell itself:

 

Screen Shot 10.png

Votes

Translate

Translate

Report

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

I think I was under the impression that I could use textframe.overflows to determine if a table had overset text. That does not seem to be the case after testing this property a bit. If I had a table with cells that could have overset text, the only way to determine that is to loop through each cell and check the cell.overflows property. Is that correct? 

I tried using the story, but that does not seem to work. 

Votes

Translate

Translate

Report

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

I think I was under the impression that I could use textframe.overflows to determine if a table had overset text.

 

I can‘t help with UXP, but with JS, the cell itself can have an overflow, or it can contain a textframe with an overflow. Here‘s a JS example:

 

var c = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements()

var s = "Overflows:\r"
for (var i = 0; i < c.length; i++){
    //true if the cell itself has a text overflow
    if (c[i].overflows) {
        s+="Cell " + c[i].index + " has overflow text\r"
    } 
    //true if the cell contains a text frame
    if (c[i].textFrames.length) {
        //true if the text frame has an overflow
        if (c[i].textFrames[0].overflows) {
            s+="Cell " + c[i].index + " contains a text frame with overflow text\r"
        } 
    } 
};   
alert(s)

 

Here the first cell has an overflow, and the 2nd cell has a text frame with an overflow.

I have to check if there are text frames in the cells:

Screen Shot 13.png

Votes

Translate

Translate

Report

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Gotcha, okay so it seems that there is no way to check if any cell on a table has overflow without checking each cell's overflow property. Otherwise, you are checking the overflow of the text frame, which is not quite the same scenario. Alright, that makes sense. Thank you for clarifying. 

Votes

Translate

Translate

Report

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 ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

@MahmoodTheDoom

 

Table doesn't have overflows property, so you need to check every Cell.

 

@rob day provided great example - but I would change one thing - instead of checking only FIRST TF of each Cell - used everyItem() to get all TFs from all Cells - just in case 2nd, 3rd, Nth has overflow.

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

everyItem() to get all TFs from all Cells - just in case 2nd, 3rd, Nth has overflow.

 

Also, there could be any number of nested textframes, so getting every text frame might not work. Would be better to get allPageItems and check the array for a text frame with an overflow.

 

 

 

 

 

var c = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().getElements()

var s = "Overflows:\r"
var api;
for (var i = 0; i < c.length; i++){
    //true if the cell itself has a text overflow
    if (c[i].overflows) {
        s+="Cell " + c[i].index + " has overflow text\r"
    } 
    api = c[i].allPageItems
    //true if the cell contains a page item
    if (api.length) {
        for (var j = 0; j < api.length; j++){
            //the page item is a text frame with an overflow
            if (api[j].constructor.name == "TextFrame" && api[j].overflows) {
                s+="Cell " + c[i].index + " contains a text frame with overflow text\r"
            } 
        };   
    } 
};   
alert(s)

 

 

 

 

 
Screen Shot 25.png

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

@rob day 

 

So we could do it like that?

 

 

var TFs = app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().allPageItems.everyItem().getElements()

 

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

.allPageItems is not a collection it’s an array, so it will not take .everyitem()

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

quote

.allPageItems is not a collection it’s an array, so it will not take .everyitem()


By @rob day

 

So in JS it's not the same type as .pageItems?

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

Right it‘s an array, and arrays don’t have a collection’s everyItem() method. Your code throws this error:

 

 

Screen Shot 26.png

 

 

.pageItems is a collection and can use the everyItem() method but it wouldn’t get nested frames—this kind of thing is the reason for the .allPageItems property:

 

 

 

 

 

Screen Shot 29.png

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

@rob day

 

Thanks. A bit strange - both should be collections? 

 

Will this work - I'm on my phone - myTable.pageItems or myTable.allPageItems - instead of everyItem()?

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

It’s designed as a shortcut. Consider this case where cell 1 contains 5 page items:

 

Screen Shot 32.png

 

 

.pageItems.everyItem() returns just the one text frame, while .allPageItems returns an array of everything inside the cell’s text frame

 

var pi = app.documents[0].stories.everyItem().tables.everyItem().cells[0].pageItems.everyItem().getElements();
$.writeln(pi)
//returns [object TextFrame]

var api = app.documents[0].stories.everyItem().tables.everyItem().cells[0].allPageItems;
$.writeln(api)
//returns [object TextFrame],[object Group],[object Oval],[object TextFrame],[object TextFrame]

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

LATEST

@rob day

 

I know what is the difference between pageItems and allPageItems - 1st is just a "first level" and 2nd is "all, even if part of the group, etc." - why in both cases it can't be a collection? It's returned "flat" anyway. 

 

In my tool - written in VisualBasic - I'm declaring my variable as Variant - then, depends on if user wants 1st level or all - set 1st or 2nd - the rest of the code remains exactly the same - and I don't even have to care from what object I'm "extracting" those collections.

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

Hi @MahmoodTheDoom ,

be aware, that there is another kind of visual indicator that an "overflow" will very likely occur if you add contents with e.g. cell.contents = "String" to a table's text cell. The end of story marker is not showing when the cell is on fixed height and the point size of the first insertion point exceeds a certain value:

 

Bildschirmfoto 2024-07-18 um 16.38.00.png

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

Very good point! We currently utilize these indications, but we wanted to create a script that could easily check all tables in case someone missed a text frame 🙂 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

quote

Very good point! We currently utilize these indications, but we wanted to create a script that could easily check all tables in case someone missed a text frame 🙂 


By @MahmoodTheDoom

 

You can use Preflight for that:

RobertatIDTasker_0-1721315366947.png

 

2nd cell has a TF inside - 3rd has a text bigger than available height - but there is a red dot - to the contrary of what @Laubender suggested? 

RobertatIDTasker_0-1721315530885.png

 

Votes

Translate

Translate

Report

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 ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

But it doesn't show TextFrame's overset - when Cell is already overset:

RobertatIDTasker_1-1721315640702.png

 

RobertatIDTasker_2-1721315669997.png

 

Which is rather OK - as TF in an overset Cell - doesn't have GeometricBounds anyway.

 

Votes

Translate

Translate

Report

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