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

filter to body pages

New Here ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

I need to filter only bodypage within this iterator below

anyone know an easy way to do this?

thanks

var doc= app.ActiveDoc;

iterate(doc)

function iterate(doc)

{

        var pgf = doc.FirstPgfInDoc;

       while (pgf.ObjectValid())

    {

/*

     if(bodypage)   

     {

     //do something

     }

*/

        pgf = pgf.NextPgfInDoc;//NextPgfInFlow

}

}

TOPICS
Scripting

Views

1.2K

Translate

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
Engaged ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

Hi,

one possible way is this.

If you want to check all flows, you have to iterate them all and check if they are on a body page.

For this you have to get the TextFrame and the unanchored frame from that.

This unanchored frame delivers the page and you can check if it's a body page.

if you've found the body page, you can get next pages.

var flow = app.ActiveDoc.FirstFlowInDoc;

while (flow.ObjectValid())

{

     var textFrame = flow.FirstTextFrameInFlow;

     var unanchoredFrame = textFrame.FrameParent;

     var page = unanchoredFrame.PageFramePage ;

     if (page.Type != Constants.BodyPage)

     {

          flow = flow.NextFlowInDoc;

          continue ;

     }

     while(page.ObjectValid())

     {

          //Iterate all BodyPages and do you actions here

          page = page.PageNext ;

     }

     flow = flow.NextFlowInDoc;

}

if you only want to check main flow, you can leave first loop, get MainFlowInDoc from active doc.

If start position is a paragraph you can get textFrame, from that paragraph:

var textFrame = pgf.InTextFrame;

from here its the same than above.

In both way it's possible getting same body page more than once. So you have to check if it's allready processed.

Code isn't testet, so I hope all works for you.

Markus

 

Votes

Translate

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 ,
Sep 14, 2012 Sep 14, 2012

Copy link to clipboard

Copied

thank you so much, I will give this a shot

thank you!

Votes

Translate

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
Community Expert ,
Sep 15, 2012 Sep 15, 2012

Copy link to clipboard

Copied

Here is a general purpose function that will get the page object of any other FrameMaker object:

function getPage (obj) {

    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.TopRowSelection.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;

    }

}

So, where you have this:

/*

     if(bodypage)  

     {

     //do something

     }

*/

you can use this:

if ((getPage(pgf)) && (getPage(pgf).constructor.name === "BodyPage")) {

     // do something here.

}

Please let me know if you have any questions or comments.

Rick

Votes

Translate

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
Participant ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

Hi, I have the following function which seems to be like yours but I can't make it work for tables!

IntT GetPageType (F_ObjHandleT docId, F_ObjHandleT objectId)

{

  F_ObjHandleT oldParentId;

  F_ObjHandleT parentId = objectId;

  IntT parentType = FO_TextFrame;

  while (parentType != FO_BodyPage &&

    parentType != FO_MasterPage &&

    parentType != FO_RefPage &&

    parentType != FO_HiddenPage)

  {

    oldParentId = parentId;

    parentId = F_ApiGetId(docId, parentId, FP_FrameParent);

    if (!parentId)

    {

      parentId = F_ApiGetId(docId, oldParentId, FP_PageFramePage);

      if (!parentId)

      {

        break;

      }

    }

    parentType = F_ApiGetObjectType(docId, parentId);

  }

  return parentType;

}

Can you help me?

Votes

Translate

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 ,
May 12, 2016 May 12, 2016

Copy link to clipboard

Copied

LATEST

Hi Ch, please avoid reviving these old threads for loosely-related followup questions. I realize you are just looking for help, but it makes it difficult to keep things organized for readers and contributors alike. Please refer to your current post for this issue:

How to filter tables from body pages only?

Russ

Votes

Translate

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