Quantcast
Viewing all 888 articles
Browse latest View live

How do you modify content of a table, but retain the table's UserString?

I have a document containing structured table elements.  The tables contain user string information [used by the FDK for tracking purposes], but when I apply a simple script to modify the table shading, I then find the UserString no longer exists on the table.  [I checked this by comparing the MIF statements].

My outline script is:

doc = app.ActiveDoc

tbl = doc.FirstTblInDoc

tblfmt = doc.GetNamedTblFmt ("RouteTable")

prop = tblfmt.GetProps()

tbl.FirstRowInTbl ; cell = row1.FirstCellInRow ; cell.CellUseOverrideShading = true ; cell.CellOverrideShading = null ; cell.CellUseOverrideFill = true ; cell.CellOverrideFill = 3 ; // change the table

tbl.SetProps (prop) // apply the changes


According to the FrameMaker scripting guide, only Element and CombinedFontDefn objects can hold user strings.

How can I modify the table [with table tag "RouteTable"] while retaining the Table's UserString?


Hiding XML elements in the structure view – scripting influence to the structure view?

Hi

Is there a way to hide specific XML elements (really the elements and not the attributes) in the structure view?


I am asking this question to know if it is possible to influence the structure view by scripting.

 

Many elements are indeed used as a kind of help for constructions which have nothing to do with the actual contents especially in the case of tables.

 

You inflate the the structure view unnecessarily and the author will lose track of the real contents. It would be nice if there was a possibility to hide those help construction elements.

 

Thank you for any hints.

 

Regards

 

Apollo102

synchronized scrollbars of differents documents (using FM10)

Someone know how can I move two or more scrollbars of documents in the same FrameMaker process? I tried to search in the web but I found anything.. If someone know the code that I can use, please post it here.

 

Thank you           -Marco

.FirstXRefInDoc not working

Hello,

I try to parse xrefs in a doc (and update them), but I have trouble getting the reference to fist xref.

var comp = doc.FirstXRefInDoc;

returns undefined, although there are xrefs in a file. I work in FM 10.

also global update doc.UpdateXRefs does not seem to have any effect.

When I do manualy Edit - Update references, xrefs in document get updated. Are these properties and methods tied to FM11, in that case, what options I have in FM10?

Image may be NSFW.
Clik here to view.

Can a script execute another script?

Dear colleagues,

 

I am not talking about calling a function from another file for which I used the #include directive. I want to execute a .jsx that I know only at runtime.

 

Until now I have found this: If a script file contains

 

#target framemaker

 

it is possible to use File(lvFilename).execute() (without the target instruction the script would simply open in ESTK).

 

But: The execute() method triggers a warning that I should execute only scripts from trustworthy sources (or so…).

 

Is there any other method to execute other scripts? Or is there a way to make my scripts trustworthy?

 

- Michael

Undo support around extendscript command

