When I start a service manual for a new product, I would like to have dialog boxes open that asks for specific information to define the variables of the template. Is scripting what I am looking for and able to do this? I extremley little experience with Framemaker 2017. Thank you.
Is it possible to create a script to get user input when beginning a New Book?
FrameMaker UI freezing while script is running
Hello guys,
I have a couple of questions for you.
When I am running my script, the script is actually working correctly in the background, but the FrameMaker UI is freezing and not reacting until the script is being shut down.
First question: How can this strange behavior be imrpoved?
Second question: How can I tell FrameMaker that a certain script must always be started when FM is starting (Autorun)?
Thanks a lot!
Selim
Timeout caused by loops
Hello guys, its me again.
While trying to fix the startup problems, I encountered a completely new bug.
My script runs perfectly when started in ExtendScript Toolkit. I am using infinite loops for socket operations, which can be broken under certain conditions (e.g. wrong request params etc.)
I am receiving following error when my script is being started from FM:
The line mentioned above always varies - I repeat: the script runs well when being started in ExtendScript Toolkit.
I guess that the troublemaker are my infinite loops, but unfortunately I need them just the way they are.
How can I tell FM to disable this timeout?
Thanks thanks thanks.
Selim
I have installed FrameMaker 2017 and cannot run scripts
Hi all,
I have recently installed FrameMaker 2017 and am unable to runs scripts.
From the FrameMaker menu I have tried File > Run and nothing happens.
I have also tried to create a new script by going file > Script > New Script and nothing happens.
I have looked in the start menu and Adobe Endscript is not there, which used to be packaged with FrameMaker 12 to create the scripts.
Is Adobe Extendscript required to be downloaded and installed to run scripts inside FrameMaker 2017?
Is there a work around to run scripts inside of FrameMaker 2017 without Adobe Extendscript.
Cheers
Invalid text location
Dear all,
Int he following script I want to place a variable at a particular position in a paragraph.
Obviously my method to define a TextLocation in line 11 is wrong. Line 26is never executed and hence no variable inserted.
TestInsertVariable (); function TestInsertVariable () { var paraText = "Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts." var oDoc = app.ActiveDoc, sValue, sVarName, oTextLoc, oPgf; if(oDoc.ObjectValid()) { oPgf = oDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf; oTextLoc = new TextLoc(oPgf, 0); oDoc.AddText(oTextLoc, paraText); // create a paragraph oTextLoc = new TextLoc(oPgf, 17); // arbitrary place sVarName = "GugusVariable"; sValue = "--- Anything I want to see in my variable ---"; InsertVariable (oDoc, oTextLoc, sVarName, sValue); } else { alert ("Document does not exist or is invalid"); } } //--- end TestInsertVariable function InsertVariable (oDoc, oTextLoc, sVarName, sValue) { //=== Insert variable at location ==== var oVar; $.bp(true); oVar = oDoc.NewAnchoredFormattedVar (sVarName, oTextLoc); if (oVar.ObjectValid ()) { oVar.Fmt = sValue; } } //--- end InsertVariable
Do I need the detour with TextSelection, etc. ?
FDK sample build issue - unresolved __declspec(dllImport)
I'm working with the trial version of Framemaker and I downloaded the FDK. I'm running VS2017, and I can't get a good build. I started with unresolved external symbols for printf (for which I found an answer to add legacy_stdio_definitions.lib; to the project's linker input, and an unresolved reference to __declspec(dllImport) which I cannot find.
What do I need to do to get a build for these samples so that I can properly evaluate the usefullness to our organization, please?
Thanks,
Kim
How to get object attributes of Frame anchor?
Hi all,
I need to fetch the frame anchor object attributes to prepare a list of text attributes.
Anchored Frame > Object Attributes > Text Attributes.
I tried following
F_ObjHandleT hGrfObjId = F_ApiGetId(FV_SessionId, docId, FP_FirstGraphicInDoc); /* Traverse list of graphics, anchored frames. */ while (hGrfObjId != NULL) { UIntT uType = F_ApiGetObjectType(docId, hGrfObjId); if (uType == FO_AFrame) { F_AttributesT attribList = F_ApiGetAttributes(docId, hGrfObjId); for (UIntT i = 0; i < attribList.len; i++) { F_Printf(NULL, "Attribute %d: %s ||| %s.\n", i, attribList.val[i].name, attribList.val[i].values); } } hGrfObjId = F_ApiGetId(m_doc.getDocId(), hGrfObjId, FP_NextGraphicInDoc); }
All seems to be inline as per fdk but I never get anything in from F_ApiGetAttributes(). It always returning len = 0 and val = null.
Am I missing anything here? If this is not correct way of extracting attributes, please suggest me right way.
Thank you.
Regards,
Paresh
Let user decide which structured application to use for xml-file import
Hey guys,
I am fairly new to the FrameMaker-scripting-thing. I basically have a folder, full of .xml files that shall be opened with a structured application and then be saved as a .fm file. I can already do that but I have to manually tell FrameMaker which structured application to use (as in How do I load an XML file, and save it as an fm file). But I can't really say which one should be used. I'd rather have the user specify the application once for the first file (maybe even open the dialog that can be seen when manually opening a .xml-file) and use it for the rest of the files as well.
Pseudo-Code:
var structApp = ChooseStructApp();
openXmlFile(filePath, structApp);
Does anyone know how to do anything like that?
Kind regards,
Tom
jsx versus jsxbin
Dear all,
I observe a difference in script behaviour when using jsx sources compared to jsxbin:
My large script FMcalc consists of 10 modules with a total of 208 functions:
Module name | Containing |
---|---|
FMcalc.jsx | #includes to all other modules (except the language modules); main(), Command(cmd), SetUpMenues(), SetupFMcalc() etc. |
FMcalc_Globals.jsx | #includes to the language modules; global declarations |
FMcalc_Ancillary.jsx | Ancillary functions such as OpenPdfAtDestination (pdfFile, location), PadWith0(number, nPlaces), CloneObject (oTarget, oSource), CopyToClipboard (theString), etc. |
FMcalc_dialogC.jsx FMcalc_dialogS.jsx FMcalc_dialogDS.jsx FMcalc_dialogV.jsx | All but the last define palettes. dialogDS allows to set building blocks and settings for the process. These modules contain the Window definition and the corrspoinding action functions (e.g. ButtonEvalC () to evaluate contents of calc markers). DialogV is an input-check for DialogDS and not a palette. |
FMcalc_Evaluation.jsx FMcalc_Markers.jsx FMcalc_Math.jsx | Evaluation contains functions for analysing statements and evaluating formulas etc. Markers contains functions to handle markers and Math contains special math functions such as M_Asinh(xx) (arcus sinus hyprbolicus) |
FMcalc_Texts_en.jsx FMcalc_Texts_de.jsx FMcalc_Texts_fr.jsx | These modules contain UI texts wich are cloned into a general text object depending on the current FM language. In the dilaogues and messages only this general text object is referenced. |
- The jsxbin is built by opening FMcalc.jsx and exporting as jsxbin.
- When installing this FMcalc.jsxbin into the FM startup folder (together with an fm-template file and a pdf help file) provides a corrclty working script.
- When trying to use the jsx sources things don't work any more: The script loads without error, but the dialogue texts are not in the dialogues and settings are only known in the main module (FMcalc.jsx), not in the other modules, e.g. FMcalc_Evaluation.jsx in the function EvaluateStmntsC (text) { //Evaluate contents of #calc marker statement}. Outside of the main module only the intitial values as defined in FMcalc_Globals are known. There they are either set to distinct values or to undefined.
- I have observed that the jsxbin is a flattened out item - as if I would concatenate all the source modules to a single file. Hence 'script-directory' is the same in all functions. Evaluting the script directory in one of the included source modules provides a different level than in the main module which includes the others.
After reading about some ExtendScript include quirks (e.g. by williamadowling) I'm completely puzzled. It's about Indesign, but this may also be true for FM: #include requires absolte paths !?! This would be OK on my own machine - but nobody else could use my script. The main script currently start with these lines:
#target framemaker #include FMcalc\FMcalc_Globals.jsx // all declarations #include FMcalc\FMcalc_Ancillary.jsx // ancillary functions #include FMcalc\FMcalc_dialogC.jsx // incl. button functions etc. #include FMcalc\FMcalc_dialogS.jsx // incl. button functions etc. #include FMcalc\FMcalc_dialogDS.jsx // incl. button functions etc. #include FMcalc\FMcalc_dialogV.jsx // ancillary dialogue #include FMcalc\FMcalc_Evaluation.jsx // for the evaluation process #include FMcalc\FMcalc_Markers.jsx // functions related to markers #include FMcalc\FMcalc_Math.jsx // math functions for evaluation #include FMcalc\FMcalc_Texts_en.jsx // From the relevant one the object will be cloned #include FMcalc\FMcalc_Texts_de.jsx // see FMcalc\FMcalc_Ancillary.jsx, SwitchUIlanguage #include FMcalc\FMcalc_Texts_fr.jsx main (); function main () { // Calling SetupFMcalc, SetupNotifications, ReportInfo, SetUpMenus } function SetUpMenus () { //=== Define the menu items for document and book } function Command (cmd) { ... case 2: CalculateInDoc(); break; ... } function CalculateInDoc() { // Evaluate Calc/Series markers in document // Called by Command, CalculateInBook // Calling SaveCurrentLocation, SetDisplay, GetDSPanelItems, CollectMarkers, CollectVariables, // EvaluateC, PaletteCalcMarkers, RestoreLocation, FindAndDeleteVariable, InsertVariable, // DeleteUnusedVariables, GetRefPageCategory, oTxtScheme, GetAllSchemes, EvaluateS, // PaletteSeriesMarkers } ...
So what is the secret of breaking up a long script into modules to avoid clutter in the Startup folder and nevertheless provide source code rather than jsxbin?
Klaus
Edit 2018-03-08 10:59
Mimicing the include process of the jsxbin building I have put everything together and get a complely unmanageable jsx file of nearly 8000 lines. But also here the settings are not gotten as defined in an early executed routine, not even the default from the initial global setting, but undefined!
How to access the Publisher module
Does anybody know if the Publisher module is exposed to FM's Extendscript (or FDK)? I looked through all of the scripting info and the FDK info, .h and config files and couldn't find any references to it other than the TPUBforFMDoc (Book/DITA esc ph shortcut) command. I need to kick off the Publish module after some manipulation and use a specified STS file depending upon the manipulation.
How to get Conditional tag name for F_TextItemT
Hi,
I am trying to get Condition tag name if present for TextItem inside paragraph
F_TextRangeT trSel, trFound; F_IntsT condIds; F_PropValsT findParams; trSel.beg.objId = trSel.end.objId = hPgfId; trSel.beg.offset = trSel.end.offset = 0; findParams = F_ApiAllocatePropVals(1); findParams.val[0].propIdent.num = FS_FindText; findParams.val[0].propVal.valType = FT_String; //For demo "c" is the first character in the string of every F_TextItemT findParams.val[0].propVal.u.sval = F_StrCopyString((ConStringT)"c"); trFound = F_ApiFind(docId, &trSel.beg, &findParams); //Setting insertion point F_ApiSetTextRange(FV_SessionId, m_doc.getDocId(), FP_TextSelection, &trFound); //Get condition ids at insertion point condIds = F_ApiGetInts(FV_SessionId, docId, FP_InCond);
I am able to get the name by making every textitem a insertion point and fetching its condition values.
Is there any way to fetch conditional tag name without adding insertion point for a textItem?
Thanks,
Abhijeet
[Moved to Scripting Forum by moderator: more chance of programming expertise here.]
Running a Publish script at startup
I have a script that reads a simple XML file, which has to be in the same folder as the script and with the same base name. For example, the script is called PublishOutput.jsx and the XML file is called PublishOutput.xml. The purpose of the script is to output Responsive HTML from a particular book. Here is the XML file that determines the script's parameters:
<?xml version="1.0" encoding="UTF-8"?><settings> <input>C:\data\scripts\SAS\20180212_InsertMarkers\BA2.book</input> <sts>C:\Program Files (x86)\Adobe\AdobeFrameMaker2015\fminit\Publisher\Default.sts</sts> <outputFolder>C:\DATA\Scripts\SAS\20180212_InsertMarkers\Output</outputFolder> <type>Responsive HTML5</type></settings>
The script works fine if it and the settings file don't reside in one of the startup folders. But, what I want to do is run this from the startup folder so it runs automatically when I launch FrameMaker. But here it doesn't work. When I launch FrameMaker, the script opens the book, but then when the Publish command is invoked, it launches another instance of FrameMaker and the whole process is short-circuited. Any ideas would be appreciated. If you want to test it, you will have to edit the values in the xml file to reflect paths on your computer. Here is the script:
#target framemaker main (); function main () { // Get the settings from the xml file. var settings = getSettings (); if (settings.errorMsgs.length === 0) { // Check the settings for missing elements and invalid paths. settings = checkSettings (settings.xml); if (settings.errorMsgs.length === 0) { settings = publishOutput (settings); writeLog (settings.errorMsgs); } else { writeLog (settings.errorMsgs); } } else { writeLog (settings.errorMsgs); return; } } function checkSettings (settingsXml) { var settings = {errorMsgs: []}, value; value = String (settingsXml.input); if (value !== "") { if (File (value).exists === true) { settings.input = value; } else { settings.errorMsgs.push ("Input file does not exist: " + value); } } else { settings.errorMsgs.push ("input element is missing or empty in the settings file."); } value = String (settingsXml.sts); if (value !== "") { if (File (value).exists === true) { settings.sts = value; } else { settings.errorMsgs.push ("Publish settings file does not exist: " + value); } } else { settings.errorMsgs.push ("sts element is missing or empty in the settings file."); } value = String (settingsXml.outputFolder); if (value !== "") { if (Folder (value).exists === true) { settings.folder = value; } else { settings.errorMsgs.push ("Output folder does not exist: " + value); } } else { settings.errorMsgs.push ("outputFolder element is missing or empty in the settings file."); } value = String (settingsXml.type); if (value !== "") { settings.type = value; } else { settings.errorMsgs.push ("type element is missing or empty in the settings file."); } return settings; } function publishOutput (settings) { var book; book = getDocOrBook (settings.input, "Book"); if ((book) && (book.ObjectValid () === 1)) { // Send the parameters to the Publish client. setSts (settings.sts); setOutputFolder (settings.folder); callPublisher (settings.type); if (book.openedByScript === true) { book.Close (true); } } else { settings.errorMsgs.push ("The book could not be opened: " + settings.input); } return settings; } function setSts (sts) { var cmd = "SetMCPSetting " + sts; return CallClient ("FMPublisher", cmd); } function setOutputFolder (folder) { var cmd = "SetOutputLocation " + folder; return CallClient ("FMPublisher", cmd); } function callPublisher (type) { var cmd = "MCPPublish " + type; return CallClient ("FMPublisher", cmd); } function writeLog (msgs) { var log; // Make a File object for the log file. log = new File ($.fileName).fsName.replace (/\.[^\.]+$/, ".log"); log = File (log); log.open ("w"); // Write the messages to the log. log.write (msgs.join ("\r")); // Close the log file. log.close (); } function getSettings () { var settingsFile, e, settings = {errorMsgs: []}; // Make a File object for the settings XML file. settingsFile = new File ($.fileName).fsName.replace (/\.[^\.]+$/, ".xml"); settingsFile = File (settingsFile); if (settingsFile.exists === false) { settings.errorMsgs.push ("The settings file does not exist:"); settings.errorMsgs.push (settingsFile.fsName); return settings; } // Open and read the settings file. settingsFile.open ("r"); try { settings.xml = new XML (settingsFile.read ()); } catch (e) { settings.errorMsgs.push ("There was an error reading the settings file:"); settings.errorMsgs.push (settingsFile.fsName); settings.errorMsgs.push (e); } // Close the settings file. settingsFile.close (); // Return the settings object. return settings; } function getDocOrBook (filename, type) { var docOrBook; // See if the document or book is already open. docOrBook = docOrBookIsOpen (filename, type); if (docOrBook) { return docOrBook; } else { // The document or book is not already open, so open it. return openDocOrBook (filename); } } function docOrBookIsOpen (filename, type) { var file, docOrBook; // Make a File object from the file name. file = File (filename); // Uppercase the filename for easy comparison. filename = file.fullName.toUpperCase (); if (type === "Doc") { // Loop through the open documents in the session. docOrBook = app.FirstOpenDoc; while (docOrBook.ObjectValid ()) { // Compare the document’s name with the one we are looking for. if (File (docOrBook.Name).fullName.toUpperCase () === filename) { // The document we are looking for is open. docOrBook.openedByScript = false; return docOrBook; } docOrBook = docOrBook.NextOpenDocInSession; } } else { // type === "Book" // Loop through the open books in the session. docOrBook = app.FirstOpenBook; while (docOrBook.ObjectValid ()) { // Compare the book's name with the one we are looking for. if (File (docOrBook.Name).fullName.toUpperCase () === filename) { // The book we are looking for is open. docOrBook.openedByScript = false; return docOrBook; } docOrBook = docOrBook.NextOpenBookInSession; } } } function openDocOrBook (filename) { var i = 0, docOrBook, openProps, retParm; // Get default property list for opening documents. openProps = GetOpenDefaultParams (); // Get a property list to return any error messages. retParm = new PropVals(); // Set specific open property values to open the document. i=GetPropIndex(openProps,Constants.FS_AlertUserAboutFailure); openProps[i].propVal.ival=false; i=GetPropIndex(openProps,Constants.FS_MakeVisible); openProps[i].propVal.ival=true; i=GetPropIndex(openProps,Constants.FS_FileIsOldVersion); openProps[i].propVal.ival=Constants.FV_DoOK; i=GetPropIndex(openProps,Constants.FS_FileIsInUse); openProps[i].propVal.ival=Constants.FV_ResetLockAndContinue; i=GetPropIndex(openProps,Constants.FS_FontChangedMetric); openProps[i].propVal.ival=Constants.FV_DoOK; i=GetPropIndex(openProps,Constants.FS_FontNotFoundInCatalog); openProps[i].propVal.ival=Constants.FV_DoOK; i=GetPropIndex(openProps,Constants.FS_FontNotFoundInDoc); openProps[i].propVal.ival=Constants.FV_DoOK; i=GetPropIndex(openProps,Constants.FS_RefFileNotFound); openProps[i].propVal.ival=Constants.FV_AllowAllRefFilesUnFindable; // Attempt to open the document or book docOrBook = Open (filename,openProps,retParm); if (docOrBook.ObjectValid () === 1) { docOrBook.openedByScript = true; return docOrBook; // Return the document or book object. } else { // If the document can't be open, print the errors to the Console. PrintOpenStatus (retParm); } }
Removing Character Tags w/ Script
My department has recently finished converting to Frame 2017, updating tags/formats/layouts, and many other activities to bring some old Frame files into the modern world. We're at the point where we can realistically begin automating and simplifying various processes, which is leading us to the land of extendscript.
I'd like to script the complete removal of individual character tags from text. Adobe has provided the very useful SuperFindChange script, which can swap one tag for another. I'm wondering if there is some easy way for a complete novice, like myself, to modify the script to simply remove the tag rather than swap it. I can manually copy a character format, use Find to locate the tag I want to strip, and then replace the tag with the copied format. I can also do the classic, Default Font and then reapply the paragraph tag (for paragraphs that are completely character tagged). It seems like I should be able to script it without too much fuss, but I'm probably oversimplifying.
Maybe someone has already done this or there is something out there on the interwebz, but my Google-fu is failing me. Can someone point me in the right direction or suggest a starting point? Maybe even take pity me on me and give me a snippet of code I can plug into the SuperFindChange script?
Batch editing and saving Fm files.
Hi, I am using FrameMaker v12. I have about 40 odd documents related to a single project which I need to update just for three things: Version Number, Date, and Copyright Year. The vesion and date are treated as variables, the copyright year isn't. After editing these standard values across all 40 documents, I need to save all of them as PDFs. Is there any way I can automate this process? I am aware of extendscript and believe this can very well be achieved using that tool.
FDK C/C++ - Frame Book conversion to XML (FrameMaker 12)
Greetings.
I am using FrameMaker 12 with the C/C++ FDK. I have looked into scripting the feature of converting a Frame Book to an XML. I have looked at the FDK Reference and Programmer's guide for assitance.
- What is the recommeded sequence to convert the book file to XML? My thought is as follows:
1. Open the book
2. Iterate over each compenent
i) Open each component
ii) Save each component as XML
3. Close the book
There are more questions to ask but I thought I would start a discussion and work through the solution. Thank you in advance.
fit page in window in framemaker.i have used var zoom= oDoc.Constants.FV_FIT_WINDOW_TO_PAGE; in javascript code.The result is -3.but nothing change in framemaker document.how to i change the zoom level in framemaker using extendscript?
fit page in window in framemaker.i have used var zoom= oDoc.Constants.FV_FIT_WINDOW_TO_PAGE; in javascript code.The result is -3.but nothing change in framemaker document.how to i change the zoom level in framemaker using extendscript?
Open fm document.
how to open an existing framemaker document using extendscript?
Remove space in fm doc.
How to remove unwanted double spaces and paragraph marks in framemaker document using extendscript ?
Convert fm to pdf
How to convert framemaker doc into pdf using extendcript.?
Convert fm to pdf
How to convert framemaker doc into pdf using extendcript.?