Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

How to get the page number according to MarkerID?

New Here ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

I want to get the page number according to the marker element in fdk. I can get the marktext and markid,How to get the page number according to MarkerID in fdk?

TOPICS
Structured

Views

508
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

zhaopeng,

You need to first get the ID of the paragraph containing the marker (with FP_TextLoc), then get the top-level frame containing the FO_Pgf object (FP_InTextFrame), then get the page containing the FO_TextFrame object (FP_PageFramePage). Here is a function that you can send various objects to in order to get the page ID, including paragraphs (this courtesy of Rick Quatro, originally posted to the Yahoo Framedev list):

F_ObjHandleT GetPage(F_ObjHandleT oDoc, F_ObjHandleT oObj)
{
  F_ObjHandleT oFrame = 0;
  IntT iObjType;
  F_ObjHandleT oRow, oCell;

  while(oObj)
  {
    oFrame = oObj;
    iObjType = F_ApiGetObjectType(oDoc, oObj);

    switch(iObjType)

    {
      case FO_SubCol:
      oObj = F_ApiGetId(oDoc, oObj, FP_ParentTextFrame);
      break;

 
      case FO_Tbl:
      oRow = F_ApiGetId(oDoc, oObj, FP_FirstRowInTbl);
      oCell = F_ApiGetId(oDoc, oRow, FP_FirstCellInRow);
      oObj = oCell;
      break;

      case FO_Row:
      oCell = F_ApiGetId(oDoc, oObj, FP_FirstCellInRow);
      oObj = oCell;
      break;


      case FO_Cell:
      case FO_Pgf:
      case FO_AFrame:
      oObj = F_ApiGetId(oDoc, oObj, FP_InTextFrame);
      break;


      case FO_TextLine:
      case FO_TextFrame:
      case FO_UnanchoredFrame:
      case FO_Arc:
      case FO_Ellipse:
      case FO_Group:
      case FO_Inset:
      case FO_Line:
      case FO_Math:
      case FO_Polygon:
      case FO_Polyline:
      case FO_Rectangle:
      case FO_RoundRect:
      oObj = F_ApiGetId(oDoc, oObj, FP_FrameParent);
      break;


      //endless loop prevention, stops the process when the top-level frame is reached

      default:

      oObj = 0;
      break;
    }
  }

  //if we found the top-level frame, return its page ID, otherwise null

  if(oFrame)

  {
    return (F_ApiGetId(oDoc, oFrame, FP_PageFramePage));
  }
  else return(0);
}

...so, you would do something like this if you have the marker ID:

F_TextLocT textLoc;

F_ObjHandleT pageId;

...

textLoc = F_ApiGetId(docId, markerId, FP_TextLoc);

pageId = GetPage(docId, pageId.objId);

Note: I'm not sure how this handles the case where a paragraph extends across two pages and the marker is located on the second page. My thought is that it might erroneously return the page where the paragraph begins. I don't know how to handle that.

Russ

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

thank you very much.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Oct 12, 2010 Oct 12, 2010

Copy link to clipboard

Copied

LATEST

I just realized that one part should have been:

textLoc = F_ApiGetId(docId, markerId, FP_TextLoc);

pageId =  GetPage(docId, textLoc.objId);

...not pageId.objId.   You probably figured that out, though.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines