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

Fetching AFrame for each page

$
0
0

Hi,

 

I want to fetch all Aframes information in an active doc whose layout has three columns for each page.

 

WS000001.jpeg

 

 

 

 

I wrote the code below:

 

#target framemaker 

var doc = app.ActiveDoc;

if (doc.ObjectValid() == true) {

    var page = doc.FirstBodyPageInDoc;

    while (page.ObjectValid()) {

        var graFrame = page.PageFrame.FirstGraphicInFrame;

        while (graFrame.ObjectValid()) {

            var subcol = graFrame.FirstSubCol;

            while (subcol.ObjectValid()) {

                var aFrame = subcol.FirstAFrame;

                while (aFrame.ObjectValid()) {

                    alert(page.PageNum + " " + aFrame.Width); // display Info about Aframe

                    aFrame = aFrame.NextAFrame;

                }

                   subcol = subcol.NextSubCol;

            }

            graFrame = graFrame.NextGraphicInFrame;

        }

        page = page.PageNext;

    }

}

 

 

This code does not work correctly.

Alert message like below;

-----------------------------

0 1000

0 2000

1 2000

-----------------------------

 

 

The second alert, "0 2000" is undesirable, because this information about Aframe on page 1.

"var subcol" ignores the page.

 

 

Could you teach me how to fix it, please?

 

 

Thanks,

Koji Koike


Remove Character Format Override From Text Range

$
0
0

This should be simple, but I am wracking my brains trying to figure this out.

 

I simply want to take a text range and remove any character format override (CTRL-I or CTRL-O) and remove the override. I am thinking I need to create a special PropVal variable, but I am trying to figure out how to do this properly.

 

Thanks,

Marc

FDK custom dialog scrolling list item limit

$
0
0

FM is crashing when I am population a list of items in a scrolling list display. I think it is due to the number of items, around 1000 or more lines and it crashes, otherwise it works fine.

 

Is there a hard limit on the number of items displayed? Can it be overridden or is there an alternative similar display method?

Script to Apply Conditional Tag based on Paragraph Tag?

$
0
0

I use conditional tags to apply automatic updates to headers and footers using variables. The conditional tag is applied to a paragraph based on what the paragraph tag is. The condition displayed is dependent upon where it is located in the hierarchy. For instance, let's say the RED conditional tag is higher than the BLUE conditional tag, which is higher than GREEN conditional tag. I apply the RED conditional tag to the paragraph that has the Red paragraph tag applied.

 

Could I use a script to search for the paragraph tags (e.g., Red, Blue, Green)  and apply the corresponding conditional tag? I would also want to ensure that no other conditional tags are applied to any of the text in each paragraph. Any and all help is appreciated. Thank you in advance!

 

Example:

RED

 

 

(Red) This paragraph uses the Red paragraph tag and has the RED condition applied.

(Blue) This paragraph uses the Blue paragraph tag and has the BLUE condition applied.

(Green) This paragraph uses the Green paragraph tag and has the GREEN condition applied.

 

RED

Cannot execute script

$
0
0

I am trying to use ExtendScript for the first time (with FrameMaker 11, from TCS 4), but the script cannot be executed (very basic script example from the  Adobe "Introduction to Scripting" guide).

The error message says "Cannot execute script. : Target Adobe FrameMaker 11 provides no engine for debugging"

I tried it with other applications of the TC Suite: same error message

Do I need to install another application/module? What can I do to make it work?

Thank you

Geraldine

How to colorize AFrames

$
0
0

Hi,

 

I am trying the automatic processing below.

  • Add borders to Aframes
  • Colorize Aframes

 

Before:

before.jpeg

After:

after.jpeg

 

Adding borders succeeded, but I can't add colors to AFrames.

My script is below.

 

 

