Skip to main content
Inspiring
June 23, 2016
Question

How to add contents in the anchor text?

  • June 23, 2016
  • 4 replies
  • 575 views

Hi experts,

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

here is my goal:

Thanks

regard

John

This topic has been closed for replies.

4 replies

JohnwhiteAuthor
Inspiring
June 25, 2016

thank you Uwe,

I will try.

thank you so much.

regard

John

JohnwhiteAuthor
Inspiring
June 24, 2016

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;

                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

Kai Rübsamen
Participating Frequently
June 24, 2016

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

JohnwhiteAuthor
Inspiring
June 23, 2016

Thank you Loic

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

Regard

John

Loic.Aigon
Legend
June 23, 2016

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

So that would be tf.insertionPoints[0];

Loic.Aigon
Legend
June 23, 2016

So what did you try ?

JohnwhiteAuthor
Inspiring
June 23, 2016

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;

            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

Loic.Aigon
Legend
June 23, 2016

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.