Copy link to clipboard
Copied
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
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; ...
// 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!!!" )
}
}
(^/)
Copy link to clipboard
Copied
Absolutely not clear! …
(^/) The Jedi
Copy link to clipboard
Copied
Look at my InDesign file.
When a table is set up with the Skip Page 1 Header feature, but the table does not span two pages (or two columns).
Problems will occur.
So to find these tables
Copy link to clipboard
Copied
What problems? Show us what you want to get (dupplicating the tables on the right page and correcting them to get the right result you want).
(^/)
Copy link to clipboard
Copied
To put it another way.
I'd like to find both 1 and 2 and cancel its “Skip header row on page 1”.
Delete the first row: the one with “cont” in it.
That mistake: Catalog duplication (gain)
I had found this bug and found the cause.
But there is no better solution.
Now I think it might be best to find these problematic tables and eliminate the “skip first page header rows”
Copy link to clipboard
Copied
Sorry, but your explanations are really hopeless! What's wrong here?
(^/)
Copy link to clipboard
Copied
To put it another way.
How to find out: a table does not span two columns. Or doesn't span two pages.
I need to correct the skipFirstHeader, set to
myTable.skipFirstHeader = false;
Robert at ID-Tasker said Horizontal Offset is not well understood.
Like this? Compare the first cell of the first row, with the first cell of the last row. It is entirely possible that they are the same.
Like this?
myTable.Rows[0].cell[0].yOffset == myTable.Rows[-1].cell[0].yOffset;
or
myTable.Rows[0].cell[0].xOffset == myTable.Rows[-1].cell[0].xOffset;
Copy link to clipboard
Copied
Sorry but your comment has really no sense, according to me but maybe I'm totally wrong!
You write:
"How to find out: a table does not span two columns. Or doesn't span two pages.
I need to correct the skipFirstHeader, set to
myTable.skipFirstHeader = false;"
In my sample, if a table does not span two columns or two pages, so just one column on a single page, the "masked" header [2-rows header beginning by "Contab"] will not be shown!
The "skipFirstHeader" table option remains "true"!
If the "skipFirstHeader" table option is "false", the "masked" header [2-rows header beginning by "Contab"] will be visible! What is definitely bad!
So, according to me, nothing has to be changed:
All The Tables have to include the "skipFirstHeader" table option as "true" and need to have a "false-header" first row!
If the layout moves after corrections, the "Contab" mention will appear or disappear, depending on the table configuration (one column on single page, two columns on single page or two text frames on single/two pages).
(^/)
Copy link to clipboard
Copied
To check if table spans multiple TextFrames / Pages - you need to check Parent Text Frame / Parent Page of the Text object of the cells.
For the Text Columns - you would've to check Horizontal Offset of the 1st Character / InsertionPoint.
Checking all cells isn't necessary - just cells in the first column would be enough.
Copy link to clipboard
Copied
You're pointing too shallowly.
I can't find my way.
Copy link to clipboard
Copied
Knowing very little.
I can't understand it, can you please show me a small example of the key code?
Thank you very much.
Copy link to clipboard
Copied
This isn't a bug, it's just how InDesign works.
What you're asking for is actually a new feature, and you can request new features through the InDesign Help menu, which will take you to the official site for feature suggestions.
Unfortunately, tables in InDesign are quite limited, so you'll often need to find workarounds to achieve what you want.
I’m not able to help with the scripting side, but like all software, InDesign has its limitations, and we all have to work within them.
It’s hard to fully understand what you’re trying to accomplish with these tables, but it sounds like a lot of what you’re doing would benefit from automation.
To be honest, there haven’t been many updates to how tables work in InDesign since the feature was introduced.
Your options are to either work within the current limitations and do a lot of manual adjustments, or collaborate with someone (whether paid or unpaidis between you) to create a script or plugin that meets your needs.
I also feel that a language barrier may be affecting clarity here, as the description of what you need isn’t entirely clear or detailed enough to fully understand.
Copy link to clipboard
Copied
hello everyone
Excuse me.
All else aside.
I'm most interested in knowing:
how to determine that a table is not spanning pages.
A table does not span two columns?
There should be no problem communicating this.
extremely grateful.
Copy link to clipboard
Copied
// 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] ) alert( "Table on 2 pages" )
else if ( myTable.storyOffset.textColumns[0] != myTable.storyOffset.paragraphs[0].insertionPoints[-1].textColumns[0] ) alert( "Table on 2 columns" )
else alert( "Table on 1 column" )
}
(^/)
Copy link to clipboard
Copied
Thank you very much FRIdNGE.
I may be able to read your paragraph of code now.
Yesterday I didn't understand what Robert at ID-Tasker said about Parent .
I just happened to see this below and kind of felt it, per my superficial thoughts:
The cells in the last row after the 1st cell, if they have the same parent text frame, are tables that don't span pages.
Copy link to clipboard
Copied
Neither of those judgments worked.
Table is for all tables in the current document.
Copy link to clipboard
Copied
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; i < tables.length; i++) {
var table = tables[i];
try {
// Get the first and last rows of the table
var firstRow = table.rows[0];
var lastRow = table.rows[table.rows.length - 1];
// Get the parent text frames of the first and last rows
var firstRowFrame = firstRow.cells[0].texts[0].parentTextFrames[0];
var lastRowFrame = lastRow.cells[0].texts[0].parentTextFrames[0];
// Check if the table spans multiple frames
if (firstRowFrame === lastRowFrame) {
// The table does NOT span multiple pages or columns
table.skipFirstHeader = false; // Disable "Skip Header Row on Page 1"
$.writeln("Table adjusted: " + table.id); // Log adjusted table IDs
}
} catch (e) {
$.writeln("Error processing table ID " + table.id + ": " + e.message);
}
}
alert("Script completed. Tables that didn't span pages/columns have been adjusted.");
Copy link to clipboard
Copied
Hi Eugene Tyson.
Thank you very much.
You guys have given me direction. I'll research and learn.
Copy link to clipboard
Copied
Hi Eugene Tyson.
This is changed to firstRowFrame ! = lastRowFrame
That's exactly what I want.
Though I didn't get why it was just the opposite of what I thought it was.
but, Everything Ok, except that it doesn't work properly when the form is not finished (overflow), this can be ignored.
Can you export the pages where the problem tables are located, I will check these tables.
Copy link to clipboard
Copied
I'd have to take a look into that one - I'm not entirely sure. And I won't have time this evening to look into it.
Copy link to clipboard
Copied
I didn't understand why (firstRowFrame == lastRowFrame)
Cannot find (The table does NOT span multiple pages or columns)
but on the contrary, (firstRowFrame ! = lastRowFrame) is correct.
In principle, the == is the key to determining that it does not span pages.
Where's the problem?
Copy link to clipboard
Copied
If a table doesn’t span multiple pages or columns, I thought it best to compare the parent text frames of the first row and the last row of the table.
If the first row and last row are in the same text frame (firstRowFrame === lastRowFrame), the table does NOT span pages or columns.
If they are in different text frames (firstRowFrame !== lastRowFrame), the table spans multiple pages or columns.
The key is using === to identify tables that stay within one frame and fixing those by setting skipFirstHeader = false.
=== asks if things are identical.
Copy link to clipboard
Copied
You'll get the same parent TextFrame - for different TextColumns in the same TextFrame.
Copy link to clipboard
Copied
Give me some of your good ideas, Robert at ID-Tasker
Copy link to clipboard
Copied
Give me some of your good ideas, God.
By @dublove
You need to be more specific - what ideas and to whom you are praying to 😉
Find more inspiration, events, and resources on the new Adobe Community
Explore Now