7 Replies Latest reply on Jun 29, 2016 7:06 PM by daitranthanhoa

    How get Page Number of a Character?

    daitranthanhoa Level 1

      Current i am getting Page of a Character by CreateOutlines

      Dim oaPols = oChar.CreateOutlines(False)

      Get Page of Object oaPols (1).

      But sometimes Indesign was crash by this code: Dim oaPols = oChar.CreateOutlines(False)

      How get Page Number of a Character?

        • 1. Re: How get Page Number of a Character?
          Willi Adelberger Most Valuable Participant

          Why do you make outlines? It should NEVER be done in InDesign!

          • 2. Re: How get Page Number of a Character?
            daitranthanhoa Level 1

            Ex: I have 2 TextFrames Link:

            Text="This is test"

            TextFrame1 contain "This is" and put on Page 1

            TextFrame 2 contain "Test" and put on Page 2.

            If get full content of TextFrame 1 , i have text="This is test".

            But i want get page number of "Test" is Page 2.

            How get Page Number of a Character?

            • 3. Re: How get Page Number of a Character?
              Willi Adelberger Most Valuable Participant

              Sorry, I don't get what you want to do.

              • 4. Re: How get Page Number of a Character?
                Peter Spier Most Valuable Participant (Moderator)

                This seems like a scripting question, so I'm moving it to the scripting forum....

                • 5. Re: How get Page Number of a Character?
                  Laubender Adobe Community Professional & MVP

                  Willi Adelberger wrote:

                   

                  Why do you make outlines? It should NEVER be done in InDesign!

                  Hi Willi,

                  the OP is trying to find a method to get the page name of a given character somewhere on a page or on a spread and is using a scripting method from VB-Script.

                   

                  The parameter False in the method is indicating, that the character will be duplicated on top of the character as outline object.
                  In the UI you would select a character and hold the ALT key when using the menu command to do this.

                   

                  Usually one is removing the returned object after getting the information from it by scripting.

                   

                  But obviously something is going wrong on the OP's side, because InDesign is crashing if this method is used on one of the sample characters. Usually a geometric object on a page will return the page object as value of its parentPage property ( ExtendScript ).

                   

                  I'm not into VB-Script, so below is an ExtendScript snippet for getting the page name of the text frame of a character.

                  Select one character and run the snippet code:

                   

                  // ExtendScript (JavaScript) snippet
                  // One single character should be selected:
                  
                  var myCharacter = app.selection[0];
                  var result = myCharacter.parentTextFrames[0].parentPage;
                  
                  
                  if(result == null)
                  {
                      alert("Character's text frame is considered on the pasteboard")
                  }
                  else
                  {
                      alert("Character's text frame is considered on page: "+result.name)
                  };
                  

                   

                  Now back to the method createOutlines().

                   

                  It would fail on e.g. all white space characters and characters that represent an anchored page item.

                  It would also fail, if the character is in overset text.


                  createOutlines() would throw an error but should not crash InDesign.

                  Now the following questions go to the OP:

                   

                  What is the character you are trying to use the method with?

                  Is it in overset text?

                   

                  What is your exact version of InDesign?
                  What is the exact version of your Windows OS?

                   

                  Regards,
                  Uwe

                  • 6. Re: How get Page Number of a Character?
                    Laubender Adobe Community Professional & MVP

                    Hi daitranthanhoa,

                     

                    maybe your question here is also answered in another thread you posted lately:

                    How get Parent TextFrame of Cell?

                     

                    Btw. getting the name or the number of a page are totally different things.

                    You get the number of a page using the documentOffset property of a page object.

                    In ExtendScript this number is zero-based, which means, that the documentOffset of the first page in a document is always number 0 .

                    VB-Script could be different. AppleScript will be different.

                     

                    The name property is always returning a string object. Depending on the option for the numbering system the user would chose for a section, it could be well a string like "0001" for the first page of a document. Could also be "0666", if the document starts with page 666. So it's also good to check the startPageNumber property of the doument, pageNumberStart and continueNumbering for every section in the document.

                     

                    Regards,
                    Uwe

                    • 7. Re: How get Page Number of a Character?
                      daitranthanhoa Level 1

                      Yes, thank you very much.