• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
8

UXP script for calling executable file (Windows, *.exe) with arguments

Explorer ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

I want to call a program (*.exe ) from the UXP *.idjs script. Certain arguments need to be passed to *.exe. The result of the action is the creation of a PDF file that needs to be linked to the *.indd file. Is it possible to do this at this stage of development of idjs scripts in InDesign?

TOPICS
Experiment , Scripting

Views

803

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 26, 2023 Jun 26, 2023

No, not possible.

Votes

Translate

Translate
Community Expert ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

No, not possible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

"The result of the action is the creation of a PDF file that needs to be linked to the *.indd file"

 

What do you need an exe app for in that case? Creating the pdf file is basically done in your idjs. And for attachments, you can embed the pdf. 

 

Or is it the other way around to attach the indd file inside the PDF file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2023 Jun 26, 2023

Copy link to clipboard

Copied

I must compile *.tex files to *.pdf (alone formulas or scientific
graphics).
The source text of formulas can be stored directly in the InDesign file as
text; when the formula is changed, the text can be immediately recompiled
to pdf and inserted into the layout InDesign file.

TEX is very inconvenient in detail (support for CMYK, text tables, and
more), and InDesign does not work with math formulas directly. I want to
automate the matching routine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 28, 2023 Jun 28, 2023

Copy link to clipboard

Copied

Have you considered MathMagic? Looks to me that is the go-to plugin for tex files processing:

http://www.mathmagic.com/product/pro.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 28, 2023 Jun 28, 2023

Copy link to clipboard

Copied

Along the same line as Loic's suggestion, have you looked at pandoc? It's my go-to command line tool for Weird Automated Text Format Conversion Stuff. Never tried to do anything TeX-related with it myself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 28, 2023 Jun 28, 2023

Copy link to clipboard

Copied

Thank you! Looks promising! I copied the manual and plan to play with it according to publishing needs. It will be interesting to see if this product can be used for multilingual publications.
Regarding solving the previously described problem, I decided to try to work with extensions (CEP). We only need to automate the already proven methods of publication layout.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2023 Jun 29, 2023

Copy link to clipboard

Copied

MathType is another option.

 

I've recently created tool, macro for WORD, that converts equations exported on Mac from MathMagic to MathMl as a HTML into native WORD equations. 

The problem wouldn't exist if there was MathType for Mac. 

 

If you are on a PC - why not switch to VBA? 

 

What exactly is your workflow / end result? 

 

ID-Tasker - most powerful tool ever created for InDesign

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2023 Jun 29, 2023

Copy link to clipboard

Copied

I only use it for multilingual publications 🙂

 

(We did a series of thirty-language manuals in print and html versions, where the tech writers stored their work on Github in Markdown, and we automated the process where every time they made changes to the Markdown, new .icml files would replace the old .icml files, and they would auto-update whenever you opened the .indd. Totally useless for you in your current project, of course, but it works quite well.)

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 29, 2023 Jun 29, 2023

Copy link to clipboard

Copied

Hi @vnh68 ,

even with ExtendScript I'm not sure if you could pass arguments to an app you are starting with file.execute().

Though, I'm not sure what you are exactly want to do in the moment you are using ExtendScript's method execute().

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 29, 2023 Jun 29, 2023

Copy link to clipboard

Copied

Suppose we have a formula as text:

$\rm \sigma(\textit{X}_{\textit{i}}) = \sqrt{\displaystyle\sum\limits_{\textit{i}\, =\, 1}^{34}\,\left(\textit{X}_{\textit{i}} - \textit{M}(\textit{X}_{\textit{i}})\right)^2},$

 

And this is how part of the page looks after the script has completed its work:

 

CaptureF.JPG

 

The program creates a high-quality PDF of the formula, it just needs to call the program from the script and paste (using the script) the resulting PDF in the right place on the page.

When calling the program (*.exe), we need to pass the text of the formula as an argument. 

The program itself determines all the sizes of characters, knowing only that the size of the surrounding text is 11 pt.

Also, instead of formulas, there can be TikZ graphics (function graphs, diagrams, etc.)...

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 30, 2023 Jun 30, 2023

Copy link to clipboard

Copied

Not sure where UXP is with doScript at the moment, but with ExtendScript that was pretty much the way to go to execute command line tools from Javascript. You can give it a try.

https://developer.adobe.com/indesign/dom/api/a/Application/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 30, 2023 Jun 30, 2023

Copy link to clipboard

Copied

I've tried these methods with ExtendScript: the File class unfortunately cannot pass arguments to the called program, and the Application class's doScript method does not call any other types of programs than those described in ScriptLanguage, although it is possible to pass arguments. 

I'll try to make a CEP extension. This is new to me, I don't know if there are restrictions for calling programs that operate on files in the operating system. The script for Node easily copes with the task, if called simply from Windows.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2023 Jul 01, 2023

Copy link to clipboard

Copied

If you can't switch to VBA completely - at least you can create short VBA code and call it via doScript() from JS - then in this code you can call exe with arguments.

 

ID-Tasker - most powerful tool ever created for InDesign

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2023 Jul 01, 2023

Copy link to clipboard

Copied

Not sure where UXP is with doScript at the moment,

 

doScript() now works in UXP.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2023 Jul 01, 2023

Copy link to clipboard

Copied

Hi Peter,

I still cannot see InDesign 18.4 as an update here in Germany.

So it could be that @vnh68 also has no access. Should be a matter of days perhaps, but I do not think, that doScript() for UXP is supported with InDesign 2023 version 18.3.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 01, 2023 Jul 01, 2023

Copy link to clipboard

Copied

I do not think, that doScript() for UXP is supported with InDesign 2023 version 18.3.

 

Correct. But it does work in 18.4

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 21, 2023 Jul 21, 2023

Copy link to clipboard

Copied

Hi Peter,
I can get a simple app.doScript( myFunction() ) to work in UXP,
but not as I am used to in ExtendScript like this:

 

app.doScript('do shell script "' + doSomething + '"', ScriptLanguage.APPLESCRIPT_LANGUAGE);

 


ScriptLanguage does not seem to be supported yet?
Thanks Stefan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 21, 2023 Jul 21, 2023

Copy link to clipboard

Copied

Found it here:
InDesign UXP DOM 
that ScriptLanguage.APPLESCRIPT_LANGUGE
is not supported, correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 21, 2023 Jul 21, 2023

Copy link to clipboard

Copied

This code worked. The docs need to be fixed.

const { app, ScriptLanguage } = require('indesign') ;
app.doScript(`display dialog "Hello from AppleScript"`, ScriptLanguage.APPLESCRIPT_LANGUAGE) ;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 23, 2023 Jul 23, 2023

Copy link to clipboard

Copied

LATEST

Works for me now too. I forgot the require command. Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

Will this work for you ?

 

https://stackoverflow.com/questions/3152482/running-exe-from-javascript

 

 

ID-Tasker - most powerful tool ever created for InDesign

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines