5 Replies Latest reply on Feb 9, 2016 6:58 PM by Arnis Gubins

    FM Script to find the pagenumber of a paragraph

    Lohith Kumar

      I am working on a frame maker script and flowing from first Pgf to the last Pgf in search of selected PgfFmt. When I found the required PgfFmt I need to list the page number in which page the Pgf is present. Using Scripting I can able to find the PgfFmt but I cant able to find the actual page in which it exist.

      Thanks & Regards,

      Lohithkumar

        • 1. Re: FM Script to find the pagenumber of a paragraph
          frameexpert Level 4

          Here is a function that I use to find the page of a particular object. This was adapted from an old FDK example. FrameScript has a shortcut Page property on most objects, but in ExtendScript and the FDK you have to use something like this:

           

          function getPage (obj) {
              
              // Gets the page object that contains the object passed in.
              
              var frame = 0, cell = 0;
              var objType = "";
              
              while (obj) {
                  
                  frame = obj;
                  objType = obj.constructor.name;
                  
                  switch (objType) {
                      case "SubCol" :
                          obj = obj.ParentTextFrame;
                          break;
                      case "Tbl" :
                          obj = obj.FirstRowInTbl.FirstCellInRow;
                          break;
                      case "Row" :
                          obj = obj.FirstCellInRow;
                          break;
                      case "Cell" :
                      case "Pgf" :
                      case "AFrame" :
                          obj = obj.InTextFrame;
                          break;
                      case "TextLine" :
                      case "TextFrame" :
                      case "UnanchoredFrame" :
                      case "Arc" :
                      case "Ellipse" :
                      case "Group" :
                      case "Inset" :
                      case "Line" :
                      case "Math" :
                      case "Polygon" :
                      case "Polyline" :
                      case "Rectangle" :
                      case "RoundRect" :
                          if (obj.FrameParent.ObjectValid()) {
                              obj = obj.FrameParent;
                          } else {
                              obj = 0;
                          }
                          break;
                      default:
                          // Prevent endless loop if unknown object type is found.
                          obj = 0;
                          break;
                  }
              }
              if (frame) {
                  return frame.PageFramePage;
              } else {
                  return 0;
              }
          }
          
          1 person found this helpful
          • 2. Re: FM Script to find the pagenumber of a paragraph
            Lohith Kumar Level 1

            Hi, the code is working fine

            Thank You

            • 3. Re: FM Script to find the pagenumber of a paragraph
              frameexpert Level 4

              Please mark the answer as Correct. Thank you.

              • 4. Re: FM Script to find the pagenumber of a paragraph
                Lohith Kumar Level 1

                Hi, I do not find any option to mark the answer as correct. I can find 4 options under the answer, Actions, Like, Reply, Translate. In Actions link, I can see only Report Abuse.

                Please tell me how to set the answer as correct.

                 

                Thanks & Regards,

                Lohithkumar

                • 5. Re: FM Script to find the pagenumber of a paragraph
                  Arnis Gubins Adobe Community Professional & MVP

                  Unfortunately, this thread wasn't started as a question and Rick's response has already been marked as "Helpful". At this point, it can no longer be changed to a question and marked with a correct answer