var doc = app.ActiveDoc;
if (doc.ObjectValid() == true) {  var colorFormat = doc.GetNamedObject(Constants.FO_Color, "Red");  var colorProps = colorFormat.GetProps();   var flow = doc.MainFlowInDoc;  var textFrame = flow.FirstTextFrameInFlow;  while (textFrame.ObjectValid()) {    var aFrame = textFrame.FirstAFrame;    while (aFrame.ObjectValid()) {      aFrame.Pen = 0;  //=> works!           aFrame.Color.SetProps(colorProps); //=> doesn't work...      aFrame.SetProps(colorProps); //=> doesn't work...      aFrame.Color.Name = "Red";  //=> doesn't work...      aFrame = aFrame.NextAFrame;    }    textFrame = textFrame.NextTextFrameInFlow;  }
}

 

Please teach me how to handle it.

 

Thanks,

 

Koji Koike

Checkboxes are set randomly

$
0
0

Dear all,

I'm fighting with randomly set check boxes in a particular dialogue:

$.writeln ("PaletteDocSettings1 -- IsDebug=" + settings.IsDebug + " Verbose=" + settings.Verbose + " EvalFeedback=" + settings.EvalFeedback);    wPalDS.p0.tabS.g1.pDbg.cbDebug = wPalDS.p0.tabS.g1.pDbg.add('checkbox',undefined,goTxt.wPalDSp0tabSg1pDbgcbDebug);    wPalDS.p0.tabS.g1.pDbg.cbDebug.preferredSize.height = 20;    wPalDS.p0.tabS.g1.pDbg.cbDebug.value = settings.IsDebug;    wPalDS.p0.tabS.g1.pDbg.cbVerbose = wPalDS.p0.tabS.g1.pDbg.add('checkbox',undefined,goTxt.wPalDSp0tabSg1pDbgcbVerbose);    wPalDS.p0.tabS.g1.pDbg.cbVerbose.preferredSize.height = 20;    wPalDS.p0.tabS.g1.pDbg.cbVerbose.value = settings.Verbose;       wPalDS.p0.tabS.g1.pDbg.cbEvalFeedback = wPalDS.p0.tabS.g1.pDbg.add('checkbox',undefined,goTxt.wPalDSp0tabSg1pDbgcbEvalFeedback);    wPalDS.p0.tabS.g1.pDbg.cbEvalFeedback.preferredSize.height = 20;    wPalDS.p0.tabS.g1.pDbg.cbEvalFeedback.value = settings.EvalFeedback;
$.writeln ("PaletteDocSettings2 -- IsDebug=" + wPalDS.p0.tabS.g1.pDbg.cbDebug.value + " Verbose=" + wPalDS.p0.tabS.g1.pDbg.cbVerbose.value + " EvalFeedback=" + wPalDS.p0.tabS.g1.pDbg.cbEvalFeedback.value);

The first write reports:

   PaletteDocSettings1 -- IsDebug=false Verbose=false EvalFeedback=false

The second write reports:

   PaletteDocSettings2 -- IsDebug=true Verbose=true EvalFeedback=false

 

What has changed the settings for the first two check boxes?

Any ideas?

How to access TblFmt from a Tbl object?

$
0
0

Is there any way to get a TblFmt from a selected Tbl which I can then use to set the TblFmt while creating a new Tbl from selected paragraphs? I am looking to convert a table to paragraphs, work on the paragraphs and then reconvert the paragraphs into a new table with the same format as previous table. I have a TextRange of selected paragraphs and am able to create a new Tbl using FCode KBD_TABLE_CONVERT but I want the new Tbl to have the same properties as the old Tbl.


Has anyone used scripts in FrameMaker 2015?

$
0
0

Hi everyone,

 

We have some relatively complex scripts we use to update books in FrameMaker 10. Now that we are running them on FrameMaker 2015, the results are mixed. We are parsing out each function and doing some testing, but I wanted to check here if anyone has any experience running scripts in FM2015.

 

If we get the issue narrowed down, I will try to share our results here.

 

Thanks for your feedback!!

 

Heather Ayer

Calling XSLT with CallClient

$
0
0

What is the syntax for calling XSLT transformations with ExtendScript's CallClient method? An example would be helpful.

 

Also, are there any other undocumented methods or properties that have been recently added? I was disappointed about not knowing about this before. Adobe guys, please let us power users know when there are new features in ExtendScript. Thank you very much.

 

-Rick

How to check current page type

$
0
0

"Welcome back my friends to the show that never ends" - I'm trying to handle variables and need to know whether the  current page is a master page or body page. As You know, on a master page more system variables are valid (Running H/F xx, Current Page #). So to set up a list of valid system vars I need to know where I am.

I read in the doc: PageObject is any Page object i.e., BodyPage, MasterPage, ReferencePage, HiddenPage.

Experiments show that I get answers with this short pgm - but what kind of pages are 'hidden' in the values 0...4, > 7 ?

Is this the correct way to test for the page type?

// CheckPageType.jsx
var   oDoc = app.ActiveDoc;
var   oPage = oDoc.CurrentPage;
var pageType = oPage.type;
$.writeln ("page = " + pageType);
/* type reported   5   Constants.FO_BodyPage        6   Constants.FO_MasterPage   7   Constants.FO_RefPage
*/

Ah well, "don't check for an error situation you don't know how to handle".

Klaus

How do I find the Allowed Data Range for an element definition

$
0
0

I'm using FrameMaker 2017 and ExtendScript. In my EDD I have an element that has its content defined as INTEGER. It also has an allowable range defined, in this case it's 'From 2 To 11'. This all works just fine in the EDD and in the structured documents.

 

When I try to handle the data range definition through ExtendScript there is no way to get the ElementDef.AllowedDataRange. It is mentioned in the scripting guide, but is not available in the ESTK. Any thoughts before I post a bug report?

 

Ian

Handling element auto insertions

$
0
0

I seem to be digging deep into areas of FrameMaker's ExtendScript Object Model that don't get much attention.

 

In an EDD it is possible to define the auto-insertions that happen when you add a new element to a structured document. The auto insertions can be InsertChild or InsertNestedChild. I need to handle these insertions dynamically according to element context. Unfortunately this seems to be impossible with ExtendScript.

 

In an ElementDef there are two relevant properties AlsoInsert and AlsoInserts. The first is an array of Stings and the second a Typed Val. It is not clear how these should work together to match the possibilities of the EDD structure. Has anyone made this work? I had a look at the FDK documentation but it's not very helpful.

 

The FDK and ExtendScript documents seem to be giving different information which is unhelpful. The FDK reference does not include a definition for an equivalent to AlsoInserts.

 

Any ideas greatefully received.

Ian

 

 

Display selection on proper page type

$
0
0

Dear experts,

To be able to navigate to any variable in the document (used on any page type) I first collect all information about the variables. The arry elements are built by the prototype function (is this the correct term?)

function oVariable (sName, sContents, oVar, bUsed, bSystem, oTr, sPageType, iPageNr, sPageName) {  this.Name     =  sName;                         // Name of variable  this.Contents =  sContents;                     // Contents of variable  this.VarObj   =  oVar;                          // Var object in document  this.VarUsed  =  bUsed;                         // User var is used in document  this.IsSystem =  bSystem;                       // true for system variable  this.TextRange=  oTr;                           // textrange of this occurance in the doc  this.PageType =  sPageType;                     // BodyPage or ... where var was found  this.PageNr   =  iPageNr;                       // for BodyPage  this.PageName =  sPageName;                     // for the other types
} //--- end oVariable

 

 

In a loop through the variables I fill the global array of objects, which works fine.

For the following don't worry about the goFMc prefix: it is the name of the global object holding all stuff.

function GetVarsInDoc (oDoc) { //=== Fill the doc variables array with all found vars in Doc ======
var bIsSystem, bIsUsed, oPage, oTR, oVar, index, iPageType, sPageType, sVarName, sVarContents;  goFMc.aDocVars.length = 0;                      // clear array for new build up  oVar = oDoc.FirstVarInDoc;                      // the variable in the text  while (oVar.ObjectValid()) {    sVarName = oVar.VarFmt.Name;                  // name of the variable    sValue   = oVar.VarFmt.Fmt;                   // contents of variable    oTR      = oVar.TextRange;                    // the text range of the variable    bIsSystem= (oVar.VarFmt.SystemVar !== Constants.FV_VAR_USER_VARIABLE);    bIsUsed  = UsrVarIsUsed (oDoc, sVarName);    goFMc.aDocVars.push (new oVariable (sVarName, sValue, oVar, bIsUsed, bIsSystem, oTr, null, null)); // array element    oDoc.ScrollToText(oTR);                       // Go there to get page type    oPage = oDoc.CurrentPage;    sPageType = oPage.constructor.name;           // BodyPage, MasterPage, RefPage [Rick Quatro]    index = goFMc.aDocVars.length - 1;            // use current array entry    goFMc.aDocVars[index].PageType = sPageType;    if (sPageType == "BodyPage") {      goFMc.aDocVars[index].PageNr = oPage.PageNum;    } else if (sPageType == "MasterPage") {      goFMc.aDocVars[index].PageName = oPage.Name;    } else if (sPageType == "RefPage") {      goFMc.aDocVars[index].PageName = oPage.Name;    }    oVar = oVar.NextVarInDoc;  }  goFMc.nDocVars = goFMc.aDocVars.length;
} //--- end GetVarsInDoc

 

To get to the first variable in the document I have the following function in the dialogue:

function ButtonFirst () { //=== Go to first variable in document ==================================
var bSystemVar, iVar, jVar, oVar, sName;  iVar =0;                                        // index in doc variable array  goFMc.indexDocVars = iVar;                       // keep for other nav buttons  oVar = goFMc.aDocVars[iVar].VarObj;             // first item in doc variable array  sName = goFMc.aDocVars[iVar].Name;  bSystemVar = goFMc.aDocVars[iVar].IsSystem;  DisplayVariable (goFMc.oCurrentDoc, iVar);      // can be on any page type
// ...
} //---  end ButtonFirst

 

Relevant data (the ingredients) from goFMc.aDocVars[0] for DisplayVariable is

Name     =  Running H/F 1
Contents =  <$paratext[0chapter-title]>
VarObj   =  // Var object in document
VarUsed  =  false   // User var is used in document
IsSystem =  true
TextRange=  // textrange of this occurance in the doc
PageType =  MasterPage
PageName =  Left

 

The user normally start on the body pages, while many variables can be on the master pages and even on the reference pages. Hence the display should switch between the various page types. However, in my test case the variable is on the first master page - but the display is still the current body page.

My question now is: why does DisplayVariable not jump to the appropriate page type and show the selected variable?

After executing ButtonFirst I can manually switch to the master pages where I see the variable selected on the very first one.

function DisplayVariable (oDoc, iVar) { //=== display the indexed variable ========================
var oTR;  oTR = goFMc.aDocVars[iVar].TextRange;  oDoc.TextSelection = oTR;  oDoc.ScrollToText(oTR);
} //--- end DisplayVariable

When switching manually to the last master page before I use the button then the display is correct.

But how can I make the function automatically go to the relvant page type?

I have the necessary ingredients, but no recipe...

Any ideas are welcome

Klaus

Nasty behaviour of ESTK

$
0
0

Dear all,

A while ago (2017-01-23) I issued bug report FRMAKER-2240

Although all my scripts include the directive #target framemaker, and it is my habit to first open FM and then ESTK to start a script, the script runs into an error, because ESTK does not look at the directive. It tries to execute the script in ExtendScript Toolkit CC.

 

The bug report is stil "To track" - imho a lazy excuse. Please vote if you have the same problem with this as I have.

Klaus


Find variables in appearing order

$
0
0

Dear friends,

Collecting variables in the order of their creation works fine for me:

function GetVarsInDoc (oDoc, aDocVars) { //=== Fill the doc variables array with all found vars in Doc ======
var oTR, oVar, sVarName, sValue;  aDocVars.length = 0;                            // clear array for new build up  oVar = oDoc.FirstVarInDoc;                      // the variable in the text  while (oVar.ObjectValid()) {    sVarName = oVar.VarFmt.Name;                  // name of the variable    sValue   = oVar.VarFmt.Fmt;                   // contents of variable    oTR      = oVar.TextRange;                    // the text range of the variable    aDocVars.push (new oVariable (sVarName, sValue, oVar, oTR));    oVar = oVar.NextVarInDoc;  }
} //--- end GetVarsInDoc

 

When walking (do you have a better term) through the collected variables the display jumps between body and master pages and the first few variables are all on the master pages. This jumping irritates the user. Hence I want to collect the variables in the order as they appear in the document (will jump only once to the master pages) - same as when using the Find dialogue with Any Variable.

 

The following, however, does not do anything at all - what is wrong?

function GetVarsInDoc (oDoc, aDocVars) { //=== Collect variables in the 'natural' order ===========
var findParams, oPara, oTRnew TextRange(), oTxtLoc1, oTxtLoc2;  oPara = oDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf; // Start at the beginning of the document  oTR.beg.obj =  oTR.end.obj = oPara;  oDoc.ScrollToText(oTR);        //  test - nothing to see  findParams = GetFindParameters (2, null);       // Get the find parameters for finding any variable  InitFA_errno ();                                // reset - it is write protected (function not shown here)  oTR = oDoc.Find(oTR.beg, findParams);           // and do an initial find to get started.  while(FA_errno === Constants.FE_Success) {    oDoc.TextSelection = oTR;                     // set up the text range
// here code is required to come from oTR  to the variable object for storage    oDoc.ScrollToText(oTR);        //  test - nothing to see    InitFA_errno ();                              // to be used to track the progress of the find and replace    oTR = oDoc.Find(oTR.end, findParams);         // prepare for next find  }
} //--- end GetVarsInDoc

This is a stripped down version:

function GetFindParameters (iType, sSearch) { //=== set up parameters for various find actions ====
var findParams, propVal;  findParams = new PropVals() ;  switch (iType) {    case 2: // ---------------------------------- find any variable      propVal = new PropVal() ;      propVal.propIdent.num = Constants.FS_FindObject;       propVal.propVal.valType = Constants.FT_Integer;       propVal.propVal.ival = Constants.FV_FindAnyVariable ;       findParams.push(propVal);       return findParams;    default:      return null;  }
} //---  end GetFindParameters

 

Who can give me a hint?

Klaus

Copy all text from pdf to framemaker using Scripts..

$
0
0

Hi friends,

         

using framemaker script ,

 

          I want to take pdf file as input.         

          Then I want to copy all text from pdf and paste into framemaker using script.

          then save the framemaker file

 

  Is it possible ?

  if it is possible please help me friends....

scrollbox Multiple selection

$
0
0

Hi.

 

Is it possible to set scrollbox on a  custom dialog to multiple selection?

If it is, please tell me how to do it.

 

Thank you.

Listbox does not work on Windows 8 - bug submitted

$
0
0

Hi all,

 

I have been working on Windows 7 and never found any problems with list boxes in dialogs, until I ran the same script on another machine that had Windows 8.1 installed. None of the list items appears in the list box there and there is no way to work around the issue. I have submitted this bug and will report here if there is a solution. It might take a patch to get this nasty bug solved. I did not test it in any of the other Adobe application that use ExtendScript with the same ScriptUI.

 

Just be aware that list boxes will not work on Windows 8.1 for the time being.

 

Kind regards

 

Jang

FrameMaker12 dialog suppression and configurations

$
0
0

Greetings. I am attempting to create a command line script for use with FrameMaker12 and my question is in regards to the suppression of dialog screens when opening a FrameMaker (.fm) file/document. I have looked at the following resources for a solution

 

 

What I have noted is that the FM API allows a developer to control custom or pre-defined dialogs and there are various suppression options for different dialogs (i.e. -  SuppressXMLWarnings, SuppressFontAlertOnOpen). However, I have been unable to locate if there is an API call to set an option to suppress ALL dialogs (regardless of the  dialog) or a specific dialog ( in this case, a dialog that states a paragraph tag does not exist in the Paragraph Catalog)?

 

Is there an option or API call that suppresses all/specific dialogs? Also, can the various configuration options listed in maker.ini be accessed through the FM API?

 

Thank you in advance.

Viewing all 888 articles
Browse latest View live


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