I have done 100s of scripts for FrameMaker, where 170 events are available to have the code react on application and user actions. I did not find any events documentation for Illustrator. Is there anything within ExtendScript to have code activated, e.g. after a document was opened ?
If I need another interface to make this work (I found references to ActionScript but these messages were ancient), such pointers would also be useful.
For my application I need to have Illustrator open a specific page from a PDF file and process it to put positioning info of line segments into an XML file. That part of the work is done. Of course this only works when starting the script from Visual Studio Code.
I need a mechanism that makes the script run outside of Visual Studio Code. The main script is driven from another Adobe application (FrameMaker) and determines which page in which PDF document should be opened and processed by the Illustrator script. I was wondering if Bridge would handle this type of inter-application work but it would be easier to just have a script that automatically runs whenever Illustrator is started or opens a document.
but how to initiate that script from somewhere else. Is there a way to run a script from Windows that launches Illustrator and then runs the script?
there might be options, it depends on what "somewhere else" is. Can you describe exactly what your workflow is?
OK, tne full workflow:
I have XML files plus corresponding PDFs. The XML contains the structure of the content but not all styling details. One important part is the widths of table columns and the presence of cell borders. These are visible in the PDF but none of the existing feature extraction tools can reliably retrieve that information (as they all focus on text extraction). This is where Illustrator's PDF rendering comes in: I can retrieve all the table borders from a PDF page opened in Illustrator and write that into an XML file. That is the script that I need to call from the main application, which is FrameMaker.
FrameMaker opens the XML, my script (firing automatically when the XML is opened) finds each table (and the page on whch the table appears), then it needs to get Illustrator to open that page in the PDF, retrieve the table bordes and write them into an XML file, which is then used by FrameMaker to set the column widths and visible borders in the XML file.
I cannot use batch files as Windows security blocks that (I tried with other batch scripts). I am looking for a way to make Illustrator automatically run a script when a particular file is opened. This is also how I control what FrameMaker does - without requiring human interaction. The entire process should run automatically without a GUI (using FrameMaker Publishing Server for this pipeline).
all right, thanks for the detailed info.
so, you have FrameMaker script that needs to trigger an illustrator script at some point.
I just google searched that FM supports extendscript, that makes things easier.
We could use
// this goes in your FM script var yourAiScript = File("full_path_to_your_ai_Script.jsx"); yourAiScript.execute(); // make sure your illustrator Script has the following line at the very top // #target illustrator; // without the double slash (uncomment)
it also supports "Inter-application communication and messaging"
let's try this, open a document in illustrator, go to FM and run the following FM script
// this goes in your FM script illustrator.executeScript("alert('Hello from ' + app.name + '-' + app.version + ' - document name: ' + app.activeDocument.name)");
let me know if either of them work
Thanks for the hints. I will have to try them at some later stage, as I am currently working with Illustrator on my MacOS, with FrameMaker running on a virtual PC, as that does not exist for MacOS. I assume both applications will have to run on the same OS to make this inter-app stuff work. Due to Adobe's licensing model I will have to move all of my work to the native Windows PC that I have available, but that will take some time to set up. I will post an update when I have the chance to test it. It would make my task a lot easier if it does.
I tried both methods but neither of them works. The #target is not showing up as legal directive in VSCode, but I ignored that and tried to run the script from FM as you mentioned. No dice. Executing the script via the illustrator.executeScript method did not give any reaction in Illustrator either. I did see that VSCode picked up that line of code and showed it in a new code window, but there was no further action on it.
It seems that the inter application support that existed earlier in the ESTK is not or not entirely covered by the VSCode package. But then, when I run the script from FM (i.e. outside of the VSCode debugger) there is no reaction from the AI side, either. No error message from FM on the execute code line, BTW.
did you try the scripts with your current set up, from virtual FM to native OS Illustrator?
No, I ran it from FM (on my virtual PC) to Illustrtor (on the same virtual PC). It should also work across to the Mac OS, but that would introduce another interface that I have no control over. The final application will run on a true PC, anyway. I still need to get AI installed on my native Windows PC so that I can try the setup there. Will let you know if that turns out to be successful.
Try to alert the app name only in the Ai script with that execute script method, there could have been a case where there was not an open document and it failed silently.
The script in AI opens a document, so no, that would not change anything. The script works fine when I run it from Visual Studio Code. Nothing happens when trying to run this from FM. But thanks for the suggestion.
The technology behind that "illustrator.executeScript…" snippet is BridgeTalk. The illustrator.something methods are just short wrappers for BridgeTalk calls. There are plenty explanations and examples, I like this one which appears to be close to the original docs that came with ESTK.
Then, have a look at "/Library/Application Support/Adobe/Startup Scripts CC/Illustrator 2022/illustrator-20.0.jsx" on your Mac for the actual code. This code should also be present on your Windows machine as soon you install Illustrator, and executed on startup of all ExtendScript hosts including FM.
Copy paste lines 548 thru 579 into your script, eventually uncomment that error handling, then just step thru the mentioned file using the VSCode or ESTK debugger, and watch out for errors.
When using the VSCode debugger, make it connect to Illustrator's targetengine "main" - that's the one processing the "eval" when the BridgeTalk call went thru.
Thanks for the detailed explanation and pointer to documents and scripts. I am concentrating on completing the FrameMaker side of the scripting now, but will return to the automation pipeline with Illustrator early next year. I will update this topic when I find the method, so that others can also benefit from my results.