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

How to get those page numbers that contain tables, Collect the results into a notepad.

Advisor ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

How to get those page numbers that contain tables, Collect the results into a notepad.

I'm trying to quickly find pages that contain tables.

 

TOPICS
Feature request , How to , Performance , Scripting , Type

Views

557
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

Guide , Jan 09, 2025 Jan 09, 2025
/*
    _FRIdNGE-0778_TablePageExtraction.jsx
    Script written by FRIdNGE, Michel Allio [08/01/25]
*/

// I suppose an .indd document open with Tables! ...
var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
var myTablePages = [];
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t]
    if ( myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.paragraphs[0].insertionPoints[-2].parentTe
...

Votes

Translate
Guide , Jan 10, 2025 Jan 10, 2025

4th version:

 

/*
    _FRIdNGE-0778_TablePageExtraction.jsx
    Script written by FRIdNGE, Michel Allio [08/01/25]
*/

// I suppose an .indd document open with Tables! ...
var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
var myTablePages = [];
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t];
    if ( myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.parentStory.insertionPoints[
...

Votes

Translate
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

There's no built-in way do that in InDesign. You (or someone else) might write a script.

Votes

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
Guide ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

Steve, Sure! … Quickly and Just For Fun!

 

/*
    _FRIdNGE-0778_TablePageExtraction.jsx
    Script written by FRIdNGE, Michel Allio [08/01/25]
*/

// I suppose an .indd document open with Tables! ...
var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
var myTablePages = [];
for ( t = 0; t < T; t++ ) {
    if ( myTables[t].storyOffset.parentTextFrames[0].parentPage.name === myTables[t].storyOffset.paragraphs[0].insertionPoints[-1].parentTextFrames[0].parentPage.name ) myTablePages.push(myTables[t].storyOffset.parentTextFrames[0].parentPage.name);
    else myTablePages.push(myTables[t].storyOffset.parentTextFrames[0].parentPage.name + "-" + myTables[t].storyOffset.paragraphs[0].insertionPoints[-1].parentTextFrames[0].parentPage.name);
}
var myFile = new File(myDoc.fullName.toString().replace(".indd",".txt"));
myFile.open('w');
myFile.write(myTablePages.sort().join("\r"));
myFile.close();
alert( "Done! ..." )

 

(^/)  The Jedi

Votes

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 ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

Thanks for the quick script!

Votes

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
Advisor ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

Hi FRIdNGE

It is Too classic!

Thank you very much.
But I think I missed some tables.

Last time, you provided more precise conditions

 

( myTables[t].storyOffset.textColumns[0] != myTables[t].storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0])

 

This one finds more eligible tables

 

Votes

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
Advisor ,
Jan 08, 2025 Jan 08, 2025

Copy link to clipboard

Copied

I'm sorry.
I made a mistake.
It's this version that's better.
So far, only found that this table on page 2 is not recognized
Tab168, seems to be just near the bottom?
You can move it around a bit and it works again.

Votes

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
Guide ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

/*
    _FRIdNGE-0778_TablePageExtraction.jsx
    Script written by FRIdNGE, Michel Allio [08/01/25]
*/

// I suppose an .indd document open with Tables! ...
var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
var myTablePages = [];
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t]
    if ( myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.paragraphs[0].insertionPoints[-2].parentTextFrames[0].parentPage ) myTablePages.push(myTable.storyOffset.parentTextFrames[0].parentPage.name);
    else myTablePages.push(myTable.storyOffset.parentTextFrames[0].parentPage.name + "-" + myTable.storyOffset.paragraphs[0].insertionPoints[-2].parentTextFrames[0].parentPage.name);
}
alert( myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r") ) // DEBUGGING - To be removed!
var myFile = new File(myDoc.fullName.toString().replace(".indd",".txt"));
myFile.open('w');
myFile.write(myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r"));
myFile.close();
alert( "Done! ..." )

 

(^/)

Votes

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
Advisor ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

Invincible is perfect.
Thanks a lot.
I actually never could understand "storyOffset and  insertionPoints[-2]"

Votes

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
Guide ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

It is an axiom in the understanding of The Force!  😉

 

(^/)

Votes

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
Advisor ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

Hi FRIdNGE

The story doesn't seem to be over.

The script above only works for table span pages.

 

When the table is in 2 columns.
The result seems to be incorrect.
For example, the sample I provided below:
Using the == condition should only find Tab1 on page 1.

But it also finds Tab2 Tab3.
Tab2-3 settings are correct, (they should skipFirstHeader= true)

 

Votes

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
Guide ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

Aha! Boring!  3rd version! …. 😉

 

/*
    _FRIdNGE-0778_TablePageExtraction.jsx
    Script written by FRIdNGE, Michel Allio [08/01/25]
*/

// I suppose an .indd document open with Tables! ...
var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
var myTablePages = [];
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t];
    if ( myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.parentStory.insertionPoints[myTable.storyOffset.index+1].parentTextFrames[0].parentPage ) myTablePages.push(myTable.storyOffset.parentTextFrames[0].parentPage.name);
    else myTablePages.push(myTable.storyOffset.parentTextFrames[0].parentPage.name + "-" + myTable.storyOffset.parentStory.insertionPoints[myTable.storyOffset.index+1].parentTextFrames[0].parentPage.name);
}
alert( myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r") ) // DEBUGGING - To be removed!
var myFile = new File(myDoc.fullName.toString().replace(".indd",".txt"));
myFile.open('w');
myFile.write(myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r"));
myFile.close();
alert( "Done! ..." )

 

(^/)

Votes

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
Advisor ,
Jan 09, 2025 Jan 09, 2025

Copy link to clipboard

Copied

Still not right.
There seems to be no solution.

 

myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.parentStory.insertionPoints[myTable.storyOffset.index+1].parentTextFrames[0].parentPage )

 


It should only find tab1 on page 1. (Now it's tab1 tab4).

Only tab1 didn't span pages, and it didn't span columns.

Votes

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
Guide ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

Tests on your 2 docs. The Script does exactly what you ask: Find pages that contain tables!!!!!!!!

 

Capture d’écran 2025-01-10 à 11.38.28.pngexpand imageCapture d’écran 2025-01-10 à 11.38.45.pngexpand image

 

(^/)

Votes

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
Advisor ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

I'm sorry I bothered you.

When you output all, you don't see the difference.
This is because the if and else conditions may be incorrect, causing you to look at results that are always right.

But you turn off the "else" and just only test the "if".
You'll see that the if doesn't contain the right content.


In the "Span colums.idml" file I provided.
Only tab1, which does not span  columns or pages,  That's what I call a "lone table".

So when you comment out the "else", only  test if conditon,  you should only get page 1(Tab1).
But now it's pages 1 and 4

Votes

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
Guide ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

The Script searches Tables!

 

If a Table is totally on a page, it will give the current page number.

If it is on several page, it will give the range of its first page and its last page with a "-" between the two numbers!

 

That's all!

The tests on the 2 documents provided by you are correct.

 

(^/)

Votes

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
Advisor ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

Oh.I see.

That "if condition" only determines that the table only takes up one page
But can't differentiate, that the table only takes up 1 page but spans 2 columns.

Votes

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
Guide ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

4th version:

 

/*
    _FRIdNGE-0778_TablePageExtraction.jsx
    Script written by FRIdNGE, Michel Allio [08/01/25]
*/

// I suppose an .indd document open with Tables! ...
var myDoc = app.activeDocument;
var myTables = myDoc.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
var myTablePages = [];
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t];
    if ( myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.parentStory.insertionPoints[myTable.storyOffset.index+1].parentTextFrames[0].parentPage ) {
        if ( myTable.storyOffset.textColumns[0] === myTable.storyOffset.parentStory.insertionPoints[myTable.storyOffset.index+1].textColumns[0] ) myTablePages.push( myTable.storyOffset.parentTextFrames[0].parentPage.name );
        else myTablePages.push( myTable.storyOffset.parentTextFrames[0].parentPage.name + "*" );
    }
    else myTablePages.push( myTable.storyOffset.parentTextFrames[0].parentPage.name + "-" + myTable.storyOffset.parentStory.insertionPoints[myTable.storyOffset.index+1].parentTextFrames[0].parentPage.name );
}
if ( T === 0 ) alert( "No Table! ..." ) // DEBUGGING - To be removed!
else if ( T === 1 ) alert( "Pre-Control, Table on Page:\r" + myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r") ) // DEBUGGING - To be removed!
else alert( "Pre-Control, Tables on Pages:\r" + myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r") ) // DEBUGGING - To be removed!

var myFile = new File(myDoc.fullName.toString().replace(".indd",".txt"));
myFile.open('w');
myFile.write(myTablePages.sort(function(a,b) {return parseFloat(a)-parseFloat(b)}).join("\r"));
myFile.close();
alert( "Done! ..." )

 

Capture d’écran 2025-01-10 à 15.25.07.pngexpand image

 

if a table is on a page but on 2 columns, it's identified by a "*" after the page number!

 

Considering all the scripts you have asked for for some time, it might be a good idea for all to hire a scripter! …

But it's just a comment.

 

(^/) 

Votes

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
Advisor ,
Jan 10, 2025 Jan 10, 2025

Copy link to clipboard

Copied

LATEST

At first, I thought that three lines of code could be taken care of, I didn't realize that so many didn't expect it.

 

Wish more people could learn it too.
Hopefully, Adobe can solve the problem of duplicate catalogs soon.

Thanks a lot.

Good luck, I have to say, you are a star, have a heart of gold.

Votes

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