1 Reply Latest reply on Sep 12, 2017 7:23 PM by frameexpert

    How to display page number of graphic?

    varuns44789478 Level 1

      Is there a way to display the PageNumString (Page Number) of parent Anchor Frame of a Graphic?

        • 1. Re: How to display page number of graphic?
          frameexpert Level 4

          Here is a general-purpose function that will return the Page object of just about any object you pass to it:

           

          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 "Marker" :
                          obj = obj.TextLoc.obj;
                          break;
                      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