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

Use scripts, How to find out tables that it doesn't span 2 pages (or 2 columns) .

Guide ,
Jan 03, 2025 Jan 03, 2025

If a table uses "Skip Header Row on Page 1" feature,

but the table only takes up 1 page (or 1 column), It will lead to duplication in the table of contents.
Waiting for an official fix for this bug may be too long.
Is there a script to find these tables and then unskip the page 1 header rows?

Initially it may have been correctly needed.

They didn't take up 2 pages (2 columns) later because the layout moved.
But you don't know which ones made the setting

 

-2.jpg

TOPICS
Bug , Feature request , How to , Performance , Scripting
3.2K
Translate
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

Community Expert , Jan 04, 2025 Jan 04, 2025

Alright - maybe something like this

Before running the script on a large or important document, test it on a smaller sample file to ensure it works as expected. Save a backup of your document as a precaution.

 

This is just and idea, maybe it does what you want and maybe not, but hopefully it can be refined or used as foundation going forward.

 

// Loop through all tables in the active document
var tables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
for (var i = 0; 
...
Translate
Guide , Jan 06, 2025 Jan 06, 2025
// Loop through all tables in the active document
var myTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t];
    if ( myTable.storyOffset.textColumns[0] != myTable.storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0] ) {
        myTable.select();
        alert( "Do Something! ... What? No idea!!!" )
    }
}

 

(^/)

Translate
Guide ,
Jan 05, 2025 Jan 05, 2025

Now it's right within two pages.
If the table spans more than 3 pages, it is incorrect

Translate
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 05, 2025 Jan 05, 2025

I've uploaded a new, clearer sample file
There are just have multiple cases.


There are tables that span multiple pages and tables that span two columns.
There are tables that originally span pages and then don't.


Those that originally had skipFirstHeader set, and then didn't span pages, resulting in duplicate items when extracting the catalog.

Translate
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
LEGEND ,
Jan 05, 2025 Jan 05, 2025

@Eugene Tyson

 

And you won't get parentTextFrame for empty / completely overset Cells.

 

Translate
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 05, 2025 Jan 05, 2025

Yeh I can't figure that out.

Translate
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
LEGEND ,
Jan 05, 2025 Jan 05, 2025
quote

Yeh I can't figure that out.


By @Eugene Tyson

 

Figure out what? There is ALWAYS a way to skin a cat 😉 

 

Please quote message you're replying to - this forum is a mess. 

 

Translate
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 05, 2025 Jan 05, 2025

Although I haven't thought about it. Why change it to "! = "can be recognized?

I'd like to settle for that.
But then I realized that when spanning multiple pages, I would delete the first row by mistake.

I've updated the sample again (Skip A1 A2 B1 B2--B3.IDML)

Translate
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 06, 2025 Jan 06, 2025

My guess is that the correct parentage was not found.
Right now it's right up to two pages, but wrong over 3 pages.

Translate
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 06, 2025 Jan 06, 2025

Capture d’écran 2025-01-06 à 15.23.44.png

 

// Place The Cursor Inside A Table Cell:
if ( app.selection[0].parent.constructor.name != "Cell" ) {
    alert( "Place The Cursor Inside A Table Cell! ..." )
    exit();
} else {
    var myTable = app.selection[0].parent.parent;
    if ( myTable.storyOffset.parentTextFrames[0] != myTable.storyOffset.paragraphs[0].insertionPoints[-1].parentTextFrames[0] ) {
        if ( myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.paragraphs[0].insertionPoints[-1].parentTextFrames[0].parentPage ) alert( "1a/ Table on 2 text frames and 1 page" )
        else alert( "1b/ Table on " + Number( (myTable.storyOffset.paragraphs[0].insertionPoints[-1].parentTextFrames[0].parentPage.documentOffset - myTable.storyOffset.parentTextFrames[0].parentPage.documentOffset) + 1) + " pages" )
    } else if ( myTable.storyOffset.textColumns[0] != myTable.storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0] && myTable.storyOffset.parentTextFrames[0].parentPage === myTable.storyOffset.paragraphs[0].insertionPoints[-1].parentTextFrames[0].parentPage ) alert( "2/ Table on 2 columns and 1 page" )
    else alert( "3/ Table on 1 column on 1 page" )
}

 

(^/)

Translate
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
LEGEND ,
Jan 06, 2025 Jan 06, 2025

@FRIdNGE

 

You are making a lot of assumptions - what if there are multiple TFs on the same page? What if there are "empty" pages in the middle of the spanned Table? What if Table is in three text column TextFrame? etc. 

 

Translate
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 06, 2025 Jan 06, 2025

More compact:

 

// Place The Cursor Inside A Table Cell:
if ( app.selection[0].parent.constructor.name != "Cell" ) {
    alert( "Place The Cursor Inside A Table Cell! ..." )
    exit();
} else {
    var myTable = app.selection[0].parent.parent;
    if ( myTable.storyOffset.textColumns[0] === myTable.storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0] ) alert( "Good! Table on 1 column on 1 page" )
    else alert( "Bad! All the other cases ..." )
}

 

