Copy link to clipboard
Copied
I am building an application that reports the page number of a given type of marker. This is normally quite simple as I just need to test for the TextLoc and resolve that to give the correct body page number.
It's not so easy if the marker is located in a paragraph that spans multiple pages. In that case the reported location is the start location of the containing paragraph and that could be several pages away from the actual marker location.
I understand that the offset of the marker location gives its true location, but how do we relate that to an actual page?
My initial attempt has been to compare the marker's TextLoc offset with the occurence of TextItems with dataType of Constants.FTI_PageBegin. Am I on the right track, or am I missing somthing really obvious?
I haven't posted any code yet because I wanted to discuss this at the conceptual level first.
Thanks
Ian
Hi Ian, it is possible and it is not as complicated as you might think. Basically, to reliably find the page location of anything like this, you need to find the page frame that contains it. That is, the highest-level frame on the page. You can reliably find the immediate parent frame of an object with its text location, then you can iterate up to the page frame, and then the page number is elementary.
Here is a basic function to do it, where doc and marker are the respective objects.
function re
...
Copy link to clipboard
Copied
I have no insights from a scripting perspective, but if generating a normal LoM for the document correctly presents the page number for the marker, then it should at least be possible.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hi Ian, it is possible and it is not as complicated as you might think. Basically, to reliably find the page location of anything like this, you need to find the page frame that contains it. That is, the highest-level frame on the page. You can reliably find the immediate parent frame of an object with its text location, then you can iterate up to the page frame, and then the page number is elementary.
Here is a basic function to do it, where doc and marker are the respective objects.
function reportMarkerPageNum(doc, marker)
{
var prop = doc.GetTextPropVal(marker.TextLoc, Constants.FP_InTextFrame);
var frame = prop.propVal.obj;
var pageFrame = null;
while(frame.ObjectValid())
{
pageFrame = frame;
frame = frame.FrameParent;
}
if(pageFrame)
{
var page = pageFrame.PageFramePage;
alert(page.PageNumString);
}
}
I hope this helps. I think this method is more logical than the approach you were taking. It will work whether the marker is in a basic text frame, table cell, anchored frame, or whatever. I think.
Russ
Copy link to clipboard
Copied