Skip to main content
dublove
Legend
Mar 26, 2014 5:53 PM UTC
Question

Is there a script that it can make Overflow text automatically routed Next?(Not the main text frame)

Is there a script that it can make Overflow text automatically routed Next?(Not the main text frame)

when I run the scrip,Overflow text can auto Typesetting to the next page?

thankS Supreme~

6 replies

Inspiring
Apr 7, 2014 2:45 PM UTC

Here's the script I use. Notice the complications getting the live area when other than rulers per spread is employed. The script automatically selects the final selection point in the story and moves to that page in the active window.

//DESCRIPTION: Autoflow selected overset story

(function(){

          if (app.documents.length > 0

                              && app.selection.length == 1

                              && app.selection[0].hasOwnProperty("parentStory")

                              && app.selection[0].parentStory.overflows) {

                    app.doScript(fixOverset, undefined, app.selection[0].parentStory, UndoModes.entireScript, "Fix Overset");

          } else {

                    alert("There must be a selection that identifies the overset story.");

          }

          function fixOverset(story) {

                    while (story.overflows) {

                              var aDoc = story.parent;

                              var lastTF = story.textContainers.pop();

                              var lastPage = lastTF.parentPage;

                              if (lastPage instanceof Page == false) {

                                        alert("Story ends on pasteboard; no action taken.");

                                        return;

                              }

                              var master = lastPage.appliedMaster;

                              var newPage = aDoc.pages.add(LocationOptions.after, lastPage);

                              newPage.appliedMaster = master; // may not be necessary

                              var liveArea = getLiveBounds(newPage);

                              var newTF = newPage.textFrames.add({geometricBounds : liveArea, layer : lastTF.itemLayer});

                              newTF.previousTextFrame = lastTF;

                              if (newTF.insertionPoints.length == 0

                                                  && lastTF.insertionPoints.length == 0) {

                                        // allows for paragraph style with startParagraph on specific page side

                                        alert("Story is permanently overset.");

                                        return;

                              }

                    }

                    selectIt(story.insertionPoints[-1]);

          }

          function getLiveBounds(page) {

                    var rO = page.parent.parent.viewPreferences.rulerOrigin;

                    var bounds = page.bounds;

                    if (rO == RulerOrigin.spreadOrigin) return returnBounds(page, bounds);

                    var width = bounds[3] - bounds[1];

                    if (rO == RulerOrigin.spineOrigin &&

                                        (page.side == PageSideOptions.leftHand ||

                                                  (page.side == PageSideOptions.rightHand &&

                                                            page.parent.pages.length > 1)) ||

                              (rO == RulerOrigin.pageOrigin &&

                                        page.side == PageSideOptions.rightHand &&

                                                  page.parent.pages.length > 1)) {

                                        bounds[1] = bounds[1] - width;

                                        bounds[3] = bounds[3] - width;

                    }

                    return returnBounds(page, bounds);

                    function returnBounds(page, bounds) {

                              return [

                                        page.marginPreferences.top,

                                        page.side == PageSideOptions.leftHand ?

                                                  bounds[1] + page.marginPreferences.right :

                                                  bounds[1] + page.marginPreferences.left,

                                        bounds[2] - page.marginPreferences.bottom,

                                        page.side == PageSideOptions.leftHand ?

                                                  bounds[3] - page.marginPreferences.left :

                                                  bounds[3] - page.marginPreferences.right

                              ] ;

                    }

          }

           function selectIt(theObj) {

                    var myZoom = app.activeWindow.zoomPercentage;

                    app.select(theObj);

                    app.activeWindow.zoom(ZoomOptions.fitPage);

                    app.activeWindow.zoomPercentage = myZoom;

           }

}())

Translate
dublove
dubloveAuthor
Legend
Apr 8, 2014 3:07 PM UTC

Hi Dave Saunders~

Thank you very much

Why are you so amazing~ very very great

It is very good,only, If there has been a blank page,Do not add a blank page

Translate
Luis_Fernando_Brito
Participating Frequently
Mar 28, 2014 8:59 PM UTC

The code below checks the frames with excess per page and the id of the frame.

var myDoc = app.documents[0];

var myPages = myDoc.pages;

for (var i = 0; i < myPages.length; i++) {

    var myPage = myDoc.pages.item(i) ;

    var myFrame= myPage.textFrames;

    for (var m = 0; m < myFrame.length; m++) {

        if ( myFrame.item(m).overflows ) {

            alert("Overflow TextFrame ID: " + myFrame.item(m).id + "\npage: " + myPage.name );

        }   

    };

};

Translate
dublove
dubloveAuthor
Legend
Mar 29, 2014 4:10 PM UTC

Hi  Luis Fernando Brito,thank you for Positiving reply.

But this is not my I I need,It  Should be able to Typesetting to the next page

Translate
Stefan Rakete
Inspiring
Apr 7, 2014 9:59 AM UTC

Have you looked into the feature "Smart Text Reflow" in the preferences panel ?

Thanks Stefan

Translate