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

Having Problems Using F_ApiSimpleImportFormats

$
0
0

Hi,

 

I am (still) using FM 8 in Structured Authoring mode with FDK8 .

 

I want to automate the processs of importing formats to the components of a book.

I have located the F_ObjHandleT of the files I want to import from

I have tried using:

F_ApiSimpleImportFormats(bookId, titleId, 0);

Where bookId is the F_ObjHandleT of the book using bookId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveBook);

And titleId is the F_ObjHandleT of the component to import from using titleId = F_ApiGetId(FV_SessionId, bookId, FP_FirstComponentInBook);

 

Believing this would simply update every file in the book

 

I have also tried cycling through the book componenets in a while loop with:

 

compId = F_ApiGetId(FV_SessionId, bookId, FP_FirstComponentInBook);

and

compId = F_ApiGetId(bookId, compId, FP_NextComponentInBook);

 

using

F_ApiSimpleImportFormats(compId, titleId, 0);

 

for each component (skipping the first one since that is the source)

 

In each case I get an FA_errno of -2 (FE_BadDocId - Illegal Document or Book)

 

I am able to get the name of the component using: componentName = F_ApiGetString(bookId, compId, FP_Name);

and print it to the log window, so I believe the doc ID and the book ID are sound.

 

Any other clues why I get an error on this API call?

 

Thanks,

 

- Michael


Can't add a new menu

$
0
0

Hi,

 

(FM10, Win XP)

 

Following the example in the scripting guide to add a menu with ES, I just can't get it to work. I expect the menu to appear after I run the script, which it does when I run the equivalent with the FDK. What am I missing here?

 

var fmMainMenu = app.GetNamedMenu("!MakerMainMenu") ;

var newMenu = fmMainMenu.DefineAndAddMenu("MyMenu1", "MyMenu1");

 

I tried adding a command to the menu and get no errors, but the new menu still does not appear.

 

Thanks,

Russ

How to reliably close a palette window

$
0
0

Hi,

 

I'm trying to figure out how to positively close a palette window that has both an X in the upper right corner and a Close button. The reason is that I want to use the Window.find() method to determine if the window already exists when someone attempts to launch it, such that duplicate palettes cannot be produced, for example

 

var graphicUtilsDlg = Window.find ("palette", "My Graphic Utilities");

if(graphicUtilsDlg != null) return;

 

So, I define this palette as graphicUtilsDlg, but before I do, I call the method above to see if a current instance exists.

 

On the palette, I have a Close button tied to the following callback:

 

graphicUtilsDlg.closeBtn.onClick = function()

{

    graphicUtilsDlg.close();

    graphicUtilsDlg = null;

};

 

...and the following callback which is invoked by the close() method above and also when the X is clicked:

 

graphicUtilsDlg.onClose = function()

{

    graphicUtilsDlg = null;

};

 

It works fine when I click the Close button. The window closes and the next attempt to open it works normally. However, it does not work properly when I click the X button. It takes two attempts before the window opens again. Somehow, the find() method is returning an object the first time, but not the second time.

 

Anyway, I know this is a bit windy and complex, but does anyone have any expertise here?

 

Thanks,

Russ

Convert Table to Text

$
0
0

I cannot find a method in the framemaker scripting guide for the Table > Convert to Paragraphs command.

 

I found a suspicious Fcode command: FCodes.KBD_TABLE_CONVERT. Not so great. I  neither like Fcodes, nor do think this would do what I want.

 

Advice?

 

Thanks,

 

Jason

iterative loop to create cross-references

$
0
0

I'd like to write a script to create a list of cross-references for all paragraphs with a certain paragraph tag in the current .fm file. Is that possible?

 

