8 Replies Latest reply on May 18, 2012 4:37 PM by Marc Autret

    active page number

    SangeethaRajeshkumar

      Hi Friends,

       

      I try to check the font size used in text and defined in style are same or not. But i cant get the exact page number of the error text.

       

      my code

       

      var myStyle = app.activeDocument.allParagraphStyles;

       

       

      for (i=0; i<myStyle.length; i++)

      {

                var myFont = myStyle[i].appliedFont.name;

                var myFontSize = myStyle[i].pointSize;

       

                app.findGrepPreferences = NothingEnum.nothing;

          app.changeGrepPreferences = NothingEnum.nothing;

                app.findGrepPreferences.appliedParagraphStyle = myStyle[i];

       

                 var myResults  = app.activeDocument.findGrep();

                 var resultCnt = Number(app.activeDocument.findGrep().length);

       

                if (resultCnt > 0)

                {

                          for (j = 0; j<resultCnt; j++)

                          {

                                    myResults [j].select();

       

                                    if (app.selection[0].contents.length>0){

                                              for (k=0; k<app.selection[0].contents.length - 1;k++)

                                              {

                                                        var textSize = app.selection[0].characters.item(k).pointSize;

                                                        if (textSize != myFontSize)

                                                        {

       

                                                                            myReport += "error in this text " + app.selection[0].contents + "  Stylename: " + myStyle[i].name + " Page number " + app.activeWindow.activePage.name +'\r';

                                                                            k = app.selection[0].contents.length;

                                                        }

                                              }

                                    }

                          }

                }

       

      }

       

       

      Thanks,

      Sangeetha

        • 1. Re: active page number
          TᴀW Adobe Community Professional & MVP

          Do you know that with Live Preflight you can get a list of overrides

          through the UI without scripting? Is that perhaps sufficient?

           

          In your script you select your search results. That is rarely necessaty

          (unless you specifically want to see the page appear while the script runs).

           

          To get the page for any Text that you know is not in the pasteboard,

          usually this should be okay:

           

          myText.parentTextFrames[0].parent.name;

           

          Ariel

          1 person found this helpful
          • 2. Re: active page number
            SangeethaRajeshkumar Level 1

            Hi Ariel,

             

            It shows error 'object does not support the property or method 'name'

             

            please help me.

             

            Thanks,

            Sangeetha

            • 3. Re: active page number
              TᴀW Adobe Community Professional & MVP

              Maybe you've found something on the pasteboard, not on a page?

              1 person found this helpful
              • 4. Re: active page number
                [Jongware] Most Valuable Participant

                That error seems to indicate you have a result that's not simply "in a text frame that's on a page".

                 

                So perhaps it's in an anchored text frame, or in a group, or table or footnote; or, as Ariel said, the text frame is *not* on a page.

                 

                Check the type of this errant parent:

                 

                alert (myText.parentTextFrames[0].parent.constructor.name);

                 

                and the problem will reveal itself.

                1 person found this helpful
                • 5. Re: active page number
                  SangeethaRajeshkumar Level 1

                  Hi Jongware,

                   

                  alert (myText.parentTextFrames[0].parent.constructor.name);

                   

                   

                  This alert shows 'page'. How can i get pagenumber.

                   

                  i tried lot of time but i cant solve this, please help. I need to show the page number.

                   

                  Thanks,

                  Sangeetha

                  • 6. Re: active page number
                    [Jongware] Most Valuable Participant

                    This totally works for me:

                     

                    myText = app.selection[0];
                    alert (myText.parentTextFrames[0].parent.name);
                    

                     

                    Did you think this through far enough? Perhaps you only checked the very first occurrence of your text with this alert, and it's on a page and thus not throwing that error, and the one that does is the next one, or the one after that (etc.).

                    • 7. Re: active page number
                      SangeethaRajeshkumar Level 1

                      Hi Jongware and Ariel,

                       

                      Extremely sorry. Now only i find, problem is in my input file. Thanks for your timing help. Thanks. Thanks a lot.

                       

                      Thanks,

                      Sangeetha.

                      • 8. Re: active page number
                        Marc Autret Level 4

                        [Jongware] wrote:

                         

                        This totally works for me:

                         

                        myText = app.selection[0];
                        alert (myText.parentTextFrames[0].parent.name);
                        

                         

                         

                        Does it?

                         

                        A PageItem's parent might still be a Page in ID CS4 or before, but since CS5 I was told we had to deal with Spread.

                        (And that's why we now have the parentPage property.)

                         

                        @+

                        Marc

                        1 person found this helpful