1 Reply Latest reply on Jun 2, 2011 9:22 AM by Kasyan Servetsky

    Overset text, autoflow?

    xmlapi Level 1

      Is there anyway to make overset text automatically flow to a new page (after the overset page) using a script that is fast?

        • 1. Re: Overset text, autoflow?
          Kasyan Servetsky Level 5

          Here, in my archive, I found a script written by Dave Saunders.

          //DESCRIPTION: Autoflow Overset Text 
          
            /* 
              ©Copyright 2006 PDS Associates 
               
              This script must not be distributed without first obtaining written permission of:  
               
              Dave Saunders, proprietor 
              PDS Associates 
              P.O. Box 127 
              Allenhurst, NJ 07711-0127 
               
              e-mail: davesaunders@pdsassoc.com 
            */ 
          
          // Note: this script does not use master text frames 
          
          if ((app.documents.length == 0) || (app.selection.length == 0)) { beep() } 
          
          aDoc = app.activeDocument; 
          aSel = app.selection[0]; 
          try { 
            aStory = aSel.parentStory; 
          } catch (e) {alert("Selection has no parent story.")}; 
          addReturn = false; 
          if (aStory.characters[-1].contents != "\r") { 
            addReturn = true; 
            aStory.insertionPoints[-1].contents = "\r"; 
          } 
          DumbRunPages(aDoc, aStory); 
          if (addReturn) {aStory.characters[-1].remove() } 
          selectIt(aStory.insertionPoints[-1]); 
          
          function DumbRunPages(theDoc, theStory) { 
            // What makes this "dumb" is that default master pages are used. 
            var uRuler = theDoc.viewPreferences.rulerOrigin; 
            theDoc.viewPreferences.rulerOrigin = RulerOrigin.spreadOrigin; 
            while (theStory.overflows) { 
              if (getVersion() < 5) { 
                var thePage = getPage(theStory.textFrames[-1]); 
              } else { 
                var thePage = getPage(theStory.textContainers[theStory.textContainers.length-1]); 
              } 
              var thePageName = thePage.name; 
              theDoc.documentPreferences.pagesPerDocument++; 
              var backPage = theDoc.pages[-1]; 
              app.activeWindow.activePage = backPage; 
              backPage.appliedMaster = thePage.appliedMaster; 
              var myPbounds = backPage.bounds; 
              var myNewTF = backPage.textFrames.add(); 
              if (backPage.side == PageSideOptions.leftHand) { 
                 myNewTF.geometricBounds =  
                   [myPbounds[0] + backPage.marginPreferences.top,  
                     myPbounds[1] + backPage.marginPreferences.right,  
                     myPbounds[2] - backPage.marginPreferences.bottom,  
                      myPbounds[3] - backPage.marginPreferences.left]; 
               } else { 
                 myNewTF.geometricBounds =  
                   [myPbounds[0] + backPage.marginPreferences.top,  
                     myPbounds[1] + backPage.marginPreferences.left,  
                     myPbounds[2] - backPage.marginPreferences.bottom,  
                      myPbounds[3] - backPage.marginPreferences.right]; 
               } 
              if (getVersion() < 5) { 
                myNewTF.itemLayer = theStory.textFrames[-1].itemLayer; 
                myNewTF.previousTextFrame = theStory.textFrames[-1]; 
              } else { 
                myNewTF.itemLayer = theStory.textContainers[theStory.textContainers.length-1].itemLayer; 
                myNewTF.previousTextFrame = theStory.textContainers[theStory.textContainers.length-1]; 
              } 
              myNewTF.textFramePreferences.textColumnCount = backPage.marginPreferences.columnCount; 
              myNewTF.textFramePreferences.textColumnGutter = backPage.marginPreferences.columnGutter; 
              if (myNewTF.insertionPoints.length == 0){ 
                theDoc.viewPreferences.rulerOrigin = uRuler; 
                throw ("Permanently overset"); // This indicates a permanent overset condition so break out of loop 
              } 
              if (theDoc.pages.item(thePageName) != theDoc.pages[-2]) { 
                // before moving the page, make sure that LayoutAdjust is on 
                var uLA = theDoc.layoutAdjustmentPreferences.enableLayoutAdjustment; 
                theDoc.layoutAdjustmentPreferences.enableLayoutAdjustment = true; 
                var newPage = theDoc.pages[-1].move(LocationOptions.after, theDoc.pages.item(thePageName)); 
                if (newPage.side != backPage.side) { 
                  var extraPage = newPage.duplicate(LocationOptions.before, newPage); 
                } else { 
                  var extraPage = newPage.duplicate(LocationOptions.after, newPage); 
                } 
                extraPage.remove(); 
                theDoc.layoutAdjustmentPreferences.enableLayoutAdjustment = uLA; 
              } 
            } 
            theDoc.viewPreferences.rulerOrigin = uRuler; 
          } 
          
          function getVersion() { 
            return Number(app.version.split(".")[0]); 
          } 
          
          function getPage(theObj) { 
            if (theObj.constructor.name == "Page") return theObj 
            if (theObj.constructor.name == "Application") { 
              alert("Story cannot be autoflowed"); exit(); 
            } 
            return getPage(theObj.parent) 
          } 
          
            function selectIt(theObj) { 
              var myZoom = app.activeWindow.zoomPercentage; 
              app.select(theObj); 
              app.activeWindow.zoom(ZoomOptions.fitPage); 
              app.activeWindow.zoomPercentage = myZoom; 
            }