(I would use a generated list of paragraphs (.lop file), but RoboHelp 9 doesn't convert the hyperlinks correctly when generating WebHelp.)

 

FM10

FM11 utility to highlight all occurrences of a word

$
0
0

Anchal Arora, Sr Software Engineer for FM, has posted a utility along with the source code to highlight all occurences of a word in a FM document (works only in FM11). I've asked for an Extendscript version of this. If anybody else thinks this would be a good learning example for Extendscripts, please add a comment to the posting.

 

Note: The utility link is buried in the Technical Details section of the post as "attached here".

 

http://blogs.adobe.com/techcomm/2012/10/utility-to-highlight-all-occur rences-of-a-word-in-a-framemaker-document.html

Import Formats flag for FM 11 Object Styles

$
0
0

I am trying to find the Object Styles flag for the SimpleImportFormats function. The Object Model View lists the rest of them (for example, Constants.FF_UFF_PGF), but I can't find one for Object Styles. Any help would be appreciated.

 

Rick

How do I use the find method to find multiple items in a single paragraph?

$
0
0

I am desigining a script to find any instances where ctrl+b and ctrl+i are applied to body text and then replace those character format overrides with Italic or Bold chartag.  Here's what the script is supposed to do:

 

  1. put the find method in a while loop that searches for character format overrides.
  2. If a character format override is found, pass the text range returned by the find method and the CharPropsChange flag to the GetTextForRange method.
  3. Use a boolean compare between the idata of the text item to the character angle and character weight constants.
  4. Whichever boolean evaluates to true, then use the SetTextProp method to set properties of the text range to the properties of the italic or bold character tag.

 

This script does work on the first character format override found however it ignores any other overrides in the same paragraph. The cause of this is that the while loop updates the text loc that the find method uses to the next paragraph in flow. I suspect that i need to add an inner loop that goes through all the text in a single paragraph, where at teach iteration the text loc used by the find method is based on the same paragraph but the offset is modified. I am just not sure how to do that.

 

 

function removeOverrides (pDoc)

{

    var vDocStart = pDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

    var vBoldFmt=getCharFmt (pDoc, 'Bold')

    var vItalicFmt=getCharFmt (pDoc, 'Italic')

    initFA_errno ();

    while (FA_errno==Constants.FE_Success)

    {

        var vTextLoc = new TextLoc(vDocStart,0);

        var vFindParams=findOverrideParams (pDoc);

        var vTextRange=pDoc.Find(vTextLoc,vFindParams);

        if (vTextRange.beg.obj.ObjectValid())

        {

            var vTextItems=pDoc.GetTextForRange (vTextRange, Constants.FTI_CharPropsChange)

            if (vTextItems.length==!0 )

            {

                if (vTextItems[0].idata==Constants.FTF_WEIGHT)

                {

                   pDoc.SetTextProps (vTextRange, vBoldFmt.GetProps())

                    }

                if (vTextItems[0].idata==Constants.FTF_ANGLE)

                {

                   pDoc.SetTextProps (vTextRange, vItalicFmt.GetProps())

                    }

                } else (Log (vLogFileName, '\nERROR: No items were found in the text format array but format override was found: '+pDoc.Name))

            }

        vDocStart=vDocStart.NextPgfInFlow;

        } 

}

 

 

 

function findOverrideParams (pDoc)

{

    var vFindParams = AllocatePropVals(1);

    vFindParams[0].propIdent.num = Constants.FS_FindObject;

    vFindParams[0].propVal.valType = Constants.FT_Integer;

    vFindParams[0].propVal.ival = Constants.FV_FindCharacterFormatOverride;

   return vFindParams;

   }


Using Find() in ExtendScript to search for Italics

$
0
0

I believe it would be the right place to place my query.

 

I'm trying to search for all Italics in my Document with Extendscript.

 

findParams = AllocatePropVals(1);

findParams[0].propIdent.num = Constants.FS_FindCharFmt;

findParams[0].propVal.valType = Constants.FT_String, etc..

 

How do I specify italic in the params?

 

Michael

 

[Thread split from original by moderator]

ExtendScript: Get all text from a document

$
0
0

Hi all.

 

I have the following task: I need to translate a document into another language using ExtendScript. So, as "input" I have a document with a text/graphics/tables/etc. in Language_1 and a "somehow-separated file", which will contain data about translation into the Language_2. E.g.:

 

Some_text_in_language_1     Some_text_in_language_2

Some_other_text_in_language_1     Some_other_text_in_language_2

 

To get the source text from the document, I've tried to use this:

 

var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

while(pgf.ObjectValid()){

     var test = pgf.GetText(Constants.FTI_String);

     var text, str;

     text = "";

     for (var i=0; i < test.len ; i +=1)

     {

          var str=test[i] .sdata.replace(/^\s+|\s+$/g, '') ; 

          text = text + str;

          PrintTextItem (test[i]);

     }                      

     pgf = pgf.NextPgfInFlow;

}

 

But with this, I can only access the regular text in the document (e.g. the text in tables remains untougched). Is there any way I can the all textual data from specified document? Or maybe, the full list of controls, which can contain it, to iterate throught them and extract it one-by-one? Or maybe there's a better way to solve this problem?

 

Thanks in advance! Any advice would be greatly appreciated.

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;
    }

}

