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

ExtendScript, InDesign 2022: Return `parentPage`s of last cells of all tables

Engaged ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

I’m trying to bring this function alive:

 

$.writeln( findPagesOfLastCells() );

function findPagesOfLastCells() {
// https://community.adobe.com/t5/indesign-discussions/javascript-property-to-tell-if-text-is-in-a-continued-table/td-p/6379093
    var aDoc = app.activeDocument,
        allTables = aDoc.stories.everyItem().tables,
        thePages = []; 
    if( allTables.length > 0 ) {
        for ( var i = 0; i < allTables.length; i++ ) {
            var theTable = allTables[i];
$.writeln('***********tables************\n'+theTable);
            if ( theTable.rows.length > 1 ) {
                var lastRowPage = 0;
                lastRowPage = theTable.rows[-1].cells[-1].insertionPoints[-1].parentTextFrames[0].parentPage;
$.writeln(lastRowPage);
                thePages.push(lastRowPage.name);
$.writeln(lastRowPage.name);
            }
        }
    }
    return thePages;
}

 

 The crucial parts is here:

 

lastRowPage = theTable.rows[-1].cells[-1].insertionPoints[-1].parentTextFrames[0].parentPage;

This doesn’t work and results to undefined. It works fine with this:

theTable.rows[-1].cells[-1].insertionPoints[-1]

I get an insertion point with all properties, including a parentTextFrames property. But extending to

theTable.rows[-1].cells[-1].insertionPoints[-1].parentTextFrames[0]

I get a text frame reference with no property at all.

 

Is this a bug? Am I doing something wrong?

 

Thanks for your kind help,

Tobias

 

TOPICS
Scripting

Views

2.8K

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

Engaged , May 14, 2022 May 14, 2022

Uwe, this is pretty nasty, puh – thank you very much for pointing this out!

So for completeness sake:

$.writeln( findPagesOfLastCells() );

function findPagesOfLastCells() {
// https://community.adobe.com/t5/indesign-discussions/javascript-property-to-tell-if-text-is-in-a-continued-table/td-p/6379093
    var aDoc = app.activeDocument,
        allTables = aDoc.stories.everyItem().tables,
        thePages = []; 
    if( allTables.length > 0 ) {
        for ( var i = 0; i < allTables.length; i++ ) {
...

Votes

Translate

Translate
Community Expert , May 16, 2022 May 16, 2022

Hi @tobias.wantzen , Uwe used the table storyOffset property answering another post this morning, and it seems like it might work here. You can get a table‘s trailing insertionPoint to find which page it ends on. Something like this:

 

var et = app.activeDocument.stories.everyItem().tables.everyItem().getElements();

alert(findPagesOfLastCells(et))


/**
* Gets the parent page of a table’s end 
* @ param a collection of tables
* @ return an array of page names 
* 
*/
function findPagesOfLastCell
...

Votes

Translate

Translate
Community Expert ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

Hi Tobias,

voted and commented your feature request.

 

Thanks,
Uwe Laubender
( Adobe Community Professional )

 

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
Engaged ,
May 17, 2022 May 17, 2022

Copy link to clipboard

Copied

Thanks, Uwe! And, yes, geometricBounds and visibleBounds would be nice either.

 

Feature requests are very frustrating. Years pass and nothing happens. It’s nearly as frustrating as the few new features in new InDesign versions.

To the community it looks, like InDesign’s development is nearly dead.

 

Kind regards,

Tobias

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