Quantcast
Channel: Adobe Community: Message List - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 3715

Re: Replacing all text in book with sample text

$
0
0

OK, I have figured it out. Here is a script that works across all text in the main flow after opening the document.

 

var oDoc = app.ActiveDoc;

var oRange = oDoc.TextSelection;

var oPgf = oRange.beg.obj;

var oTLoc1 = new TextLoc;

var oTLoc2 = new TextLoc;

var oTRange = new TextRange;

var sNewTxt;

 

while ( oPgf.ObjectValid ( ) )

{

          var oTexts = oPgf.GetText ( -1 );

          oTLoc1.obj = oPgf;

          oTLoc2.obj = oPgf;

          for ( i = 0; i < oTexts.length; i++ ) {

                    if ( oTexts[i].dataType == Constants.FTI_String ) {

                              oTLoc1.offset = oTexts[i].offset;

                              oTLoc2.offset = oTexts[i].offset + oTexts[i].sdata.length;

                              oTRange.beg = oTLoc1;

                              oTRange.end = oTLoc2;

                              oDoc.TextSelection = oTRange;

                              oDoc.Clear ( 0 );

                              sNewTxt = oTexts[i].sdata.replace ( /[a-z]/g, 'x' );

                              sNewTxt = sNewTxt.replace ( /[A-Z]/g, 'X' );

                              oDoc.AddText ( oTLoc1, sNewTxt );

                    }

          }

          oPgf = oPgf.NextPgfInDoc;

}


Viewing all articles
Browse latest Browse all 3715

Trending Articles



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