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

FM Script to find the pagenumber of a paragraph

New Here ,
Feb 07, 2016 Feb 07, 2016

Copy link to clipboard

Copied

I am working on a frame maker script and flowing from first Pgf to the last Pgf in search of selected PgfFmt. When I found the required PgfFmt I need to list the page number in which page the Pgf is present. Using Scripting I can able to find the PgfFmt but I cant able to find the actual page in which it exist.

Thanks & Regards,

Lohithkumar

TOPICS
Scripting

Views

787
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 ,
Feb 08, 2016 Feb 08, 2016

Copy link to clipboard

Copied

Here is a function that I use to find the page of a particular object. This was adapted from an old FDK example. FrameScript has a shortcut Page property on most objects, but in ExtendScript and the FDK you have to use something like this:

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 "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;

    }

}

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 ,
Feb 08, 2016 Feb 08, 2016

Copy link to clipboard

Copied

Hi, the code is working fine

Thank You

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
Community Expert ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

Please mark the answer as Correct. Thank you.

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 ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

Hi, I do not find any option to mark the answer as correct. I can find 4 options under the answer, Actions, Like, Reply, Translate. In Actions link, I can see only Report Abuse.

Please tell me how to set the answer as correct.

Thanks & Regards,

Lohithkumar

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
LEGEND ,
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

LATEST

Unfortunately, this thread wasn't started as a question and Rick's response has already been marked as "Helpful". At this point, it can no longer be changed to a question and marked with a correct answer

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