3 Replies Latest reply on Jul 5, 2011 10:32 AM by Jeremy bowmangraphics

    Autoflow XML

    brandonkboswell

      I recently created a script to import and populate an inDesign document with an XML structure, but have yet to find how to autoflow this via script. Is there an auto-flow function once the xml is placed?

       

      Thank you

        • 1. Re: Autoflow XML
          Harbs. Level 6

          Depending on how complex your needs are, you might find functions on the forum that meet your needs.

           

          I have customers using AutoFlow Pro for this purpose...

          http://in-tools.com/products/plugins/autoflow-pro/

           

          Harbs

          • 2. Re: Autoflow XML
            chapmanga Level 1

            Once the XML has been imported you can get InDesign to look for overflowed text and then add pages accordingly.

             

             

            //If text overflows generate pages with threaded frames to continue story
                 for (var pageCounter =indexDoc.pages.length; indexDoc.pages[-1].textFrames[0].overflows; pageCounter++)
                      {
                      //add new page     
                      indexDoc.pages.add()
                      //is page new page odd or even          
                      if(myCheckPageStart(indexDoc) == false)
                           {
                           myPageAdjust = 1;
                           }     
                      else
                           {
                           myPageAdjust = 0;
                           }
                      for(var myCounter = (indexDoc.pages[1].documentOffset-1); myCounter < indexDoc.pages[-1].documentOffset; myCounter++)
                      var myPage = indexDoc.pages.item(myCounter);
                      var myPageValue = myPage.documentOffset;
                      myPageValue = myPageValue + myPageAdjust;
                      if(myPageValue % 2 == 1)
                           {
                           //Page is an even page.
                           //Add left hand frame with columns                    
                           var indexFrameLeft=indexDoc.pages.item(pageCounter).textFrames.add();
                           indexFrameLeft.geometricBounds = myGeometricBoundsLeft;
                           indexFrameLeft.textFramePreferences.textColumnCount=myColumns;
                           indexFrameLeft.textFramePreferences.textColumnGutter=myGutter;
                           //Thread text frame back to previous page
                           var tf = indexDoc.pages[pageCounter].textFrames[0]
                           tf.previousTextFrame = indexDoc.pages[-2].textFrames[0];
                           }
                      else
                           {
                           //Page is an odd page.
                           //Add right hand frame with columns
                           var indexFrameRight=indexDoc.pages.item(pageCounter).textFrames.add();
                           indexFrameRight.geometricBounds = myGeometrisBoundsRight;
                           indexFrameRight.textFramePreferences.textColumnCount = myColumns;
                           indexFrameRight.textFramePreferences.textColumnGutter = myGutter
                           //Thread text frame back to previous page
                           var tf = indexDoc.pages[pageCounter].textFrames[0]
                           tf.previousTextFrame = indexDoc.pages[-2].textFrames[0];
                           }
                      }
            

             

            For your both your left and right hand pages you will have to define the geometric bounds of the text frame, the number of columns and the gutter. this should then build pages on until you run out of content.

             

            G

            • 3. Re: Autoflow XML
              Jeremy bowmangraphics Level 2

              Try something like this:

               

               

              myPage.placeXML(myXMLElement, [x, y], true);

               

               

              EDIT: Oh wait, you said "after it has been placed" -- sorry about that! Ignore the above.