5 Replies Latest reply: Jul 7, 2011 9:08 AM by xmlapi RSS

    Smart text flow doesn't work in scripting

    xmlapi Community Member

      This is getting to be really frusting. I have enabled smart text flow, it only works if I open the app and modify a textframe. It never works when I run it through a script????? How do I activate this stupid feature using a script?

        • 1. Re: Smart text flow doesn't work in scripting
          2i_Geert Community Member

          Hi,

           

          This works (for me):

           

          var document = app.activeDocument;
          var textFrame = document.textFrames.add();
          var page = document.pages.add();
          var nextTextFrame = page.textFrames.add();

           

          document.textPreferences.smartTextReflow = true;
          document.textPreferences.limitToMasterTextFrames = false;
          document.textPreferences.deleteEmptyPages = true;
          document.textPreferences.addPages = AddPageOptions.END_OF_DOCUMENT;

           

          textFrame.geometricBounds = [10, 10, 280, 200];
          nextTextFrame.geometricBounds = [10, 10, 280, 200];
          nextTextFrame.previousTextFrame = textFrame;

           

          for(var index = 0; index < 100; index++)
          {
              textFrame.contents += "Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World Hello InDesign World ";
          }

          • 2. Re: Smart text flow doesn't work in scripting
            pkahrel Community Member

            Why do you want to activate it if it's so stupid?

             

            Peter

            • 3. Re: Smart text flow doesn't work in scripting
              xmlapi Community Member

              I adjusted the script above to this to show you that it doesn't work (the deleting part of smart text reflow does not work cause it's delayed)

               

              var document =app.documents.add();

               

              document.textPreferences.smartTextReflow = true;
              document.textPreferences.limitToMasterTextFrames = false;
              document.textPreferences.deleteEmptyPages = true;
              document.textPreferences.addPages = AddPageOptions.END_OF_DOCUMENT;

               

              for(var index = 0; index < 10; index++)
              {
                  var page = document.pages.add();
              var page2 = document.pages.add();
              var textFrame = page.textFrames.add();

               

              var nextTextFrame = page2.textFrames.add();

               

              textFrame.geometricBounds = [10, 10, 40,  40];
              nextTextFrame.geometricBounds = [10, 10,  40,  40];
              nextTextFrame.previousTextFrame = textFrame;

               

              textFrame.contents = "asdasD";
              textFrame.recompose();
              }

               

              Run the script above and you'll see the delete part does not work. It will have empty pages that should be deleted. These empty pages will ONLY be deleted when Indesign is idle OR you manually resize the text frame in the indesign app (not script).

               

              Is this a bug?

              • 4. Re: Smart text flow doesn't work in scripting
                2i_Geert Community Member

                I think you're missing the point. You should not add pages in the loop. The smart text reflow does the adding for you (when there is text overflow).

                • 5. Re: Smart text flow doesn't work in scripting
                  xmlapi Community Member

                  Smart text reflow ONLY (per textframe) IF at least 2 text frames are threaded together (documentation). I'm adding the second page and a textframe and then linking this textframe to the first page textframe (so smart text flow will work). Each page will have an extra page associated with it so that smart text reflow works (basically, the additional page works as a placeholder....for overset text). If there is no overset text on a particular "even" ("first") page, then smart text reflow should automatically delete the extra page associated with it (the placeholder page). It will ONLY do this randomly/when indesign is idle. If you manually force it by using quick apply > recompose all stories immediately, it works immediately. Using textframe.recompose or document.recompose DOES NOT fix this problem. I noticed that the more the document had pages, the more time it took smart text reflow to trigger (unless you use the quick apply method).

                   

                  This issue is in the Desktop, I don't know if Server has the same issue (can someone with server try smart text reflow and see if it deletes the pages? try using the recompose method on the server as well).