Change a command’s position on a menu?

$
0
0

Hi Everyone

 

I wrote a little Script to let FrameMaker 10 user save Version 8 fm-Files.

The Script works good so far, but the Command is not placed a the position in the Menu where I like to have it (after the Save in the File Menu). Do I do something wrong with the PrevMenuItemInMenu?: 



var fileMenu = app.GetNamedMenu("FileMenu")
var saveAsCmd = app.GetNamedCommand("Save");
var newCmd=DefineCommand(1,"Save As fm 8.0" ,"Save As fm 8.0","")
fileMenu.AddCommandToMenu(newCmd)
newCmd.PrevMenuItemInMenu = saveAsCmd; 
UpdateMenus(); 
function Command(cmd){    switch(cmd) {        case 1:            var file;            file  = app.ActiveBook;            if (!file.ObjectValid()) {                file = app.ActiveDoc;                if (!file.ObjectValid()) {                    Alert("No active document or book found", Constants.FF_ALERT_CONTINUE_NOTE);                }              }            var params = GetSaveDefaultParams();            var returnParamsp =new PropVals();            var i = GetPropIndex(params, Constants.FS_FileType);            params[i].propVal.ival =Constants.FV_SaveFmtBinary80;            file.Save(file.Name, params, returnParamsp);            break;        }}

 

Thanks!

Declaring Variables

$
0
0

This is a pretty basic question. How do you know when to declare a variable as new object, and when to simply declare it by naming it?

 

For example, here is a list of variables:

 

var textRange = new TextRange();

var pgf;

 

The textRange variable is declared as a new TextRange object. But the pgf variable is not declared as a new Pgf object. If you try to do this, ExtendScript says, "Pgf does not have a constructor."

 

How do you know if an object has a constructor? I see in the scripting guide that the TextRange object also lists TextRange as a method. That might be a clue, right?

 

Also, is it important to declare a variable as new object if it does have a constructor? For example, is there a difference between these two declarations:

 

var textRange;

var textRange = newTextRange();

 

Or is it more-or-less a preference?

 

Thanks.

 

Jason 

non breaking space for dates

$
0
0

Hi,

 

Being a complete newby for FrameMaker (10 on windows 7), I was wondering if someone has a script (javascript) to converts the normal space with a non breaking space in dates, so that the day and the month stay together.

I'm doing this by hand for the moment, and FM crashes several times, just using the F&C. I'm working with Indesign too, and as seceond question, can I use thes scripts in FM also?

 

thnkx

Find overflow Text

$
0
0

Hi every one

 

is there a script that help to find the text boxes with overflow text (like in indesign with overset text)


Modifying markers at Book level

Adding functionality to FrameMaker objects with .prototype

$
0
0