(^/)

Translate
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 06, 2025 Jan 06, 2025

Place The Cursor Inside A Table Cell?

Targets all tables in the entire document, not selecting a particular table. It is traversing all tables.

Translate
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 06, 2025 Jan 06, 2025
// Loop through all tables in the active document
var myTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t];
    if ( myTable.storyOffset.textColumns[0] != myTable.storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0] ) {
        myTable.select();
        alert( "Do Something! ... What? No idea!!!" )
    }
}

 

(^/)

Translate
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 06, 2025 Jan 06, 2025

Hi FRIdNGE,,

Thank you very much.

That should do it. I tried it last night.
Just not var T = myTables.length, t;
for ( t = 0; t < T; t++ ) {
var myTable = myTables[t];
This paragraph.
What does myTables.length mean?
The number of all tables? It can also be expressed like this ......

Translate
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
LEGEND ,
Jan 06, 2025 Jan 06, 2025
quote

.

What does myTables.length mean?
The number of all tables? 


By @dublove

 

Yes. 

 

Translate
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 06, 2025 Jan 06, 2025

No problems found except that it doesn't work when it contains overflow text
No other problems were found.

Only 1 column or 1 page. But there is an overflow

 

==    corresponds myTable.skipFirstHeader = false;
or 
!=    corresponds myTable.skipFirstHeader = true;

 

All failing.

----------------------Below is the code for the test--------------------

 

// Loop through all tables in the active document
var myTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
var T = myTables.length,  t;
for ( t = 0; t < T; t++ ) {
    var myTable = myTables[t];
    if ( myTable.storyOffset.textColumns[0]== myTable.storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0] ) {
        //myTable.select();
		myTable.skipFirstHeader = false; 
        //alert( "Do Something! ... What? No idea!!!" )
    }
}

 

overflow text.jpg

Translate
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
LEGEND ,
Jan 06, 2025 Jan 06, 2025

Because in case of overflow text - main text, the Table is in - last InsertionPoint is in overset - so doesn't have parentTextFrames nor TextColumns.

 

Translate
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 06, 2025 Jan 06, 2025

Always the same question:

 

Why do you want to change the "skipFirstHeader" option as "false" to these 2 tables?

 

(^/)

Translate
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 06, 2025 Jan 06, 2025

Hi FRIdNGE

As I said before.
At the beginning of the layout, there are some table span pages (or  columns), so set “skipFirstHeader = true”
But then, because of content changes, some tables didn't span pages (or columns). You have to change these tables to “skipFirstHeader = false”.

Otherwise, the catalog (contents) you extracted, will have duplicate items.

This is a big bug.

https://community.adobe.com/t5/indesign-discussions/great-people-please-come-and-study-how-to-avoid-...

Translate
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
LEGEND ,
Jan 06, 2025 Jan 06, 2025
quote

Otherwise, the catalog (contents) you extracted, will have duplicate items.

This is a big bug.


By @dublove

 

No, it's not, it's just your specific layout / design. 

 

Translate
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 06, 2025 Jan 06, 2025

Duplicate entries occur in the extraction catalog.
This is not a problem I've run into alone.
A lot of people have run into it and gotten yelled at by their customers.

I have studied it over a long period of time.
It was found to be caused by skipping the table header on page 1.

 

I never want to write a script for a trope.
My requests are universally applicable to most operations.

Translate
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
LEGEND ,
Jan 06, 2025 Jan 06, 2025

@dublove

 

You HAVE to change your approach to working in InDesign.

 

First, before you start automating things - make sure that there are no oversets - either visually or by using preflight - or with a script.

 

ONLY THEN you can successfully run scripts. 

 

Then, as I've pointed out already - remove "extra" rows added by earlier script or 1st run of the same script - before you run additional scripts that would be affected by those "extra" rows - or columns, whatever. 

 

Because, right now, you're repeating the same "problem" over and over again - providing us with broken examples. 

 

Translate
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 06, 2025 Jan 06, 2025

Yes, I'm changing.
I'm always uncomfortable inside when a problem isn't solved.

Translate
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 07, 2025 Jan 07, 2025
LATEST

Hi FRIdNGE

How do I output the page number where the above condition occurs?
Output all page numbers at once.
I want to check one page at a time.

 

Thank you very much.

Translate
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
LEGEND ,
Jan 06, 2025 Jan 06, 2025

@dublove

 

Let's reset everything - because, I think, we went into a rabbit hole - are you doing your documents for print or for ePUB / accessibility - or both?

 

Because, I'm pretty sure there is / are much easier way(s) to solve your "problems" - and you're "trying too hard" to accomplish everything at once. 

 

Translate
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 06, 2025 Jan 06, 2025
quote

Because, I'm pretty sure there is / are much easier way(s) to solve your "problems" - and you're "trying too hard" to accomplish everything at once. 

By @Robert at ID-Tasker

I also think you're way better off. Well hope you can share.

I've been waiting for you 10,000 years.

 

It is usually used for printing.
Interactive output is only used for proofreading. It can be disregarded.

 

Translate
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