Copy link to clipboard
Copied
Is there a way to display the PageNumString (Page Number) of parent Anchor Frame of a Graphic?
Copy link to clipboard
Copied
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;
}
}