Has anyone tried extending FrameMaker's built in objects using the .prototype propery? I would like to add some functionality to the Pgf object and it is tempting to use its prototype to add methods so that all Pgf instances will have access to these methods. I don't have a lot of experience with this, so any feedback would be appreciated. Thank you very much.

 

Rick

FM - PDF Conversions Programatically

$
0
0
Hi All , We are going for upgrade of  Frame maker 8 which is on unix system  to FM 10 or 11. We are using Framemaker mainly for renditions, i.e to convert the fm documents to PDF. To convert fm document to PDF we are using the below mentioned command line utility available in FM 8.(on unix). /opt/app/frame8.0/bin/fmprint -i -p Sample.fm.fmtpl Sample.fm Currently the the fm file which need to converted to PDF and the FM 8(installed) are available on the same unix system ,so we were able to initiate/use the command line utility of FM 8. The rendition of the FM to PDF is On -Demand.( We are not running any batch activities/ bulk renditions).We are rendering the document as soon as the document  is available. As we upgrade the FM to newer versions which would be installed on the Windows machine as Frame maker 10 or 11 will not support unix plat form, so can you please let us know which option is better to use i.e we want to convert fm file to PDF using java program without any manual intevention . we came to know that about FDK and extend scripts but we are very new to those !! could you please any one can provide us ways and provide us sample codes/scripts to convert FM file to PDF !! and please let us know which one is better client / server version to do this .

Book level - import master pages and formats

$
0
0

Dear all,

 

I am very new at scripting for framemaker (and a complete novice at JavaScripting) and I find it a bit hard to find information in an environment I'm not familiar in. Maybe you can help me out.

 

What I would like to do:

 

I would like to be able to modify the master pages, page layouts, paragraph formats and character formats in the first document of a book and then initiate the script, which will

  1. import the master pages and formats from the first document into all the other documents (just like if you go via File > Import > Format),
  2. update the book.

 

In the example scripts folder in the installation folder, I have found an example script that goes through all the documents in a book:

 

book=app.ActiveBook;

comp=book.FirstComponentInBook;

while(comp.ObjectValid())

{

        open(comp.Name);

        nextComp=comp.NextBookComponentInDFSOrder;

        prevComp=comp.PrevBookComponentInDFSOrder;

        compType=comp.BookComponentFileType;

        Log("BookComponent.log", "CompName-"+comp.Name);

        Log("BookComponent.log", "comp File Type-"+compType);

        Log("BookComponent.log", "Component Type(Fldr,Grp,file)-"+comp.ComponentType);

        Log("BookComponent.log", "PreviousCompName-"+prevComp.Name);

        Log("BookComponent.log", "nextCompName-"+nextComp.Name);

        Log("BookComponent.log", "---------------------------------");

        //process component here//

        comp=nextComp;

    }

 

function open(filename)

{

openProp = GetOpenDefaultParams()

 

i=GetPropIndex(openProp,Constants.FS_FileIsOldVersion)

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

 

i=GetPropIndex(openProp,Constants.FS_FontNotFoundInCatalog)

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

 

i=GetPropIndex(openProp,Constants.FS_FontNotFoundInDoc)

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

 

i=GetPropIndex(openProp,Constants.FS_FileIsInUse)

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

 

i=GetPropIndex(openProp,Constants.FS_AlertUserAboutFailure)

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

 

retParm = new PropVals()

docOpen=Open(filename,openProp,retParm);

return docOpen;

}

 

 

function Log(logFile,textLine)

{

    file=new File ("C:\\ESLog\\"+logFile);

    file.open("a+", "TEXT", "????");

    file.write(textLine+"\r");

    file.close();

    }

 

That gets me started a bit. I have also seen the line //process component here//, and I am a bit familiar with programming and scripting. I somehow see how this works in principle. But then I am at a loss.

 

I know that there's a lot of documentation on FrameMaker scripting (I have the scripting guide). But I find it hard to find the corresponding information without spending hours of learning.

 

