Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

How to center the new string ?

$
0
0

Hi forum.

 

I have got a function that delete a text from a texline  and set a new text in this one.

the new text is shorter and i would to center this text instead of set on the left side.

 

the currently uggly workaround i found is to put space to the front of the new text.

do you have smarter solution to center the text like managing the offset,LocX or adding the center property .

 

thank you

 

function ChangeText(TextLineFrame){

    // cette procedure remplace le texte de l'objet TEXTLINE

    // on défini le textrange

    // on recupére les proprietés du texte avant de le supprimer et de le remplacer.

  

     var DZGprops  

     var BegLoc = new TextLoc(), EndLoc = new TextLoc(); //create text location object

           

     BegLoc.obj = TextLineFrame;

     BegLoc.offset = 0; // insert at the start of the cell

     EndLoc.obj=TextLineFrame;

     EndLoc.offset=Constants.FV_OBJ_END_OFFSET;

    var textRange = new TextRange (BegLoc, EndLoc);

  

    DZGprops= app.ActiveDoc.GetTextProps(textRange.beg);

    app.ActiveDoc.DeleteText(textRange);

    app.ActiveDoc.AddText(BegLoc, "                                                    new text with front blank space"  );

    app.ActiveDoc.SetTextProps(textRange, DZGprops);  

    $.writeln("text has been change");

  

     }


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>