FM Script to find the pagenumber of a paragraph

New Here ,
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

500

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
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;

    }

}

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
Feb 08, 2016

Copy link to clipboard

Copied

Hi, the code is working fine

Thank You

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Feb 09, 2016

Copy link to clipboard

Copied

Please mark the answer as Correct. Thank you.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
New Here ,
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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Feb 09, 2016

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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