Could someone help me out?

 

Immense gratitude in advance!

Matthias

generating exe file for fdk script : getting error

$
0
0

we trying to convert FM file to PDF using FDK asynchrouns script. we are getting below error while running attched script to crete exe file .

Error "the application has faield to start because icuu32.dll was not found . re- installing the application may fix this problem"

 

Script :

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

#define DONT_REDEFINE // Console app needs native types
#define WBUFLEN 512
#include "fdetypes.h"
#include "futils.h"
#include "fapi.h"
#include "fstrings.h"
#include <windows.h>
#include <ddeml.h> //not required
#include <stdarg.h> //not required

int main(int argc, char **argv)
{
StringT opt_progid;
CLSID pclsid;
LPOLESTR progStr;
HRESULT res;
F_ObjHandleT docId;

// Get the process name.
if(argc == 2)
opt_progid = F_StrCopyString((StringT)argv[1]);
else {
fprintf(stderr, "You must provide a process name.");
return(1);
}

// Convert the process name into a GUID
progStr = (OLECHAR*)malloc( WBUFLEN*sizeof(wchar_t) );
if(0 == MultiByteToWideChar(CP_ACP, 0,
(char *)opt_progid, -1,
  progStr, WBUFLEN )) {
fprintf(stderr, "failed to allocate\n");
return(1);
}
if (progStr[0] == '{') // hex-codes within brackets
res = CLSIDFromString(progStr, &pclsid);
else
res = CLSIDFromProgID(progStr, &pclsid);

if(res == S_OK)
F_ApiWinConnectSession(NULL, NULL, &pclsid);
if (!F_ApiAlive()) {
fprintf(stderr, "No connection: %s\n", opt_progid);
return 1;
}
// Print the name of the current document.
docId = F_ApiGetId(0, FV_SessionId, FP_ActiveDoc);
if (docId) {
StringT docname = F_ApiGetString(FO_Session, docId,
                                                   FP_Name);
fprintf(stderr, "Current document: %s\n", docname);
F_ApiDeallocateString(&docname);
} else
fprintf(stderr, "No active document\n");

return 0;
}

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''

we have got below steps from one of adobe person :

Steps.

 

 

can you please explaine clearly The above steps  and how can we generate PDF for a FM file without manual intervention .

 

the actual requirement is :

 


1) Goto installed location of FM and launch framemaker with specified process id.

eg : $Installdir\FrameMaker.exe /progid:MyProcess
2) Build the asynchronous client exe\dll with the help from attached sample client.
3) Goto the location where client exe is copied and then run with specified FM process id.
eg : asynch_script.exe MyProcess

To resolve few dependencies, you can also copy the client exe to installed location of FM. So the above step in that case would be

$Installdir\ asynch_script.exe MyProcess

 

Hi All , We are going for upgrade of  Frame maker 8 which is on unix system  to FM 10 or 11. We are using Framemaker mainly for renditions, i.e to convert the fm documents to PDF. To convert fm document to PDF we are using the below mentioned command line utility available in FM 8.(on unix). /opt/app/frame8.0/bin/fmprint -i -p Sample.fm.fmtpl Sample.fm Currently the the fm file which need to converted to PDF and the FM 8(installed) are available on the same unix system ,so we were able to initiate/use the command line utility of FM 8. The rendition of the FM to PDF is On -Demand.( We are not running any batch activities/ bulk renditions).We are rendering the document as soon as the document  is available. As we upgrade the FM to newer versions which would be installed on the Windows machine as Frame maker 10 or 11 will not support unix plat form, so can you please let us know which option is better to use i.e we want to convert fm file to PDF using java program without any manual intevention . we came to know that about FDK and extend scripts but we are very new to those !! could you please any one can provide us ways and provide us sample codes/scripts to convert FM file to PDF !! and please let us know which one is better client / server version to do this .

 

please heklp us as it is very important

Viewing all 888 articles
Browse latest View live


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