Chapter 2: Sample ESTK scripts
ExtendScript is similar to JavaScript. You can easily develop ExtendScript for any of the applications in FrameMaker
if you are familiar with JavaScript.
Following are examples for scripts that automate specific activities in FrameMaker 10.
Note: Sample scripts shipped with FrameMaker are at the following location: <FMINSTALL_DIR>\samples
Adding text to a document and enabling change bar
The following script adds a sample text to a FrameMaker document and then enables the change bar. Open a
FrameMaker document before running the script.
Copy and paste the script to ESTK and select FrameMaker 10 as the target application. Click the Play button to run the
script.
var doc = app.ActiveDoc;
var tl = new TextLoc();
var firstPgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
tl.obj = firstPgf;
doc.AddText (tl, "Hello");
doc.AutoChangeBars =1;
The script creates a text location using the
location. Using the
AddText()
Changing the table properties in a document
The following script changes the left indentation of all the tables in a FrameMaker body page by 1 inch. It also changes
the width of the columns to 2 inches. Open a FrameMaker document that has tables with two columns before running
the script.
var doc =app.ActiveDoc;
var flow = doc.MainFlowInDoc;
var tbl = 0;
var textItems = flow.GetText(Constants.FTI_TblAnchor);
for (var i = 0; i < textItems.len; i += 1)
{
tbl = textItems[i].obj;
tbl.TblLeftIndent = (2*72 * 65536);
var tblColWidths = new Metrics (2 * 72 * 65536, 2 * 72 * 65536);
tbl.TblColWidths = tblColWidths;
}
method. Assign the first page of the document as the text
new TextLoc()
method, add a sample text. Set the
Last updated 9/26/2011
property to 1 to enable the change bar.
AutoChangeBars
6