Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

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

Guía ,
Jan 08, 2025 Jan 08, 2025

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.

 

TEMAS
Solicitud de función , Procedimiento , Rendimiento , Scripts , Texto
1.2K
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines

correct answers 2 respuestas correctas

Guía , 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
...
Traducir
Guía , 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[
...
Traducir
Community Expert ,
Jan 08, 2025 Jan 08, 2025

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 08, 2025 Jan 08, 2025

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Community Expert ,
Jan 08, 2025 Jan 08, 2025

Thanks for the quick script!

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 08, 2025 Jan 08, 2025

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

 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 08, 2025 Jan 08, 2025

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
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].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! ..." )

 

(^/)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 09, 2025 Jan 09, 2025

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 09, 2025 Jan 09, 2025

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

 

(^/)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 09, 2025 Jan 09, 2025

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)

 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 09, 2025 Jan 09, 2025

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! ..." )

 

(^/)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 09, 2025 Jan 09, 2025

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 10, 2025 Jan 10, 2025

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.pngCapture d’écran 2025-01-10 à 11.38.45.png

 

(^/)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 10, 2025 Jan 10, 2025

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 10, 2025 Jan 10, 2025

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.

 

(^/)

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 10, 2025 Jan 10, 2025

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
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[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.png

 

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.

 

(^/) 

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Guía ,
Jan 10, 2025 Jan 10, 2025
MÁS RECIENTES

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines