Copiar vínculo al Portapapeles
Copiado
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.
/*
_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
...
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[
...
Copiar vínculo al Portapapeles
Copiado
There's no built-in way do that in InDesign. You (or someone else) might write a script.
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
Thanks for the quick script!
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
/*
_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! ..." )
(^/)
Copiar vínculo al Portapapeles
Copiado
Invincible is perfect.
Thanks a lot.
I actually never could understand "storyOffset and insertionPoints[-2]"
Copiar vínculo al Portapapeles
Copiado
It is an axiom in the understanding of The Force! 😉
(^/)
Copiar vínculo al Portapapeles
Copiado
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)
Copiar vínculo al Portapapeles
Copiado
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! ..." )
(^/)
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
Tests on your 2 docs. The Script does exactly what you ask: Find pages that contain tables!!!!!!!!
(^/)
Copiar vínculo al Portapapeles
Copiado
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
Copiar vínculo al Portapapeles
Copiado
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.
(^/)
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
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! ..." )
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.
(^/)
Copiar vínculo al Portapapeles
Copiado
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.
Encuentra más inspiración, eventos y recursos en la nueva comunidad de Adobe
Explorar ahora