0 Replies Latest reply on Jul 13, 2010 12:59 AM by sandy_88

    Autoflow Problem

    sandy_88 Level 1

      Hi Everyone,

       

      I have a problem with the below script, the script created for autoflow the word document, but when running the script, the verso page (right page) is not flowing correctly i.e., the verso textframes are not placed correctly in the Text Margin.

       

      Please check and do the needful.

       

      var noDoc="Please Open the Indesign Template or File and Run the Script";
      var noframes="There is no Text frame to flow";
      if(app.documents.length == 0)
      {
      alert (noDoc);
      }
      else
      {
      var myDoc = app.activeDocument;
      //Create a text frame on page 1.
      var myTextFrame = myDoc.pages.item(0).textFrames.add();
      var myWord=File.openDialog("Select the word file to Import");
      myTextFrame.place(File(myWord));
      //Set the bounds of the text frame.
      myTextFrame.geometricBounds = myGetBounds(myDoc, myDoc.pages.item(0));
      //create the frame and set its bounds and place the wordfile:
      function myGetBounds(myDoc, myPage){
      var myPageWidth = myDoc.documentPreferences.pageWidth;
      var myPageHeight = myDoc.documentPreferences.pageHeight
      if(myPage.side == PageSideOptions.leftHand){
      var myX2 = myPage.marginPreferences.left;
      var myX1 = myPage.marginPreferences.right;
      }
      else{
      var myX1 = myPage.marginPreferences.left;
      var myX2 = myPage.marginPreferences.right;
      }
      var myY1 = myPage.marginPreferences.top;
      var myX2 = myPageWidth - myX2;
      var myY2 = myPageHeight - myPage.marginPreferences.bottom;
      return [myY1, myX1, myY2, myX2];
      }

       

      //finding the overflow text and make it autoflow
      if (app.activeDocument.textFrames.length < 1) {alert(noframes);}
      else{
      for(var i = 0; i < app.activeDocument.pages.count(); i++)
         {
        for(var b = 0; b < app.activeDocument.pages[i].textFrames.count(); b++)
        {
          if(app.activeDocument.pages[i].textFrames[b].overflows == true)
           {
          np = myDoc.pages.add();
          marg = np.marginPreferences;
          gb = [marg.top, marg.left,
           myDoc.documentPreferences.pageHeight - marg.bottom,
           myDoc.documentPreferences.pageWidth - marg.right];
             
          oldRuler = myDoc.viewPreferences.rulerOrigin;
         
          myDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

          with (myDoc.pages[-1].textFrames.add())
          {
           geometricBounds = gb;
           previousTextFrame = myDoc.pages[-2].textFrames[0];
          }
          myDoc.viewPreferences.rulerOrigin = oldRuler;
            }
          }
         }
      alert ("Processed");
      }
      }