Highlighted

Problem Extracting Characters from Table Lines Using Indesign Server 2019

Community Beginner ,
Apr 07, 2020

Copy link to clipboard

Copied

Hello - I am running into an intermittent issue around extracting characters from lines using IndesignServer. The task is to determine the number of lines that have at least one character with a Bold character style applied. For lines outside of tables, I can extract characters using something like this:
template.stories.item(0).lines[0].characters....
However, when I try to do something similar to extract characters from lines in a table
template.stories.item(0).tables[0].columns[0].cells[0].texts[0].lines[0].characters
I get
ReferenceError: Object is invalid
This is specifically referring to the last attempt to index into the characters in the second example. Any thoughts?
Adobe Community Professional
Correct answer by Sunil_Yadav1 | Adobe Community Professional

Hi,

Try this : 

 

for(var s = 0; s < template.stories.length; s++){
    for(var t = 0; t < template.stories[s].tables.length; t++){
        var table = template.stories[s].tables[t];
        for(var c = 0; c < table.cells.length; c++){
            if(table.cells[c].overflows == false){
                for(var l = 0; l < table.cells[c].lines.length; l++){
                    var characters = table.cells[c].lines[l].characters;
                    // Do you work
                    }
                }
            }
        }
    }

 

Best

Sunil

Topics

Scripting, Server developers

Views

239

Likes

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

Problem Extracting Characters from Table Lines Using Indesign Server 2019

Community Beginner ,
Apr 07, 2020

Copy link to clipboard

Copied

Hello - I am running into an intermittent issue around extracting characters from lines using IndesignServer. The task is to determine the number of lines that have at least one character with a Bold character style applied. For lines outside of tables, I can extract characters using something like this:
template.stories.item(0).lines[0].characters....
However, when I try to do something similar to extract characters from lines in a table
template.stories.item(0).tables[0].columns[0].cells[0].texts[0].lines[0].characters
I get
ReferenceError: Object is invalid
This is specifically referring to the last attempt to index into the characters in the second example. Any thoughts?
Adobe Community Professional
Correct answer by Sunil_Yadav1 | Adobe Community Professional

Hi,

Try this : 

 

for(var s = 0; s < template.stories.length; s++){
    for(var t = 0; t < template.stories[s].tables.length; t++){
        var table = template.stories[s].tables[t];
        for(var c = 0; c < table.cells.length; c++){
            if(table.cells[c].overflows == false){
                for(var l = 0; l < table.cells[c].lines.length; l++){
                    var characters = table.cells[c].lines[l].characters;
                    // Do you work
                    }
                }
            }
        }
    }

 

Best

Sunil

Topics

Scripting, Server developers

Views

240

Likes

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
Adobe Community Professional ,
Apr 08, 2020

Copy link to clipboard

Copied

Hi,

Try this : 

 

for(var s = 0; s < template.stories.length; s++){
    for(var t = 0; t < template.stories[s].tables.length; t++){
        var table = template.stories[s].tables[t];
        for(var c = 0; c < table.cells.length; c++){
            if(table.cells[c].overflows == false){
                for(var l = 0; l < table.cells[c].lines.length; l++){
                    var characters = table.cells[c].lines[l].characters;
                    // Do you work
                    }
                }
            }
        }
    }

 

Best

Sunil

Likes

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
Reply
Loading...