This probably should be obvious, but how can "undo" be supported for a custom command(in Framemaker 10?  I found app.beginUndoGroup() for another product but frame gives an unknown method call for this.

 

The following will delete with Ctrl-Q, but "undo" remains greyed out.  Thanks in advance.

 

function demoDelete() {

    var doc = app.ActiveDoc;

    if (!doc) {

        alert("No active document");

        return;

    }

    var range = doc.TextSelection;

    if (range.beg.offset == range.end.offset) {

        alert("Need to select some text");

        return;

    }

    doc.DeleteText(range);

}

function Command(cmd) {

    app.beginUndoGroup("demoCsr Command");

    switch (cmd) {

    case 1111: {

        demoDelete();

    }

    app.endUndoGroup();

}

var cmd = DefineCommand(1111, "demoCsrXrefInsert", "demoCsrXrefInsert", "^q");

Save PDF with Bookmarks

How to save a book as PDF with bookmarks?

 

I am exporting an open book as PDF using the following script:

 

var params = GetSaveDefaultParams()

var returnParamsp =new PropVals()

var i = GetPropIndex(params, Constants.FS_FileType)

params[i].propVal.ival =Constants.FV_SaveFmtPdf

file.Save(pdfName, params, returnParamsp)

 

This works fine but the pdf document does not have bookmarks. I would like to get the same

result as if a selected "Generate PDF bookmarks" (translated from German) on the Bookmars

page of the PDF Settings dialog.

 

I guess I will have to set some property value, but which one? Is there a place where I can

look it up?

 

Thanks

Need help in content chunking..

Is there a way to extract the XPath results as separate XML files? I am currently looking to chunk a large xml file based on certain tags. I tried using XSLT, but I understand that FM 12 supports only XML version 1.0 and doesnt help in splitting. I am not familiar with Javascripting too. Is there a script or any easy way that can do this job. Any help is appreciated. Thanks!

Image may be NSFW.
Clik here to view.

How do I "Remove Structure from Flow" in a Script

I would like to emulate the "Remove Structure from Flow" in a Script - I have found "FCodes.KBD_REMOVE_STRUCT" but I think that is only used to examine a keystroke in a script.

Executing a program from a script

Hi all,

 

Is there a way to run a program (some exe, with optional commandline arguments) from within a script ?

 

Thanks

 

Jang

Image may be NSFW.
Clik here to view.

ChooseFile not working to open a directory ?

Hi all,

 

I am creating an installer for my scripts and need to get an istall directory from the customer. It seems that ChooseFile ( ) with the ChooseOpenDir parameter is exactly what I need. But this does not work: there is no dialog and the return value is always null. Does anyone else experience this? Is this a bug in FM or just something wrong in my FM installation? I am running FM 12.0.0.308 on Windows 7.

 

Ciao

 

Jang

How do I obtain a list of a document's "FontWeightNames"

FM 12 - Javascript

 

I cannot find the correct way to obtain a list of a document's "FontWeightNames"

 

This is as I understand it (but it does not work):

 

var mydocweights = MyDoc.FontWeightNames
                                        

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

                                        
  alert(mydocweights[i])                
                                        
}                                       
Image may be NSFW.
Clik here to view.

NewElementInHierarchy() - Adding New Elements, progressively takes longer when adding multiple siblings

With my ESTK script, users select model numbers from a list and then the script inserts an element with a model number entered into an attribute, one element for each model selected.

 

When adding a large number of elements, each additional sibling element takes a little longer to add then the previous element. Adding 250 elements can take upwards of 3-1/2 minutes or more. While adding 20, 50, or 75 elements happens quickly, without any noticeable duration. It’s somewhere above 110 is where it starts to be noticeable.

 

I even used $.hiresTimer and wrote the value to the console for each time a model was added. Since the timer is reset back to zero (0) each time it's called, it was easier to notice that the amount it incremented from one element to the next got progressively larger.

 

Any thoughts as to why it’s taking so long or thoughts on what I could do to speed it up?

 

The structure looks like this:

<PartModels>
      <NoteText>Text</NoteText>
      <Model ModelNumber=”ABC01”/>
      <Model ModelNumber=”ABC02”/>
      <Model ModelNumber=”DEF03”/>
      <Model ModelNumber=”DEF04”/>
      …
      …
      <Model ModelNumber=”XYZ01-A”/>
      <Model ModelNumber=”XYZ*B”/>
      <Model ModelNumber=”XYZ500”/>
</PartModels>

 

The script is somewhat straight forward: cycle through an array of the model numbers selected, add a new element for each model number and set it's attribute value to the model number. This is the short version:

 

Function InsertModelElements (modelsToIns, insElemLoc, GVdoc) {

     var newEleId;

     var newElemLoc = insElemLoc;

     var elemDef = GVdoc.GetNamedElementDef(“Model”);

     for(var i = 0; i < modelsToIns.length; i++){ // modelsToIns is the array of models selected

          newEleId = elemDef.NewElementInHierarchy(newElemLoc); //ElementLoc based on NoteText first, last, or not present

          SetAttribute(newEleId, "ModelNumber", null, modelsToIns[i]); //more robust function to set attribute

         

          /*Which also works for setting attribute*/

          //var vattributes = newEleId.GetAttributes();

          //vattributes[0].values[0] = modelsToIns[i];

          //newEleId.Attributes = vattributes;


          /*At one point I tried using a new element location from the last inserted element, no change*/

          //var newElemRange = setElementSelection(GV_doc, EleId); //function that returns range

          //newElemLoc = newNewElemRange.end;

                }

}

Any help is appreciated.

 

Sincerely,

Trent

Changing the color of an object

I have tried very unsuccessfully to change the color of an object:

My simplest approach has been:

 

//  The current color of a pgf format is Black and I want to change it to Royal Blue

 

var myobject =  MyDoc.GetNamedObject(Constants.FO_PgfFmt,"Heading-3")

myobject.Color.Name = "Royal Blue";

alert(myobject.Color.Name)  // the colour is still Black

 

I have also tried:

 

var mycolorprops = myobject.Color.GetProps()

var i  = GetPropIndex(myobject.Color,Constant.Name)

mycolorprops[i].propVal.ival =  Constants.FV_COLOR_ROYALBLUE        

                                     or

mycolorprops[i].propVal.sval =  "Royal Blue"

 

If I can solve for Color then I will be able to work with all other commands that involve Properties.

Image may be NSFW.
Clik here to view.

Where can I found a definitive list of JavaScript operators accepted by ExtendScript Editor

As a JavaScript Newbie (but not a newbie programmer!) I am finding it difficult to find out which JavaScript operators are accepted by ther ExtendScript Editor. I have the latest copy of David Flanagan's JavaScript Pocket reference (I never look in the Browser part of the reference) but frequently I find a useful command that is not accepted by the Editor. The lack of an appropriate reference is considerably slowing me up.


InvalidObject understanding

Hi,

 

I encounter an issue with custom objects, I try to find Element with the function Find(). When I search Xref, row or known elements I get a valid Object. If a search for a custom element like here "RuleTemplate" I get an InvalidObject. Here is my code :

 

var searchPropValRuleTemplate = AllocatePropVals(1) // allocate array of 1 PropVal
searchPropValRuleTemplate[0].propIdent.num = Constants.FS_FindElementTag // element search mode
searchPropValRuleTemplate[0].propVal.valType = Constants.FT_Strings; // property of type Strings (array of string)
searchPropValRuleTemplate[0].propVal.ssval.length = Constants.FV_NumFindElementItems; // required
searchPropValRuleTemplate[0].propVal.ssval[Constants.FV_FindElemTag] = "RuleTemplate"; // element to find
searchPropValRuleTemplate[0].propVal.ssval[Constants.FV_FindAttrName]= ""; // required even if empty
searchPropValRuleTemplate[0].propVal.ssval[Constants.FV_FindAttrValue] = ""; // required even if empty

var startLoc = new TextLoc(currentDoc.FirstPgfInDoc, 0);
var trFoundInDoc = currentDoc.Find(startLoc, searchPropValRuleTemplate);
var currentSGMLTag = currentDoc.ElementSelection.beg.child.Object;
var firstUidSGMLTag = currentSGMLTag.Unique;

 

In this sample currentSGMLTag is an InvalidObject, if I change the propval FindElemTag to "XRef" by example I get my XRef valid Object.

Can anyone help me please ? I'm missing something.

I am seeing book.SetProps() and doc.SetProps() crash both FrameMaker 11 and 12.

I am attempting to set the PDFDocInfo at the book and doc level.

I can get the active book, get its props, and read and write to the PDFDocInfo. When I add book.SetProps( props ); to the code it crashes FrameMaker 11 or 12.

 

I tried doing only:

var book = app.ActiveBook;

var props = book.GetProps ( );

book.SetProps ( props );

 

Simplest possible case, and the same with doc, it still crashes.

Has anybody else seen this?

 

Regards,

 

Stuart

Change Color in CellOverrideShading

Hi all,

 

I tried to change the color in CellOverrideShading but I didn't get it.

My attempts were the following:

First I tried to get the index of the color property via GetPropIndex:

var testProp = cell.CellOverrideShading.GetProps();

var testPropIndex = GetPropIndex(testProp, Constants.FP_Color);

But the result is "-4", so it seems that CellOverrideShading has no FP_Color property.

 

Second: I tried to change the color via the PropVal object:

     testProp[1].propVal.sval = 'Olive';


When I print the properties to the Console the color name seems to be updated to 'Olive'

for (var i=0; i <testProp.length; i++)

{

            propText = propText + ' \n' + i + ': ' + testProp[i].propIdent.name + ' - ' + testProp[i].propIdent.num + ' - ' + testProp[i].propVal.sval;

}

1:  - 20 - Olive

 

Then I assin the properties to the cell.

cell.CellOverrideShading.SetProps(testProp);

 

But the color in the Frame document remains unchanged. When I print the color name to the Console [Console('FARBE: ' + cell.CellOverrideShading.Name);]

I still receive FARBE: Königsblau

What's my mistake? Any ideas?

 

Yours Wolfgang

Doc Import Param to suppress XML import validation message

Hi,

 

I'm running a script where the first part is to import an xml document, then to make some changes to the imported xml.

Problem is, the xml may not always be valid. If it isn't I would like to still make the changes regardless.

Unfortunately, my code is not running as I end up with "Validation of XML file failed. Continue? " prompt.

Can I somehow suppress this ?  or is there a way to send the OK key hit - so my code can just continue without requiring any user interaction ?

 

 

var importParams = GetImportDefaultParams();

                         i=GetPropIndex(importParams,Constants.FS_ImportAsType);

                        importParams[i].propVal.ival=Constants.FV_TYPE_XML;

                         i=GetPropIndex(importParams,Constants.FS_FileIsXmlDoc);

                        importParams[i].propVal.ival=Constants.FV_DoOK;

                        i=GetPropIndex(importParams,Constants.FS_AlertUserAboutFailure);

                        importParams[i].propVal.ival=0;

                         i=GetPropIndex(importParams,Constants.FS_DontNotifyAPIClients);

                        importParams[i].propVal.ival=1;

                       // var importParams = GetImportDefaultParams();

                        i=GetPropIndex(importParams,Constants.FS_HowToImport);

                        importParams[i].propVal.ival=Constants.FV_DoByCopy;

                        var returnParams = new PropVals() ;

                alert("importing");

                        doc.Import (doc.TextSelection.end , filename, importParams, returnParams);

             app.ActiveDoc = doc;

 

do_something_else();

 

 

thanks!

Tracey

Image may be NSFW.
Clik here to view.

Process XML attributes of all tables in a structured document

Hi all,

 

I try to process the XML attributes of all tables in a structured document.

When I use SelectedTbl everything works fine for the selected table and the attributes of the tabelle Element are written correctly to the Console.

 

doc = app.ActiveDoc;

table = doc.SelectedTbl;

if (table.TblElement)

{

    Console('Elementname: ' + table.TblElement.ElementDef.Name);

    tblEle = table.Element;

    attrs = tblEle.GetAttributes();

    for (i = 0; i < attrs.len; i++) {

        aName = attrs[i].name;

        aWert = attrs[i].values;

        Console( "     " + aName + "    " + aWert);     

    }

}

 

However when I use GetText(Constants.FTI_TblAnchor) to walk through all tables of the documens neither ElementDef.Name nor Attributes are processed.

 

var flow = doc.FirstFlowInDoc;

var textItems = flow.GetText(Constants.FTI_TblAnchor);

while(iTab<textItems.length) {

table = textItems[iTab].obj;

if (table.TblElement)

{

    Console('Elementname: ' + table.TblElement.ElementDef.Name);

    tblEle = table.Element;

    attrs = tblEle.GetAttributes();

    for (i = 0; i < attrs.len; i++) {

        aName = attrs[i].name;

        aWert = attrs[i].values;

        Console( "     " + aName + "    " + aWert);     

    }

}

}

 

Any Suggestions?

Yours

Wolfgang

Image may be NSFW.
Clik here to view.
Viewing all 888 articles
Browse latest View live


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