create register (anchored) objects

Engaged ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

Hello.

My isssue:

I have a register as a plain text like:

A

Item ....... page x

Item ........ page x

B

Item. ........ page x

Item ..........page x

 

... and so on. Now I want to put the capital letters in an array, create small text frames with each letter as content, apply an object style, and place these text frames as anchored objects in the same place that that letter was. The last thing to do is to delete the source character.

 

 

    function regFormat(){
        app.findGrepPreferences = null;        
        app.findGrepPreferences.properties = {findWhat: "^\\u~b",}     

        texts = myDoc.findGrep();
        n = texts.length; 
        app.changeGrepPreferences.changeTo = "";      
        myText.changeGrep();   
        app.findGrepPreferences = app.changeGrepPreferences = null;   
        app.findGrepPreferences = NothingEnum.nothing; 
        app.changeGrepPreferences = NothingEnum.nothing; 

        for (var i=0; i<n; i++) {
            
            var y = texts[i].contents.toString();
            buchstabenMitKomma.push(y);
            }
        
        regBuchstaben = buchstabenMitKomma.toString().replace( /[\r\n,]+/gm, "" );

        for (var e=0; e<regBuchstaben.length; e++) {

            var x = myFrame.insertionPoints.lastItem().textFrames.add({geometricBounds: [0, 0, 5, 5]});

            x.contents = regBuchstaben[e];
            x.appliedObjectStyle = osRegister ; 

            }

     }     

 

 

Nearly everything is fine, except the insrting place of each rectangle. There are all one behind the other at the end of the document. How can I controll the insertion point? Can I save something like the position of those capital letters??

TOPICS
How to, Scripting

Views

100

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

LATEST

Hi cmoke73,

please provide a sample document and another one with one expected result.

That should be doable a bit easier.

What's your InDesign version?

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

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