9 Replies Latest reply on Jun 25, 2016 5:39 AM by Johnwhite

    How to add contents in the anchor text?

    Johnwhite Level 1

      Hi experts,

       

      My goal is add a tags in anchor text, here is orginal:

       

      00001.jpg

       

       

      here is my goal:

       

       

      00002.jpg

       

      Thanks

       

      regard

      John

        • 1. Re: How to add contents in the anchor text?
          Loic.Aigon Adobe Community Professional

          So what did you try ?

          • 2. Re: How to add contents in the anchor text?
            Johnwhite Level 1

            Hi Loic,

             

             

            I got this script:

             

             

                app.findObjectPreferences = NothingEnum.nothing;
                app.changeObjectPreferences = NothingEnum.nothing;
                app.findObjectPreferences.anchoredPosition = AnchorPosition.ANCHORED;
            var t  =myDocument.findObject();
                for(var i=0 ; i < t.length ; i++)
                {
                        var tf=t[i];
                        if(tf.parent.constructor instanceof Character)
                        {        
                          tf.texts.everyItem().move(LocationOptions.BEFORE, tf.parent);        
                          tf.parent.contents = "</sn1>\r";        
                        }  
                    }
                
                app.findGrepPreferences = 
                app.changeGrepPreferences = null
                app.findGrepPreferences.findWhat = "^(.+)</sn1>";
                app.changeGrepPreferences.changeTo = "<sn1>$1</sn1>";
                app.changeGrep();
            

             

             

            for get anchor text into main story, and add tags

            but How can I add the tags first will then get the anchor into main story?

             

             

            thanks

            Regard

            John

            • 3. Re: How to add contents in the anchor text?
              Loic.Aigon Adobe Community Professional

              Well as far as I understand you should reach the insertionPoint you are interested in and add a textFrame to this object. Then you can add contents to the anchored text frame.

              • 4. Re: How to add contents in the anchor text?
                Johnwhite Level 1

                Thank you Loic

                 

                but How can I get insertPoint in each ANCHORD text frame?

                 

                Regard

                John

                • 5. Re: How to add contents in the anchor text?
                  Loic.Aigon Adobe Community Professional

                  well insertionPoint is a child of the collection of insertionPoints that belongs to the textframe reference.

                  So that would be tf.insertionPoints[0];

                  • 6. Re: How to add contents in the anchor text?
                    Johnwhite Level 1

                    Hi Loic

                     

                    I change it like this:

                     

                        app.findObjectPreferences = NothingEnum.nothing;   
                        app.changeObjectPreferences = NothingEnum.nothing;   
                        app.findObjectPreferences.anchoredPosition = AnchorPosition.ANCHORED;   
                        var t  =myDocument.findObject();   
                        for(var i=0 ; i < t.length ; i++)   
                        {   
                                var tf=t[i]; 
                                    tf.insertionPoints[0].contents = "<sn1>";           
                                  tf.insertionPoints[-1].contents = "</sn1>";
                                if(tf.parent.constructor instanceof Character)   
                                {           
                                  tf.texts.everyItem().move(LocationOptions.BEFORE, tf.parent);           
                                  tf.parent.contents = "\r";
                                }     
                            }  
                    

                     

                     

                    but error.

                     

                    Coule you please show me how?

                     

                    Regard

                    John

                    • 7. Re: How to add contents in the anchor text?
                      Kai Rübsamen Adobe Community Professional

                      John or whatever your real name is:

                       

                      First, a lot of topics this week. Second, those posts are realy annoying!

                       

                      So, if you have a real problem, provide idml-files before/after. What should we do with your scrumbled screenshots? You know, I told you that from time to time.

                       

                      If you provide code, this code should be runable. In your example 'myDocumet' is not declared.

                       

                      Your code assumes, that you want to move everything from your anchored textframe in the normal textflow, but that is not what the second screen shows.

                       

                      So:

                      1. Provide examples

                      2. Make a detailed list with steps, that must be scripted

                      3. Think about it and show your executable script trial

                       

                      Kai

                      • 8. Re: How to add contents in the anchor text?
                        Laubender Adobe Community Professional & MVP

                        Hi John,

                        did you analyze the script you are showing in answer #2 ?
                        Did you run it step by step, line by line, from the ESTK ( ExtendScript Toolkit )?
                        There is a step-by-step mode.

                         

                        And you can set break points in the code and when a break point is reached you can inspect your variables in the JavaScript Console of the ESTK. Just write them into the Console window and press enter.

                        So you can find out what the variable tf really holds at that time.

                         

                        Read the JavaScript Tools Guide for how to use the ESTK..
                        You can find that under "Help" in the ESTK.

                         

                        Regards,
                        Uwe

                        • 9. Re: How to add contents in the anchor text?
                          Johnwhite Level 1

                          thank you Uwe,

                           

                          I will try.

                           

                          thank you so much.

                           

                          regard

                          John