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

How to add tags in your XML when changing style to Bold

$
0
0

I'm currently checking if there is an easier way to automatically add <b> tags when changing font style to Bold in your xml. I'm not sure how to override the format  of a structured application automatically in FM. Do I need to create a script for this? Or is there any configuration that can be made to make this work automatically?


Find Replace from Textfile with regex

$
0
0

Hello.

 

I'm wondering if anyone knows about an existing script that does a find/replace by list like the script "FindChangeByList.jsx" that comes with every InDesign installation.

This consists of tow parts, the script itself with the functionality and a simple textfile where you have simple one-liners capable of find/replace with regex.

 

the Textfile:

 

//FindChangeList.txt

//A support file for the InDesign CS4 JavaScript FindChangeByList.jsx

//

//This data file is tab-delimited, with carriage returns separating records.

//

//The format of each record in the file is:

//findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description

//

//Where:

//<tab> is a tab character

//findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).

//findProperties is a properties record (as text) of the find preferences.

//changeProperties is a properties record (as text) of the change preferences.

//findChangeOptions is a properties record (as text) of the find/change options.

//description is a description of the find/change operation

//

//Very simple example:

//text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double dashes and replace with an em dash.

//

//More complex example:

//text          {findWhat:"^9^9.^9^9"}          {appliedCharacterStyle:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".

//

//All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.

//

//If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"

//as shown in the example below:

//

//{findWhat:"\\s+"}

//

grep          {findWhat:"  +"}          {changeTo:" "}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double spaces and replace with single spaces.

grep          {findWhat:"\r "}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a space And replace with single returns.

