Skip to main content
Known Participant
February 20, 2023
Answered

Overset textframe issue

  • February 20, 2023
  • 2 replies
  • 662 views

Hi,

Occasionally, the overset feature does not work. If the text frame gets overset on the 3rd page, then the overset page won't be split.

In the attachment, you will find a script for splitting tables. Could you please guide me on this?

 

IterateDocument();

function IterateDocument()
{
// Get the active document
var doc = app.activeDocument;
// Loop through all pages of the document
for (var i = 0; i < doc.pages.length; i++) {
  var page = doc.pages[i];
  var pageHeight = page.bounds[2] - page.bounds[0];
  // Loop through all text frames on the page
  for (var j = 0; j < page.textFrames.length; j++) {
    var frame = page.textFrames[j];
            for(var k=frame.tables.length-1; k>=0; k--)
        {          
     var table = frame.tables[k];
    // Log the height of the text frame in the JavaScript console
    var height = frame.geometricBounds[2] - frame.geometricBounds[0];
    if(pageHeight < height)
    {
    AddColumnToTable(frame, i,table);
    }
} // Get Table length
  } // get Text Framelength
} //Get total page count
}
function AddColumnToTable (mySel,addPageLocation, originalTable)
{
        var gb = mySel.geometricBounds;
       gb[2] = gb[0] + originalTable.height/2;
          gb= [95.891, 37.5, 730.458, 576];
       mySel.geometricBounds = gb;
   var newFrame = app.activeDocument.pages.add(LocationOptions.AFTER, app.activeDocument.pages[addPageLocation]);
    var textframe = app.activeDocument.pages[addPageLocation+1].textFrames.add({
        	geometricBounds:[95.891, 37.5, 730.458, 576] 
            });
          mySel.nextTextFrame = textframe ;
           textframe.fit(FitOptions.frameToContent);
  if(textframe.overflows  == true)
{
        AddColumnToTable (mySel,addPageLocation,originalTable);
}
}

 

 

This topic has been closed for replies.
Correct answer Laubender

Hi @Barathi ,

splitting the table is actually working.

At least there are three main text streams in your result document.

With one table in each of the text streams.

 

What happens is that the start of the second text stream, threaded text frames, is on the same page where the first one ends. So the last text frame of the first stream is stacked below the first text frame of the second stream.

 

Also:

The start text frame of the third text stream is stacked at the same position of the second text frame of the third text stream.

 

What your script is doing wrong:

In that facing-pages document only the first page of every spread is used for positioning the text frames.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

2 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
February 24, 2023

Hi @Barathi ,

splitting the table is actually working.

At least there are three main text streams in your result document.

With one table in each of the text streams.

 

What happens is that the start of the second text stream, threaded text frames, is on the same page where the first one ends. So the last text frame of the first stream is stacked below the first text frame of the second stream.

 

Also:

The start text frame of the third text stream is stacked at the same position of the second text frame of the third text stream.

 

What your script is doing wrong:

In that facing-pages document only the first page of every spread is used for positioning the text frames.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

m1b
Community Expert
Community Expert
February 20, 2023

Hi @Barathi, are you able to explain very specifically what your problem is? I don't understand. Can you show screenshot before and after fixing the problem? Perhaps post a sample doc showing problem in a simple way?

- Mark

BarathiAuthor
Known Participant
February 21, 2023

Hi @m1b 

I have tried by using below mentioned script and able to generate the partical output (refer to the Output Document.indd). But I need to get the document which I have attached in the "Expected Output Document.indd

IterateDocument();
var addPageLocation = 0; 
function IterateDocument()
{
// Get the active document
var doc = app.activeDocument;
// Loop through all pages of the document
for (var i = 0; i < doc.pages.length; i++) {
  var page = doc.pages[i];
  var pageHeight = page.bounds[2] - page.bounds[0];
  // Loop through all text frames on the page
  for (var j = 0; j < page.textFrames.length; j++) {

    var frame = page.textFrames[j];
            for(var k=frame.tables.length-1; k>=0; k--)
        {
          
     var table = frame.tables[k];
    // Log the height of the text frame in the JavaScript console
    var height = frame.geometricBounds[2] - frame.geometricBounds[0];
    if(pageHeight < height)
    {
    AddColumnToTable(frame, i,table);
    }
} // Get Table length
  } // get Text Framelength
} //Get total page count
}
   function AddColumnToTable (mySel,addPageLocation, originalTable)
{
        var gb = mySel.geometricBounds;
       gb[2] = gb[0] + originalTable.height/2;
       gb= [95.891, 37.5, 730.458, 576];
       mySel.geometricBounds = gb;
   var newFrame = app.activeDocument.pages.add(LocationOptions.AFTER, app.activeDocument.pages[addPageLocation]);
    var textframe = app.activeDocument.pages[addPageLocation+1].textFrames.add({
        	geometricBounds:[95.891, 37.5, 730.458, 576] 
            });
          mySel.nextTextFrame = textframe ;
          textframe.fit(FitOptions.frameToContent);
  if(textframe.overflows  == true)
{
addPageLocation = addPageLocation +1;
 AddColumnToTable (textframe,addPageLocation,originalTable);

}
}

"