grep          {findWhat:" \r"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a space and replace with single returns.

grep          {findWhat:"\t\t+"}          {changeTo:"\t"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double tab characters and replace with single tab characters.

grep          {findWhat:"\r\t"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a tab character and replace with single returns.

grep          {findWhat:"\t\r"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a tab character and replace with single returns.

grep          {findWhat:"\r\r+"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double returns and replace with single returns.

text          {findWhat:" - "}          {changeTo:"^="}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all space-dash-space and replace with an en dash.

text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all dash-dash and replace with an em dash.

 

 

The script:

 

//FindChangeByList.jsx

//An InDesign CS5.5 JavaScript

/* 

@@@BUILDINFO@@@ "FindChangeByList.jsx" 3.0.0 15 December 2009

*/

//Loads a series of tab-delimited strings from a text file, then performs a series

//of find/change operations based on the strings read from the file.

//

//The data file is tab-delimited, with carriage returns separating records.

//

//The format of each record in the file is:

//findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description

//

//Where:

//<tab> is a tab character

//findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).

//findProperties is a properties record (as text) of the find preferences.

//changeProperties is a properties record (as text) of the change preferences.

//findChangeOptions is a properties record (as text) of the find/change options.

//description is a description of the find/change operation

//

//Very simple example:

//text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double dashes and replace with an em dash.

//

//More complex example:

//text          {findWhat:"^9^9.^9^9"}          {appliedCharacterStyle:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".

//

//All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.

//

//If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"

//as shown in the example below:

//

//{findWhat:"\\s+"}

//

//For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html

//or visit the InDesign Scripting User to User forum at http://www.adobeforums.com

//

main();

function main(){

          var myObject;

          //Make certain that user interaction (display of dialogs, etc.) is turned on.

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

          if(app.documents.length > 0){

                    if(app.selection.length > 0){

                              switch(app.selection[0].constructor.name){

                                        case "InsertionPoint":

                                        case "Character":

                                        case "Word":

                                        case "TextStyleRange":

                                        case "Line":

                                        case "Paragraph":

                                        case "TextColumn":

                                        case "Text":

                                        case "Cell":

                                        case "Column":

                                        case "Row":

                                        case "Table":

                                                  myDisplayDialog();

                                                  break;

                                        default:

                                                  //Something was selected, but it wasn't a text object, so search the document.

                                                  myFindChangeByList(app.documents.item(0));

                              }

                    }

                    else{

                              //Nothing was selected, so simply search the document.

                              myFindChangeByList(app.documents.item(0));

                    }

          }

          else{

                    alert("No documents are open. Please open a document and try again.");

          }

}

function myDisplayDialog(){

          var myObject;

          var myDialog = app.dialogs.add({name:"FindChangeByList"});

          with(myDialog.dialogColumns.add()){

                    with(dialogRows.add()){

                              with(dialogColumns.add()){

                                        staticTexts.add({staticLabel:"Search Range:"});

                              }

                              var myRangeButtons = radiobuttonGroups.add();

                              with(myRangeButtons){

                                        radiobuttonControls.add({staticLabel:"Document", checkedState:true});

                                        radiobuttonControls.add({staticLabel:"Selected Story"});

                                        if(app.selection[0].contents != ""){

                                                  radiobuttonControls.add({staticLabel:"Selection", checkedState:true});

                                        }

                              }

                    }

          }

          var myResult = myDialog.show();

          if(myResult == true){

                    switch(myRangeButtons.selectedButton){

                              case 0:

                                        myObject = app.documents.item(0);

                                        break;

                              case 1:

                                        myObject = app.selection[0].parentStory;

                                        break;

                              case 2:

                                        myObject = app.selection[0];

                                        break;

                    }

                    myDialog.destroy();

                    myFindChangeByList(myObject);

          }

          else{

                    myDialog.destroy();

          }

}

function myFindChangeByList(myObject){

          var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;

          var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;

          var myStartCharacter, myEndCharacter;

          var myFindChangeFile = myFindFile("/FindChangeSupport/FindChangeList.txt")

          if(myFindChangeFile != null){

                    myFindChangeFile = File(myFindChangeFile);

                    var myResult = myFindChangeFile.open("r", undefined, undefined);

                    if(myResult == true){

                              //Loop through the find/change operations.

                              do{

                                        myLine = myFindChangeFile.readln();

                                        //Ignore comment lines and blank lines.

                                        if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")|| (myLine.substring(0,5)=="glyph")){

                                                  myFindChangeArray = myLine.split("\t");

                                                  //The first field in the line is the findType string.

                                                  myFindType = myFindChangeArray[0];

                                                  //The second field in the line is the FindPreferences string.

                                                  myFindPreferences = myFindChangeArray[1];

                                                  //The second field in the line is the ChangePreferences string.

                                                  myChangePreferences = myFindChangeArray[2];

                                                  //The fourth field is the range--used only by text find/change.

                                                  myFindChangeOptions = myFindChangeArray[3];

                                                  switch(myFindType){

                                                            case "text":

                                                                      myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

                                                                      break;

                                                            case "grep":

                                                                      myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

                                                                      break;

                                                            case "glyph":

                                                                      myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

                                                                      break;

                                                  }

                                        }

                              } while(myFindChangeFile.eof == false);

                              myFindChangeFile.close();

                    }

          }

}

function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

          //Reset the find/change preferences before each search.

          app.changeTextPreferences = NothingEnum.nothing;

          app.findTextPreferences = NothingEnum.nothing;

          var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";

          myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";

          myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";

          app.doScript(myString, ScriptLanguage.javascript);

          myFoundItems = myObject.changeText();

          //Reset the find/change preferences after each search.

          app.changeTextPreferences = NothingEnum.nothing;

          app.findTextPreferences = NothingEnum.nothing;

}

function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

          //Reset the find/change grep preferences before each search.

          app.changeGrepPreferences = NothingEnum.nothing;

          app.findGrepPreferences = NothingEnum.nothing;

          var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";

          myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";

          myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";

          app.doScript(myString, ScriptLanguage.javascript);

          var myFoundItems = myObject.changeGrep();

          //Reset the find/change grep preferences after each search.

          app.changeGrepPreferences = NothingEnum.nothing;

          app.findGrepPreferences = NothingEnum.nothing;

}

function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

          //Reset the find/change glyph preferences before each search.

          app.changeGlyphPreferences = NothingEnum.nothing;

          app.findGlyphPreferences = NothingEnum.nothing;

          var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";

          myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";

          myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";

          app.doScript(myString, ScriptLanguage.javascript);

          var myFoundItems = myObject.changeGlyph();

          //Reset the find/change glyph preferences after each search.

          app.changeGlyphPreferences = NothingEnum.nothing;

          app.findGlyphPreferences = NothingEnum.nothing;

}

function myFindFile(myFilePath){

          var myScriptFile = myGetScriptPath();

          var myScriptFile = File(myScriptFile);

          var myScriptFolder = myScriptFile.path;

          myFilePath = myScriptFolder + myFilePath;

          if(File(myFilePath).exists == false){

                    //Display a dialog.

                    myFilePath = File.openDialog("Choose the file containing your find/change list");

          }

          return myFilePath;

}

function myGetScriptPath(){

          try{

                    myFile = app.activeScript;

          }

          catch(myError){

                    myFile = myError.fileName;

          }

          return myFile;

}

 

 

This is a very useful and easy to maintain script which even people who cant write scripts (but know how to use regex) can do complex search replace mass replacements.

Would love to find something like this for FrameMaker 12 (as i can't write scripts myself).

 

regards

daniel

New Extendscript Guides for FM 11&12 available

Create an ExtendScript to create PDFs...object help

$
0
0

Hi Adobe Framer Community-

 

Does anyone know which FM Object the Constants.FV_SaveFmtBookWithFm property value constant is a property of? I think it's a property of the Doc object, but I'm having trouble finding documentation on how to work with this and/or to confirm this.

 

I am working on an ExtendScript script to automate the PDF process from DITA/XML files in FrameMaker 11 and following the directions on pg. 11 of the Adobe FrameMaker 10 Scripting Guide (also outlined very nicely on FrameAutomation.com) to get the notification set up. I'm using Constants.FA_Note_PreSaveDoc here, and I can get an alert to display the iparam (=0), the sparam (=..\GettingStarted.fm), and the object type (=object Doc).

 

So if the notification tells me the object type is Doc when I perform a Save Ditamap As -> Book 11 with fm components (*.book), how do I determine what (in the Doc object) the Constants.FV_SaveFmtBookWithFm property goes to? As far as I can tell, the Doc object contains the first page, followed by the paragraphs, etc. Does the Constants.FV_SaveFmtBookWithFm property value belong to some other object perhaps?

 

Thanks for any and all suggestions!

 

Diana

Is there a maker.ini command to change extendscript default startup directory?

$
0
0

Hi All,

 

Rather than use <framemaker install dir>\startup, I want to use c:\deploy - for storing all my required startup extendscripts and dlls.

 

Can I do this, if so, how?

 

 

Thanks!

 

Tracey

apply a conditional tag to all occurences of a pragraph

$
0
0

Is it possible to write an extend script to apply a conditional tag  to all occurences of a pragraph tag in a document? Are there any samples of a script like this

Applying a condition to a paragraph

$
0
0

Greetings,

 

I want to iterate through all paragraphs in a document and for each paragraph with the "comment" style, I want to apply an existing condition called "Comment" (as per p. 126 of the FDK Programmer's Guide)

 

The script below iterates, selects the correct text, but it doesn't apply the condition.  I suspect I am not adding the correct information to the condid variable. I've tried adding the object or just the Id integer value of the condition without success.

 

If I apply the condition manually to a paragraph and then run a script to look at the property values, Framemaker seems to apply the condition object to "osval" which is different than what the FDK states (isval).  And, of course, "osval" seems to be undocumented. So, I'm stumped on what Frame is expecting.

 

I'd appreciate any pointers.

 

Thanks.

 


#target framemaker

if (app.ActiveDoc.ObjectValid()) {
    processDoc(app.ActiveDoc);
}
else{
    Alert("No doc open");
}

 

function processDoc(doc) {
 
    var txtFrame= doc.MainFlowInDoc.FirstTextFrameInFlow;
    var pgf = txtFrame.FirstPgf;
   
    var CondObj=doc.GetNamedObject(Constants.FO_CondFmt,"Comment");
     
   
    while (pgf.ObjectValid()){

        var stylename="Comment";
        var paraname=pgf.Name;
        if (paraname == stylename){

          //get text selection for paragraph
            var tr = new TextRange();               
            tr.beg.obj = tr.end.obj = pgf;
            tr.beg.offset = 0;
          //Retrieve the text from the paragraph
            var txtstring = "";
            var textItems = pgf.GetText(Constants.FTI_String | Constants.FTI_LineEnd);
            for (var i = 0; i < textItems.len; i += 1) {
                txtstring += (textItems[i].sdata);
            }
          //Get length + line end          
            tr.end.offset = txtstring.length+1;
          // set text selection
            doc.TextSelection = tr;

 

 

          // Set up the Condition object          
            var condid = new Ints();
            condid.push(CondObj);
           
          // Create the properties and apply to the selection
            var newprops = AllocatePropVals(1);
            newprops[0].propIdent.num = Constants.FP_InCond;
            newprops[0].propVal.valType = Constants.FT_Ints;
            newprops[0].propVal.isval = condid;          

 

            FA_errno = Constants.FE_Success;
            doc.SetTextPropVal(tr, newprops);
           
            if (FA_errno != Constants.FE_Success){
                $.writeln ("Error : " + FA_errno);
            }
        }
        pgf=pgf.NextPgfInFlow;
    }

}

Error while loading an XML document using a structured application

$
0
0

Hi,

 

I try to load an XML document using a structured application defined in the default structapps.fm

 

My code is shown down, extracted from the FDK API code sample.

 

Problem, I always have the same message :

"Cannot find the file named e:\xml\AdobeFrameMaker10\file. Make sure that the file exists. "

 

Where "e:\xml\AdobeFrameMaker10\" is my install directory.

So I assume that frame try to find the structapps.fm file but does not find it.

What else can it be ?

 

Does anyone knowns how to achieve this simple task using extendScript ?

 

Thanks for any comments, Pierre

 

 

 

function openXMLFile(myLastFile) {

    var filename = myLastFile.openDlg("Choose XML file ...", "*.xml", false);

    if (filename != null) {

       

 

        /* Get default open properties. Return if it can’t be allocated. */

        var params = GetOpenDefaultParams();

       

       

        /* Set properties to open an XML document*/

       

        /*Specify XML as file type to open*/

        var i = GetPropIndex(params, Constants.FS_OpenAsType)

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

       

       

        /* Specify the XML application to be used when opening the document.*/

        i = GetPropIndex(params, Constants.FS_StructuredOpenApplication)

        params[i].propVal.sval = "myApp";

       

       

        i = GetPropIndex(params, Constants.FS_FileIsOldVersion)

       

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

       

        i = GetPropIndex(params, Constants.FS_FontNotFoundInDoc)

       

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

       

        i = GetPropIndex(params, Constants.FS_FileIsInUse)

       

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

       

        i = GetPropIndex(params, Constants.FS_AlertUserAboutFailure)

       

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

       

        /*The structapps.fm file containing the specified application must have

        already been read. The default structapps.fm file is read when FrameMaker is

        opened so this shouldn't be a problem if the application to be used is

        listed in the structapps.fm file.*/

       

        var retParm = new PropVals()

        var fileObj = Open(filename, params, retParm);

        return fileObj

    } else {

        return null;

    }

}


my palette window hides behind main window

$
0
0

For awhile, as I developed a script, the "tools palette" window that it creates stayed in front of the main doc window. Somehow it changed behavior, and how hides behind the main doc window whenever I click in the document. I want the tools to stay in front, but I can't find any window property to help with this.

Free and For-sale Scripts

$
0
0

Though I don't write scripts myself, I was happy when Adobe announced that ExtendScript capability would be added to FrameMaker. I thought that users would write scripts to enhance FrameMaker's capability and share them with the community-- either as free or for-sale scripts. I'm surprised that I have not seen that happen.

 

Perhaps some of you have developed scripts that you would be willing to give away or sell. If so, perhaps you could start listing them in this message thread.

Getting rid of a notification

$
0
0

I have tried notification and decided there are too many problems with it. But no matter what I do now, the Console keeps showing the same notification error with every file I open. I had a notification on the File Open event, but that script file is gone. How do I tell FM to just forget about any notifications that require an ExtendScript file? Or is FM going to nag me about this until the end of time? Is there some kind of overview of active notifications, which preferably also allows me to disable them for particular clients?

 

Kind regards

 

Jang

How can I find out if a structured doc is valid?

$
0
0

Hi all,

 

I need to establish the validity of a Doc before my script transforms it to XML and applies an XSLT in the process. I have searched the FM12 scripting guide but cannot find any Doc property or method to figure out whether or not the Doc is valid. Am I looking in the wrong place?

 

Kind regards

 

Jang

Patternstream and Framemaker Publishing Server 12

$
0
0

What's the best way to make sure an FDK (Patternstream in our case) fires up with every job on Framemaker Server 12, and how do you pass parameters (e.g., the name of the pset file to work with?)   We can delve into C++ etc. if we have to, but I'm hoping this can be handled with Framescript or Extendscript.   Thanks in advance.

Set book file name when opening XML file using Read/Write rules

$
0
0

We are attempting to script the loading of an XML file into FrameMaker binary files and subsequent processing.  Our structured appplication read/write rules specify the component names, but FrameMaker always prompts for the book file name.  Is there a way via a notify event (FA_Note_PreOpenXML or FA_Note_PostOpenXML), or opening the XML file using a property, that the book file name can be set?  Or do we have to to bypass the read/write rules and create the components manually?

 

Jon

 

Environment

- Windows 7 SP1

- FrameMaker 11

- Custom XML structured application

FDK: #define FAPI_*_BEHAVIOR

$
0
0

FDK allows for defining the following symbols: FAPI_4_BEHAVIOR, FAPI_5_BEHAVIOR, FAPI_55_BEHAVIOR and FAPI_6_BEHAVIOR. What FAPI_*_BEHAVIOR shall be defined for FDK12? I found the follwoing inconsistency:

 

FIRST:

********

fapi.h defines F_ApiNotify() as follows:

 

#ifdef FAPI_4_BEHAVIOR

extern VoidT F_ApiNotify FARGS((IntT notification, F_ObjHandleT docId, StringT filename));

#else

externVoidT F_ApiNotify FARGS((IntT notification, F_ObjHandleT docId, StringT sparm, IntT iparm));

#endif

 

If I look at F_ApiNotify() in FDK 12 Programmer's Reference, I derive that FAPI_4_BEHAVIOR shall NOT be defined.

 

SECOND:

*************

fapi.h defines F_AttributeDefT as follows:

 

typedefstruct {

          StringT name;

          BoolT required;

#ifdef FAPI_5_BEHAVIOR

          BoolT readOnly;

#else

          UIntT flags;

#endif

          IntT attrType;

          F_StringsT choices;

          F_StringsT defValues;

          StringT rangeMin;

          StringT rangeMax;

} F_AttributeDefT;

 

Comparing it with FDK 12 Programmer's Reference, I conclude that FAPI_5_BEHAVIOR shall NOT be defined.

 

THIRD:

*********

fchannel.h defines F_ChannelOpen() as follows:

 

#ifdefined(FAPI_5_BEHAVIOR) || defined(FAPI_4_BEHAVIOR)

extern ChannelT F_ChannelOpen FARGS((FilePathT *path, StringT type));

#else

externChannelT F_ChannelOpen FARGS((FilePathT *path, CStringT type));

#endif

 

Comparing it with FDK 12 Programmer's Reference, I conclude that FAPI_5_BEHAVIOR shall be defined or FAPI_4_BEHAVIOR shall be defined..

 

THERE IS A CLASH!

**************************

FIRST and SECOND say that none of them shall be defined, THIRD says that one of them shall be defined.

 

Could somebody give me a hint what symbol shall I define for FDK 12?

 

Many thanks in advance.  Zdenek


Framescript: search and replace condition name in a bunch of mif files

$
0
0

Hello fellows,

 

I would like to loop through all mif files listed in a book, and search/replace specific condition names with other ones.

This can be done in each FM file as follows:

...

Sub ProcessDoc

  Loop ForEach(CondFmt) In(vCurrentDoc) LoopVar(vCondFmt)

    If vCondFmt.Name = (vCurrentName)

      Set vCondFmt.Name = (vFutureName);

    EndIf

  EndLoop

EndSub

...

 

The question is what would be the code in case of mif files. Conditions are defined in mif files as follows:

 

<Conditional

    <InCondition `SampleCond'>

    <InCondition `SampleCond'>

   > # end of Conditional

 

Thank you for your input in advance!

Finding an element from a text location

$
0
0

Hello again,

 

How do I get to an element from a text location ? As my document is structured I am always in an element, but there does not seem to be a way to get there easily. I tried doc.ElementSelection but that just gives me ivalid elements.

 

Thanks for any pointer in the right direction

 

Jang

Output function (results to a file) in Extendscript

$
0
0

When I check a script I use the alert to see if the code is working, such as "Current tag is body".

Is there a function that outputs alert results to a file? For example, a way to send to a file all

of the paragraph tags that are used in a document. (The actual code could be a loop). I could

use this as a start to produce what I really want, an array of all the valid tags, and then print to a file

a list of all the "rogue" tags that are not in the valid list

copy paste text frame

$
0
0

Hi to all.

I am trying to make a very simple script that finds the first text frame that exists in a flow (in this case a secondary flow with only a line of text) ,copy that in the exact same location to all pages of the active document. Is this possible with javascript?

Check if a single Text Item in a cell is bold and then grab the string that is bold

$
0
0

I have written a script that runs through a table and parses out the information I need to create another table with some added information.

The last piece that I can't seem to figure out is how to check if some text in a cell is bold and then grab said text to put in the new table.

I will give a small table demo of what I am try to retrieve.

 

Table A.

Column 1Description
123456This is a description (This is a note)
789123

This is a description (This is note A) (This is note B) (This is more stuff that isn't needed.

 

Table B.

Column 1Column 2Note
1123456(This is a note)
2789123(This is note A) (This is note B)

 

 

I can pull all of the other information across that I am trying to get without any issue.

I can't seem to figure out how to check the formatting of a TextItem to see if it is bold. I have been able to figure out how to check if a cell has bold text in it. using if ((tItems[counterVar].idata & Constants.FTF_WEIGHT) > 0). This ends up not working well because of a few issues. I was wondering if there is any way to check the formatting of a single character?

I tried something similar to the following:

 

prop_Change = tbl_Description_Cell.GetText(Constants.FTI_CharPropsChange);

txt_String = tbl_Description_Cell.GetText(Constants.FTI_String);

if (prop_Change.len > 0)

{

        if((prop_Change[0].idata & Constants.FTF_WEIGHT) > 0)

        {

                pOffset = prop_Change[0].offset;

                for (var tbl_tItems = 0; tbl_tItems < txt_String.len; tbl_tItems++)

                {

                        tOffset = txt_String[tbl_tItems].offset

                        if(tOffset == pOffset)

                        {

                                alert(txt_String[tbl_tItems].sdata);

                        }

                }

        }

}

 

Thanks,

 

Steven

Viewing all 888 articles
Browse latest View live


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